-----------------------------
.NetCF: C#-VB.Net
Documentation eVC
(C/C++/MFC), eVB: ----------------------------- Software Developers Special Topics
Printing Utilities |
double pwid=prce.PrPgWidth; // // Print the contents of text box in two columns per page // Note: for simplicity of this code, we assume "text" string to contain all text to be printed. // // Column width for each column will be half of paper width minus 3/4 inch center margin double colwid=(prce.PrPgWidth-0.75)/2; double left=0; int rlen; // We are going to loop printing columns until all text has been printed for (;text.Length>0;) { //Use DrawTextFlow with "NOFORMFEED" flow option - this will flow text into next column // and return number of characters printed in the column rlen=prce.DrawTextFlow(text,0,0,left,-1,colwid,-1,-1,PrinterCE.FLOW_OPTIONS.NOFORMFEED); if (rlen==0 || rlen>=text.Length) break; //If nothing printed, we are done text=text.Remove(0,rlen); //Get rid of the text printed in this column // If we just printed left column, move to right side of page. If printed right column // do NewPage and prepare to print left column on next page. if (left==0) { left=colwid+0.75; } else { left=0; prce.NewPage(); } } prce.EndDoc(); //Done with this page - print it } catch (PrinterCEException exc) { if (prce!=null) { prce.ShutDown(); //Done - free PrinterCE resources // NOTE: Only call ShutDown if PrinterCE instance is about to be destroyed. } prce=null; MessageBox.Show("PrinterCE Exception","Exception"); } finally { if (prce!=null) { prce.ShutDown(); //Done - free PrinterCE resources // NOTE: Only call ShutDown if PrinterCE instance is about to be destroyed. } prce=null; } |