Sunteți pe pagina 1din 3

2/3/13

PrintDocument in C#.net 4.0 - CodeProject


9,629,515 members (25,890 online) Nirupendar 573 Sign out

home

articles

quick answers

discussions

features

community

help

print document in c#

Ask a Question

All Questions All Unanswered Mine

FAQ

Next

PrintDocument in C#.net 4.0


See more: C#4.0
I want to display the pages in a PrintDocument(may atleast 1000 pages). In PrintPreview Control it takes a long time to display the Document. Is there a way to Reduce the time ?
Vote:

Your Filters
Interested (e.g. C++, VB) Ignored (e.g. Homework, LOLCode) Save Filters
Update

Top Experts in 24hrs


Posted 8 Sep '12 - 7:20 Joseph.cse 144 Permalink

0 1 2 3

Abhishek Pant Krunal Rohit Hasham Ahmad OriginalGriff Abhinav S

532 530 440 372 303

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

Top Experts this month


0 Krunal Rohit 1 Abhishek Pant 2 OriginalGriff 3 Abhinav S 4 Sergey Alexandrovich Kryukov 1,461 1,013 925 646 586

Reply

Have a Question or Comment?

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

PrintDocument in C#.net 4.0 - CodeProject

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

Collapse | Copy Code

srotn =srotn +dcmn.eEeetyd&3;rnAe&3;.neHM; tCnet tCnet ouetgtlmnBI(#9Pitra#9)inrTL

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"

Posted 17 Sep '12 - 21:09 Rickin Kane 1.8K

Edited 17 Sep '12 - 21:11 v2

Permalink

Have a Question or Comment?

Add your solution here


B I U S small BIG c d v r < oe a > & link [^] encode untab indent outdent

www.codeproject.com/Questions/455478/PrintDocument-in-Csharp-net-4-0

2/3

2/3/13

PrintDocument in C#.net 4.0 - CodeProject

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)

Advertise | Privacy | Mobile Web03 | 2.6.13022.3 | Last Updated 17 Sep 2012

Layout: fixed | fluid

Copyright CodeProject, 1999-2013 All Rights Reserved. Terms of Use

www.codeproject.com/Questions/455478/PrintDocument-in-Csharp-net-4-0

3/3

S-ar putea să vă placă și