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:
Form Test

Demonstrates the capabilities of positioning text, changing text justification and drawing lines and rectangles to create a form.

See full size printed output

 
PrinterCE prce = null;
try //Use
{
  prce = new PrinterCE(); //Create instance of PrinterCE class
  prce.SelectPrinter(true);
  prce.PrOrientation = PrinterCE.ORIENTATION.PORTRAIT; //Force to portrait mode
  prce.ScaleMode = PrinterCE.MEASUREMENT_UNITS.INCHES; //Everything in inches
  prce.PrLeftMargin = 0.5;
  prce.PrTopMargin = 0.7;
  prce.PrRightMargin = 0.5;
  prce.PrBottomMargin = 0.7;
  prce.DrawWidth = 0.02;
 
  //Draw major rectangles and lines
  prce.DrawRect(0,0, 5.7, 0.5);
 
  //Draw a shaded rectangle
  prce.FillColor=Color.LightGray;
  prce.FillStyle=PrinterCE.FILL_STYLE.SOLID;
  prce.DrawRect(0, 0, 5.7, 0.25);
  prce.DrawLine(2, 0, 2, 0.5);
  prce.DrawLine(3.8, 0, 3.8, 0.5);
 
  //Draw text strings
  prce.FontSize = 12;
  prce.FontBold = true;
  prce.ForeColor = Color.Black;
  prce.JustifyHoriz = PrinterCE.JUSTIFY_HORIZ.CENTER;
  prce.JustifyVert = PrinterCE.JUSTIFY_VERT.CENTER;
  prce.DrawText("Account Number", 1, 0.125);
  prce.DrawText("Meter Number", 2.9, 0.125);
  prce.DrawText("Payment Due By", 4.75, 0.125);
  //Draw dark box with clear inner box
  prce.FillColor = Color.DarkGray;
  prce.DrawRect(5.7, 0, 7.5, 0.7);
  prce.ForeColor = Color.White;
  prce.FontSize = 9;
  prce.FontBoldVal = 1000; //As bold as possible
  prce.DrawText("PLEASE PAY THIS AMOUNT", 6.6, 0.1);
  prce.FillColor = Color.White;
  prce.DrawRoundedRect(5.8, 0.2, 7.4, 0.6, 0.15, 0.15);
 
  prce.ForeColor = Color.Black;
  prce.FontSize = 12;
  prce.FontBold = false;
  prce.DrawRect(4, 0.9, 7.5, 1.7);
  prce.DrawLine( 4, 1.1, 6.2, 1.1);
  prce.DrawLine(4, 1.3, 7.5, 1.3);
  prce.DrawLine(5.1, 1.1, 5.1, 1.7);
  prce.DrawLine(6.2, 0.9, 6.2, 1.7);
  prce.DrawText("METER READINGS", 5.1, 1);
  prce.DrawText("USAGE", 6.85, 1);
  prce.DrawText("Cubic Feet", 6.85, 1.2);
  prce.DrawRect(5, 1.9, 7.5, 2.6);
  prce.DrawText("To avoid Late Payment charge,", 6.25, 2.05);
  prce.DrawText("full payment must be received by", 6.25, 2.25);
  prce.JustifyHoriz = PrinterCE.JUSTIFY_HORIZ.LEFT;
  prce.FontSize = 8;
  prce.DrawText("PLEASE RETURN THIS STUB WITH PAYMENT", 0, 2.8);
  prce.JustifyHoriz = PrinterCE.JUSTIFY_HORIZ.RIGHT;
  prce.DrawText("TO ENSURE PROPER CREDIT, PLEASE WRITE YOUR ACCOUNT NUMBER ON YOU CHECK.", 7.5, 2.8);
  prce.FontSize = 14;
  prce.FontBold = true;
  prce.FontItalic = true;
  prce.JustifyHoriz = PrinterCE.JUSTIFY_HORIZ.CENTER;
  prce.DrawText("THANK YOU FOR YOUR PROMPT PAYMENT", 2.5, 2.5);
 
  //Fill in customer specific data here - could be database driven
  prce.FontBold = false;
  prce.FontItalic = false;
  prce.DrawText("06-036171-408", 1, 0.375);
  prce.DrawText("R52581782D-AB", 2.9, 0.375);
  prce.DrawText("09-22-99", 4.75, 0.375);
  prce.FontSize = 16;
  prce.FontBold = true;
  prce.DrawText("$70.01", 6.6, 0.4);
  prce.FontSize = 12;
  prce.FontBold = false;
  prce.DrawText("09-22-99", 6.25, 2.45);
  prce.DrawText("06-15-99", 4.55, 1.2);
  prce.DrawText("08-17-99", 5.65, 1.2);
  prce.FontSize = 14;
  prce.DrawText("145,990", 4.55, 1.5);
  prce.DrawText("151,280", 5.65, 1.5);
  prce.DrawText("5,290", 6.85, 1.5);
 
  prce.JustifyHoriz = PrinterCE.JUSTIFY_HORIZ.LEFT;
  prce.FontSize = 16;
  prce.DrawText("John Doe Smith", 0.5, 1.2);
  prce.DrawText("12345 Main Street");
  prce.DrawText("Camino, CA. 95709-5555");
  prce.DrawWidth = 0.01; //Draw very thin line
  prce.DrawLine(0, 3, 7.5, 3);
  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;
}