Académique Documents
Professionnel Documents
Culture Documents
home
articles
quick answers
discussions
features
community
help
print document in c#
Ask a Question
FAQ
Next
Your Filters
Interested (e.g. C++, VB) Ignored (e.g. Homework, LOLCode) Save Filters
Update
0 1 2 3
Add a Solution
Comments
Rickin Kane - 10 Sep '12 - 6:02 you need to print a single page or multiple page at once , means do u wish to print the curent open page Member 8153759 - 17 Sep '12 - 9:00 Single page at a time will be handy... Reply
Reply
1 solution Solution 2
Vote:
I dont know your exact requirement ,but if you want a print preview for your Page then the most simplest solution is to write a Javascript as below i dont remember from where i found the below Javascript it was quite a long time , but it has always worked wondoers for me
Collapse | Copy Code
<citlnug=jvsrp"tp=tx/aacit> srp agae"aacit ye"etjvsrp" fnto Pitotn( { ucin rnCnet) pitidw=wno.pn","yidw, rnWno idwoe(" mwno" "egt60wdh99srlT,eial=,colas1lcto="; hih=5,it=9,colorszbe1srlbr=,oain1) vrsrotn ="hm>ha>;/ I yuueti srp isd <ed a tCnet <tl<ed" / f o s hs cit nie ha> o tepg,teemgtb err S Ia keigisd bd (eaeo <ed) n h ae hr ih e ro. o m epn nie oy bcu f ha> srotn =srotn +"ttePitPeiw/il>; tCnet tCnet <il>rn rve<tte" srotn =srotn +"ln he=./.ApTee/eal/aecs tCnet tCnet <ik rf'../p_hmsDfutPg.s' tp=tx/s'rl'tlset /" ye'etcs e=Syehe' >; srotn =srotn +"/ed" tCnet tCnet <ha>; srotn =srotn +"bd>; tCnet tCnet <oy" srotn =srotn +"dvsye'it:0%tx-lg:et'" tCnet tCnet <i tl=wdh10;etainlf;>; srotn =srotn +"igat'mgi'sc'../mgsLg.p' tCnet tCnet <m l=Iaed r=./.Iae/oojg /" >; srotn =srotn +"/i>; tCnet tCnet <dv"
www.codeproject.com/Questions/455478/PrintDocument-in-Csharp-net-4-0
1/3
2/3/13
srotn =srotn +"dvsye'it:5;etainrgt'" tCnet tCnet <i tl=wdh9%tx-lg:ih;>; srotn =srotn +"igat'rnI'tte'rn' tCnet tCnet <m l=PitD il=Pit cas'rnIo' sc'../mgspitcnjg ocik'idwpit) /" ls=Pitcn r=./.Iae/rnio.p' nlc=wno.rn(' >; srotn =srotn +"/i>; tCnet tCnet <dv" srotn =srotn +"dvsye'it:0%'" tCnet tCnet <i tl=wdh10;>; srotn =srotn +dcmn.eEeetyd'rnAe'.neHM; tCnet tCnet ouetgtlmnBI(Pitra)inrTL srotn =srotn +"/i>; tCnet tCnet <dv" srotn =srotn +"/oy" tCnet tCnet <bd>; pitidwdcmn.rt(tCnet; rnWno.ouetwiesrotn) pitidwdcmn.ls(; rnWno.ouetcoe) pitidwfcs) rnWno.ou(; rtr fle eun as; } <srp> /cit
Once you done with javascript ,you will see the line inside a Javscript as below
the PrintArea is the one which you need to print , so all the content of page which need to be printed should come under Print Area if you have multiple area you can write as per below
Collapse | Copy Code
srotn =srotn +dcmn.eEeetyd'rnHae'.neHM; tCnet tCnet ouetgtlmnBI(pitedr)inrTL srotn =srotn +dcmn.eEeetyd'rnTte)inrTL tCnet tCnet ouetgtlmnBI(pitil'.neHM; srotn =srotn +dcmn.eEeetyd'iApcctoSau'.neHM; tCnet tCnet ouetgtlmnBI(dvpliaintts)inrTL srotn =srotn +dcmn.eEeetyd'rn5)inrTL tCnet tCnet ouetgtlmnBI(Pit'.neHM; srotn =srotn +dcmn.eEeetyd'rn1)inrTL tCnet tCnet ouetgtlmnBI(Pit'.neHM; srotn =srotn +dcmn.eEeetyd'rn2)inrTL tCnet tCnet ouetgtlmnBI(Pit'.neHM;
amd then in your button on which click you want to load a print preview you do following
Collapse | Copy Code
<s:utnI=bnrn"rnt"evr Csls=bto"Tx=Pit apBto D"tPit ua=sre" sCas"utn et"rn" OCinCik"eunPitotn(; /<t> nletlc=rtr rnCnet)" >/d <dsye"it:1%> t tl=wdh 0"
Permalink
www.codeproject.com/Questions/455478/PrintDocument-in-Csharp-net-4-0
2/3
2/3/13
Preview
Submit your solution!
When answering a question please: 1. Read the question carefully. 2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar. 3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome. Let's work to help developers, not make them feel stupid.
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)
www.codeproject.com/Questions/455478/PrintDocument-in-Csharp-net-4-0
3/3