Wireless File and Print Solutions for Windows Mobile, BlackBerry, iPhone, MIDP, Palm OS, Symbian UIQ and Nokia Series 60 Handhelds and Smartphones

   Downloads Products Support Purchase    News Partners Developers About Us
PrintBoy SDK Enterprise Edition

for eMbedded Visual C++ Software Developers

Source Code Examples

Simple Hello World Example:

     
    if (0 == ReportLayoutSetLicenseKey (L"PRINTBOY_SDK_TRIAL"))
    {
        ReportLayout *pReport = ReportLayoutCreate ();
        if (pReport)
        {
            ReportLayoutBegin (pReport, L"My Report");

            ReportLayoutAddText ( pReport, L"Hello World!", ALIGN_CENTER, FONT_TNR, 14, 1, 0 );

            ReportLayoutEnd (pReport);

            ReportLayoutExecute (pReport);
            
            ReportLayoutDestroy (pReport);

        }
    }

Simple Bitmap Example:

     
    if (0 == ReportLayoutSetLicenseKey (L"PRINTBOY_SDK_TRIAL"))
    {
        ReportLayout *pReport = ReportLayoutCreate ();
        if (pReport)
        {
            HBITMAP hBitmap = NULL;
 
            ReportLayoutBegin (pReport, L"Bitmap Example");

            hBitmap = ::LoadBitmap( AfxGetApp()->m_hInstance,  MAKEINTRESOURCE ( IDB_BITMAP_SIGNATURE ) );
            ReportLayoutAddBitmap ( pReport, hBitmap, 120, 80, ALIGN_LEFT );

            ReportLayoutEnd (pReport);

            ReportLayoutExecute (pReport);
            
            ReportLayoutDestroy (pReport);

        }
    }

Simple Barcode Example (requires printer with resident barcode support):

     
    if (0 == ReportLayoutSetLicenseKey (L"PRINTBOY_SDK_TRIAL"))
    {
        ReportLayout *pReport = ReportLayoutCreate ();
        if (pReport)
        {
            ReportLayoutAddBarcode ( pReport, L"Code39", L"135792", 50, 1, 3, 1, L"" );

            ReportLayoutEnd (pReport);

            ReportLayoutExecute (pReport);
            
            ReportLayoutDestroy (pReport);

        }
    }

Simple Logo Example (requires printer with resident logo support):

     
    if (0 == ReportLayoutSetLicenseKey (L"PRINTBOY_SDK_TRIAL"))
    {
        ReportLayout *pReport = ReportLayoutCreate ();
        if (pReport)
        {
	    // ask the printer to use a logo with an id of "1"
            ReportLayoutAddLogo ( pReport, L"1", 100, 117, L"" );

            ReportLayoutEnd (pReport);

            ReportLayoutExecute (pReport);
            
            ReportLayoutDestroy (pReport);

        }
    }

Receipt Example Using a Table:

    if (0 == ReportLayoutSetLicenseKey (L"PRINTBOY_SDK_TRIAL"))
    {
        ReportLayout *pReport = ReportLayoutCreate ();
        if (pReport)
        {
            ReportLayoutBegin (pReport, L"Receipt");

            ReportLayoutAddText ( pReport, L"Bachmann Software", ALIGN_CENTER, FONT_TNR, 14, 1, 0 );
            ReportLayoutAddText ( pReport, L"1 Main Street", ALIGN_CENTER, FONT_TNR, 12, 0, 0 );
            ReportLayoutAddText ( pReport, L"Anytown, USA", ALIGN_CENTER, FONT_TNR, 12, 0, 0 );
            ReportLayoutAddText ( pReport, L"web: http://www.bachmannsoftware.com", ALIGN_CENTER, FONT_TNR, 12, 0, 0 );
            ReportLayoutAddText ( pReport, L"email: sales@bachmannsoftware.com", ALIGN_CENTER, FONT_TNR, 12, 0, 0 );
            ReportLayoutAddText ( pReport, L"phone: (973) 729-9427", ALIGN_CENTER, FONT_TNR, 12, 0, 0 );
            ReportLayoutSkipLines ( pReport, 1 );

            //add a date and time
            ReportLayoutAddText ( pReport, L"Date: 8/24/2004 5:26 PM", ALIGN_CENTER, FONT_TNR, 12, 0, 0 );
            ReportLayoutSkipLines( pReport, 1 );

            //table is 100 pct of the page
            ReportLayoutBeginTable ( pReport, 100, 0 );

            //Items
            ReportLayoutBeginTableRow( pReport );
            ReportLayoutAddTableCell ( pReport, L"Printboy Premium Edition", 60, ALIGN_LEFT, FONT_TNR, 10, 0, 0, 0 );
            ReportLayoutAddTableCell ( pReport, L"1 @ $39.99", 40, ALIGN_RIGHT, FONT_TNR, 10, 0, 0, 0 );
            ReportLayoutEndTableRow( pReport );

            ReportLayoutBeginTableRow( pReport );
            ReportLayoutAddTableCell ( pReport, L"InfraReady Adapter", 60, ALIGN_LEFT, FONT_TNR, 10, 0, 0, 0 );
            ReportLayoutAddTableCell ( pReport, L"1 @ $89.99", 40, ALIGN_RIGHT, FONT_TNR, 10, 0, 0, 0 );
            ReportLayoutEndTableRow( pReport );

            ReportLayoutBeginTableRow( pReport );
            ReportLayoutAddTableCell ( pReport, L"", 60, ALIGN_LEFT, FONT_TNR, 10, 0, 0, 0 );
            ReportLayoutAddTableCell ( pReport, L"----------", 40, ALIGN_RIGHT, FONT_TNR, 10, 0, 0, 0 );
            ReportLayoutEndTableRow( pReport );

            ReportLayoutBeginTableRow( pReport );
            ReportLayoutAddTableCell ( pReport, L"Total", 60, ALIGN_LEFT, FONT_TNR, 10, 1, 0, 0 );
            ReportLayoutAddTableCell ( pReport, L"$129.98", 40, ALIGN_RIGHT, FONT_TNR, 10, 1, 0, 0 );
            ReportLayoutEndTableRow( pReport );

            //end table
            ReportLayoutEndTable( pReport );

            // end the report layout
            ReportLayoutEnd (pReport);

            // now execute the report!
            ReportLayoutExecute (pReport);
            
            // clean up
            ReportLayoutDestroy (pReport );
        }


Invoice Example Using Multiple Tables:

    if (0 == ReportLayoutSetLicenseKey (L"PRINTBOY_SDK_TRIAL"))
    {
	ReportLayout *pReport = ReportLayoutCreate ();
	if (pReport)
	{
	    char szTemp[50];
   	    BitmapPtr pbmp;
            MemHandle bitmapH;
            
 	    ReportLayoutBegin (pReport, L"Invoice Report");

            // table is 100 pct of the page
            ReportLayoutBeginTable (pReport, 100, false);

            ReportLayoutBeginTableRow (pReport);	
			
            // Customer and Invoice
            // left side is 60pct, right side is 40 pct

            ReportLayoutAddTableCell (pReport, L"", 60, ALIGN_LEFT, L"Times New Roman",  10, false, false, false);
            ReportLayoutAddTableCell (pReport, L"Invoice", 40, ALIGN_LEFT, L"Times New Roman",  12, true, false, true);
            ReportLayoutEndTableRow (pReport);

            ReportLayoutBeginTableRow (pReport);	
            ReportLayoutAddTableCell (pReport, L"1735 County Road", 60, ALIGN_LEFT, "Times New Roman",  10, false, false, false);
            ReportLayoutAddTableCell (pReport, L"M100", 40, ALIGN_LEFT, L"Times New Roman",  10, false, false, false);
            ReportLayoutEndTableRow (pReport);

            ReportLayoutBeginTableRow (pReport);	
            ReportLayoutAddTableCell (pReport, L"", 60, ALIGN_LEFT, L"Times New Roman",  10, false, false, false);
            ReportLayoutAddTableCell (pReport, L"Date", 40, ALIGN_LEFT, L"Times New Roman",  10, false, false, false);
            ReportLayoutEndTableRow (pReport);

            ReportLayoutBeginTableRow (pReport);	
            ReportLayoutAddTableCell (pReport, L"", 60, ALIGN_LEFT, "Times New Roman",  10, false, false, false);
            ReportLayoutAddTableCell (pReport, L"6/20/2002", 40, ALIGN_LEFT, L"Times New Roman",  10, false, false, false);
            ReportLayoutEndTableRow (pReport);

            ReportLayoutBeginTableRow (pReport);	
            ReportLayoutAddTableCell (pReport, L"Bayshore", 60, ALIGN_LEFT, L"Times New Roman",  10, false, false, false);
            ReportLayoutAddTableCell (pReport, L"", 40, ALIGN_LEFT, L"Times New Roman",  10, false, false, false);
            ReportLayoutEndTableRow (pReport);

            ReportLayoutBeginTableRow (pReport);	
            ReportLayoutAddTableCell (pReport, L"CA", 60, ALIGN_LEFT, L"Times New Roman",  10, false, false, false);
            ReportLayoutAddTableCell (pReport, L"", 40, ALIGN_LEFT, L"Times New Roman",  10, false, false, false);
            ReportLayoutEndTableRow (pReport);

            ReportLayoutBeginTableRow (pReport);	
            ReportLayoutAddTableCell (pReport, L"94326", 60, ALIGN_LEFT, L"Times New Roman",  10, false, false, false);
            ReportLayoutAddTableCell (pReport, L"", 40, 	ALIGN_LEFT, L"Times New Roman",  10, false, false, false);
            ReportLayoutEndTableRow (pReport);
			
            ReportLayoutBeginTableRow (pReport);	
            ReportLayoutAddTableCell (pReport, L"US", 60, ALIGN_LEFT, L"Times New Roman",  10, false, false, false);
            ReportLayoutAddTableCell (pReport, L"", 40, ALIGN_LEFT, L"Times New Roman",  10, false, false, false);
            ReportLayoutEndTableRow (pReport);

            // customer and invoice info are done
            ReportLayoutEndTable (pReport);

            // Bill To and Ship To
            // 50 pct each
            ReportLayoutBeginTable (pReport, 100, false);

            ReportLayoutBeginTableRow (pReport);	
            ReportLayoutAddTableCell (pReport, L"Bill To", 50, ALIGN_LEFT, L"Times New Roman",  12, true, false, true);
            ReportLayoutAddTableCell (pReport, L"Ship To", 50, ALIGN_LEFT, L"Times New Roman",  12, true, false, true);
            ReportLayoutEndTableRow (pReport);

            ReportLayoutBeginTableRow (pReport);	
            ReportLayoutAddTableCell (pReport, L"Kristy Abercrombie", 50, ALIGN_LEFT, L"Times New Roman",  10, false, false, false);
            ReportLayoutAddTableCell (pReport, L"Kristy Abercrombie", 50, ALIGN_LEFT, L"Times New Roman",  10, false, false, false);
            ReportLayoutEndTableRow (pReport);
			
            ReportLayouBeginTableRow (pReport);	
            ReportLayoutAddTableCell (pReport, L"5647 Cypress Hill Rd", 50, ALIGN_LEFT, L"Times New Roman",  10, false, false, false);
            ReportLayoutAddTableCell (pReport, L"5647 Cypress Hill Rd", 50, ALIGN_LEFT, L"Times New Roman",  10, false, false, false);
            ReportLayoutEndTableRow (pReport);
			
            ReportLayoutBeginTableRow (pReport);	
            ReportLayoutAddTableCell (pReport, L"", 50, ALIGN_LEFT, L"Times New Roman",  10, false, false, false);
            ReportLayoutAddTableCell (pReport, L"", 50, ALIGN_LEFT, L"Times New Roman",  10, false, false, false);
            ReportLayoutEndTableRow (pReport);
			
            ReportLayoutBeginTableRow (pReport);	
            ReportLayoutAddTableCell (pReport, L"Bayshore", 50, ALIGN_LEFT, L"Times New Roman",  10, false, false, false);
            ReportLayoutAddTableCell (pReport, L"Bayshore", 50, ALIGN_LEFT, L"Times New Roman",  10, false, false, false);
            ReportLayoutEndTableRow (pReport);
			
            ReportLayoutBeginTableRow (pReport);	
            ReportLayoutAddTableCell (pReport, L"CA", 50, ALIGN_LEFT, L"Times New Roman",  10, false, false, false);
            ReportLayoutAddTableCell (pReport, L"CA", 50, ALIGN_LEFT, L"Times New Roman",  10, false, false, false);
            ReportLayoutEndTableRow (pReport);
			
            ReportLayoutBeginTableRow (pReport);	
            ReportLayoutAddTableCell (pReport, L"94326", 50, ALIGN_LEFT, L"Times New Roman",  10, false, false, false);
            ReportLayoutAddTableCell (pReport, L"94326", 50, ALIGN_LEFT, L"Times New Roman",  10, false, false, false);
            ReportLayoutEndTableRow (pReport);

            // Bill To and Ship To are now done
            ReportLayoutEndTable (pReport);

            ReportLayoutBeginTable (pReport, 100, false);

            // PO/term, etc
            ReportLayoutBeginTableRow (pReport);	
            ReportLayoutAddTableCell (pReport, L"PO", 15, ALIGN_LEFT, L"Times New Roman",  10, true, false, true);
            ReportLayoutAddTableCell (pReport, L"Term", 20, ALIGN_LEFT, L"Times New Roman",  10, true, false, true);
            ReportLayoutAddTableCell (pReport, L"Rep", 15, ALIGN_LEFT, L"Times New Roman",  10, true, false, true);
            ReportLayoutAddTableCell (pReport, L"Ship", 20, ALIGN_LEFT, L"Times New Roman",  10, true, false, true);
            ReportLayoutAddTableCell (pReport, L"Via", 15, ALIGN_LEFT, L"Times New Roman",  10, true, false, true);
            ReportLayoutAddTableCell (pReport, L"FOB", 15, ALIGN_LEFT, L"Times New Roman",  10, true, false, true);
            ReportLayoutEndTableRow (pReport);

            ReportLayoutBeginTableRow (pReport);	
            ReportLayoutAddTableCell (pReport, L"", 15, ALIGN_LEFT, L"Times New Roman",  10, false, false, true);
            ReportLayoutAddTableCell (pReport, L"", 20, ALIGN_LEFT, L"Times New Roman",  10, false, false, true);
            ReportLayoutAddTableCell (pReport, L"", 15, ALIGN_LEFT, L"Times New Roman",  10, false, false, true);
            ReportLayoutAddTableCell (pReport, L"", 20, ALIGN_LEFT, L"Times New Roman",  10, false, false, true);
            ReportLayoutAddTableCell (pReport, L"", 15, ALIGN_LEFT, L"Times New Roman",  10, false, false, true);
            ReportLayoutAddTableCell (pReport, L"", 15, ALIGN_LEFT, L"Times New Roman",  10, false, false, true);
            ReportLayoutEndTableRow (pReport);

            // PO/Term are now done
            ReportLayoutEndTable (pReport);

            // Items table
            ReportLayoutBeginTable (pReport, 100, false);

            ReportLayoutBeginTableRow (pReport);	
            ReportLayoutAddTableCell (pReport, L"Qty", 15, ALIGN_RIGHT, L"Times New Roman",  10, true, false, true);
            ReportLayoutAddTableCell (pReport, L"Desc", 37, ALIGN_LEFT, L"Times New Roman",  10, true, false, true);
            ReportLayoutAddTableCell (pReport, L"Price", 23, ALIGN_RIGHT, L"Times New Roman",  10, true, false, true);
            ReportLayoutAddTableCell (pReport, L"Amount", 25, ALIGN_RIGHT, L"Times New Roman",  10, true, false, true);
            ReportLayoutEndTableRow (pReport);

            ReportLayoutBeginTableRow (pReport);	
            ReportLayoutAddTableCell (pReport, L"1", 15, ALIGN_RIGHT, L"Times New Roman",  10, false, false, true);
            ReportLayoutAddTableCell (pReport, L"Cabinets", 37, ALIGN_LEFT, L"Times New Roman",  10, false, false, true);
            ReportLayoutAddTableCell (pReport, L"0.00", 23, ALIGN_RIGHT, L"Times New Roman",  10, false, false, true);
            ReportLayoutAddTableCell (pReport, L"0.00", 25, ALIGN_RIGHT, L"Times New Roman",  10, false, false, true);
            ReportLayoutEndTableRow (pReport);

            ReportLayoutBeginTableRow (pReport);	
            ReportLayoutAddTableCell (pReport, L"1", 15, ALIGN_RIGHT, L"Times New Roman",  10, false, false, true);
            ReportLayoutAddTableCell (pReport, L"standard interior door frame", 37, ALIGN_LEFT, "Times New Roman",  10, false, false, true);
            ReportLayoutAddTableCell (pReport, L"0.00", 23, ALIGN_RIGHT, L"Times New Roman",  10, false, false, true);
            ReportLayoutAddTableCell (pReport, L"0.00", 25, ALIGN_RIGHT, L"Times New Roman",  10, false, false, true);
            ReportLayoutEndTableRow (pReport);

            ReportLayoutBeginTableRow (pReport);	
            ReportLayoutAddTableCell (pReport, L"1", 15, ALIGN_RIGHT, L"Times New Roman",  10, false, false, true);
            ReportLayoutAddTableCell (pReport, L"Exterior wood door", 37, ALIGN_LEFT, "Times New Roman",  10, false, false, true);
            ReportLayoutAddTableCell (pReport, L"120.00", 23, ALIGN_RIGHT, L"Times New Roman",  10, false, false, true);
            ReportLayoutAddTableCell (pReport, L"120.00", 25, ALIGN_RIGHT, L"Times New Roman",  10, false, false, true);
            ReportLayoutEndTableRow (pReport);

            // End Items table
            ReportLayoutEndTable (pReport);

            // Totals
            ReportLayoutBeginTable (pReport, 100, false);

            ReportLayoutBeginTableRow (pReport);	

            ReportLayoutAddTableCell (pReport, L"", 50, ALIGN_LEFT, L"Times New Roman",  10, false, false, true);
            ReportLayoutAddTableCell (pReport, L"Sub Total", 25, ALIGN_LEFT, L"Times New Roman",  10, false, false, true);
            ReportLayoutAddTableCell (pReport, L"120.00", 25, ALIGN_RIGHT, L"Times New Roman",  10, false, false, true);
            ReportLayoutEndTableRow (pReport);

            ReportLayoutBeginTableRow (pReport);	
            ReportLayoutAddTableCell (pReport, L"", 50, ALIGN_LEFT, L"Times New Roman",  10, false, false, false);
            ReportLayoutAddTableCell (pReport, L"Tax", 25, ALIGN_LEFT, L"Times New Roman",  10, false, false, true);
            ReportLayoutAddTableCell (pReport, L"9.30", 25, ALIGN_RIGHT, L"Times New Roman",  10, false, false, true);
            ReportLayoutEndTableRow (pReport);

            ReportLayoutBeginTableRow (pReport);	
            ReportLayoutAddTableCell (pReport, L"", 50, ALIGN_LEFT, L"Times New Roman",  10, true, false, false);
            ReportLayoutAddTableCell (pReport, L"Total", 25, ALIGN_LEFT, L"Times New Roman",  10, true, false, true);
            ReportLayoutAddTableCell (pReport, L"129.30", 25, ALIGN_RIGHT, L"Times New Roman",  10, true, false, true);
            ReportLayoutEndTableRow (pReport);

            ReportLayoutBeginTableRow (pReport);	
            ReportLayoutAddTableCell (pReport, L"", 50, ALIGN_LEFT, L"Times New Roman",  10, false, false, false);
            ReportLayoutAddTableCell (pReport, L"Applied", 25, ALIGN_LEFT, L"Times New Roman",  10, false, false, true);
            ReportLayoutAddTableCell (pReport, L"0.00", 25, ALIGN_RIGHT, L"Times New Roman",  10, false, false, true);
            ReportLayoutEndTableRow (pReport);

            ReportLayoutBeginTableRow (pReport);	

            // draw signature bitmap
            HBITMAP hBitmap = ::LoadBitmap( AfxGetApp()->m_hInstance,  MAKEINTRESOURCE ( IDB_BITMAP_SIGNATURE ) );
            ReportLayoutAddBitmap ( pReport, hBitmap, 120, 80, ALIGN_LEFT );
			
            ReportLayoutAddTableCell (pReport, L"Balance", 20, ALIGN_LEFT, L"Times New Roman",  10, false, false, true);
            ReportLayoutAddTableCell (pReport, L"129.30", 20, ALIGN_RIGHT, L"Times New Roman",  10, false, false, true);
            ReportLayoutEndTableRow (pReport);

            // Totals are now done
            ReportLayoutEndTable (pReport);

            ReportLayoutAddBarcode( pReport, BarCodeCode39, L"123456", 50, 2, 6, true, 0 );

            // end the report layout
            ReportLayoutEnd (pReport);

            // now execute the report!
            ReportLayoutExecute (pReport);
			
            // clean up
            ReportLayoutDestroy (pReport );
        }
    }

Copyright 2004 Bachmann Software & Services, LLC