FieldSoftware
Home

PrinterCE SDK
   General Info
   Download
   Purchase & Pricing

Developer Info
   eVC MFC
   eVC C/C++
   eVB

Special Features
   AsciiCE
   PrintDC
   BarcodeCE

Documentation
   PrinterCE SDK
   AsciiCE
   PrintDC
   BarcodeCE

Special Topics
  Supported Printers
  Bluetooth Printing
  Network Printing

.Net CF C# or VB.Net:
  PrinterCE.NetCF SDK

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

Software Developers
  PrinterCE SDK
 
PrinterCE.NetCF SDK
  PocketHTMLprint SDK

Printing Utilities
  PrintPocketCE
  PIEprint
  PocketPixPrint
  PocketShot
 
PocketClipPrint

 Arcade Games
  SockOut
  MazeCraze

Contact Info

Special AsciiCE2 Topic: 
Intermixing PrinterCE and AsciiCE2

[ AsciiCE2 Documentation]    [AsciiCE2 Developer Info]

It is possible, although tricky, to intermix PrinterCE and AsciiCE2. For example, perhaps you want to print out a company logo (using a bitimage graphic file), print a lot of text quickly, and then print out a bitimage file containing a signature. Certainly this is easy enough to do with PrinterCE, but some printers are very slow in printing in bit-image mode, which is how PrinterCE always prints. You could instead use PrinterCE to print out the graphic image files and use AsciiCE2 to quickly print out all of the text. 

The following code (which is from the PrCEDemo demo program) shows how intermixing PrinterCE and AsciiCE is done. spPrinterCE is a pointer to an instance of PrinterCE that has previously been created, while spAsciiCE is a pointer to an instance of AsciiCE2. 

Note that the tricky part of this is that PrinterCE and AsciiCE printing output cannot overlap. Normally, PrinterCE will gather all printing operations from your application until it receives an "EndDoc()" or "NewPage()" function call. At this point, PrinterCE proceeds to print an entire page and then resets itself for the start of another page (or for ending the printing session).

When PrinterCE and AsciiCE operations are intermixed, all PrinterCE commands that have been received will be printed when an AsciiCE printing command is sent. However no formfeed operation will occur. Instead, the AsciiCE printing operations will begin immediately below the last PrinterCE printed portion of the page. AsciiCE printing operations are handled as they are received.

When PrinterCE commands are sent after AsciiCE printing, these PrinterCE printing operations will be positioned immediately following the last AsciiCE printing location. If you need to send printer control commands to the printer, you can skip the flushing of PrinterCE operations by passing a negative byte count to AsciiCE2's Write or WriteVar method.

NOTE: Some page printers, such as Canon and HP, force paper feed when switching between text mode and bit-image mode.

The basic steps for using PrinterCE and AsciiCE together are:

  1. Use PrinterCE to establish a connection to a printer.

  2. Notify AsciiCE that we will be using a shared connection.

  3. Send PrinterCE and AsciiCE2 batches of printing commands.

  4. Close AsciiCE connection

  5. Close PrinterCE connection.

  long errVal, success;
  spPrinterCE->put_ScaleMode(vbInches); //All PrinterCE measurements are in inches

  spPrinterCE->SelectPrinter(); //Establish connection with printer via PrinterCE
  spPrinterCE->get_StatusCheck((long *) &errVal); //Get status - see if error in connecting to printer
  if (errVal!=vbNoError) return; //if error, skip printing
  //Use AsciiCE2 to establish a "shared" connection by specifying "PORT_PRINTERCE"
  spAsciiCE->SelectPortEx(PORT_PRINTERCE, S_DONTCARE, S_DONTCARE,0,&success);
  if (success) {
      // Use PrinterCE to draw some text and a picture.
      spPrinterCE->put_FontSize(15);
      spPrinterCE->put_FontBold(VARIANT_TRUE);
      spPrinterCE->put_FontItalic(VARIANT_TRUE);
      spPrinterCE->DrawText(CComBSTR(_T("PrinterCE+AsciiCE2")),NULL,NULL,NULL);
 
      // Now use AsciiCE to print out a text string
      spAsciiCE->CrLf(); //Move to next line
      spAsciiCE->Text(CComBSTR("ASCII Text"));
      spAsciiCE->CrLf();
     
      // Use PrinterCE to print out another image immediately below the last Ascii text string
      spPrinterCE->DrawText(CComBSTR(_T("Back to PrinterCE text")),NULL,NULL,NULL);
      // We are done... close AsciiCE shared port
      spAsciiCE->ClosePort();
  }
  //Close PrinterCE printer connection
  spPrinterCE->EndDoc();