FieldSoftware
Home

-----------------------------

.NetCF: C#-VB.Net
 Software Developers


PrinterCE.NetCF SDK
   General Info
   Download & Install
   Purchase & Pricing
   Upgrade from PrinterCE

Getting Started with:
 
C#   -   VB.Net

  Code Examples

Documentation
  PrinterCE for .Net CF
  AsciiCE for .Net CF
  BarcodeCE for .Net CF

eVC (C/C++/MFC), eVB:
  PrinterCE SDK

-----------------------------

Software Developers
  PrinterCE SDK
  PrinterCE.NetCF SDK
  PocketHTMLprint SDK

Special Topics
  Supported Printers
  Bluetooth Printing
  Network Printing

Printing Utilities
  PrintPocketCE
  PIEprint
  PocketPixPrint
  PocketShot
 
PocketClipPrint

Arcade Games
  SockOut
  MazeCraze

Contact Info

PrinterCE.NetCF Example:
TextColumns

Use DrawTextFlow with NOFORMFEED option to print text in 2 columns per page.

See full size printed output

 
PrinterCE prce = null;
try
{
  prce = new PrinterCE(); //Create instance of PrinterCE class
  prce.SelectPrinter(true);
  prce.ScaleMode = PrinterCE.MEASUREMENT_UNITS.INCHES; //Everything in inches

  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;
}