Bachmann Software Home
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 for Mobile Application Developers
PrintBoy SDK
for Mobile Application Developers
Buy It
Try It

PrintBoy SDK Example:
Using ReportLayout with C++ to Create an Invoice

This example uses the ReportLayout API from PrintBoy SDK to create a real-world, formatted invoice with tables, fonts, and left, center and right alignment.

This code will produce a report that will print using any PrintBoy printer driver.

Even better, the same code will compile and run for both Palm and PocketPC handheld platforms!


// Create the report layout
ReportLayout *pReport = ReportLayoutCreate ();
if (pReport)
{
	ReportLayoutBegin (pReport, "Invoice Report");
	
	// table is 100 pct of the page
	ReportLayoutBeginTable (pReport, 100, false);
	
	// Customer and Invoice
	// left side is 60pct, right side is 40 pct
	ReportLayoutBeginTableRow (pReport);	
	ReportLayoutAddTableCell (pReport, "", 60, ALIGN_LEFT, "Times New Roman",  10, false, false, false);
	ReportLayoutAddTableCell (pReport, "Invoice", 40, ALIGN_LEFT, "Times New Roman",  12, true, false, true);
	ReportLayoutEndTableRow (pReport);

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

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

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

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

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

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

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

	// This table contains Bill To and Ship To information
	// 50 pct each
	ReportLayoutBeginTable (pReport, 100, false);
	
	ReportLayoutBeginTableRow (pReport);	
	ReportLayoutAddTableCell (pReport, "Bill To", 50, ALIGN_LEFT, "Times New Roman",  12, true, false, true);
	ReportLayoutAddTableCell (pReport, "Ship To", 50, ALIGN_LEFT, "Times New Roman",  12, true, false, true);
	ReportLayoutEndTableRow (pReport);
	
	ReportLayoutBeginTableRow (pReport);	
	ReportLayoutAddTableCell (pReport, "Kristy Abercrombie", 50, ALIGN_LEFT, "Times New Roman",  10, false, false, false);
	ReportLayoutAddTableCell (pReport, "Kristy Abercrombie", 50, ALIGN_LEFT, "Times New Roman",  10, false, false, false);
	ReportLayoutEndTableRow (pReport);
	
	ReportLayoutBeginTableRow (pReport);	
	ReportLayoutAddTableCell (pReport, "5647 Cypress Hill Rd", 50, ALIGN_LEFT, "Times New Roman",  10, false, false, false);
	ReportLayoutAddTableCell (pReport, "5647 Cypress Hill Rd", 50, ALIGN_LEFT, "Times New Roman",  10, false, false, false);
	ReportLayoutEndTableRow (pReport);
	
	ReportLayoutBeginTableRow (pReport);	
	ReportLayoutAddTableCell (pReport, "", 50, ALIGN_LEFT, "Times New Roman",  10, false, false, false);
	ReportLayoutAddTableCell (pReport, "", 50, ALIGN_LEFT, "Times New Roman",  10, false, false, false);
	ReportLayoutEndTableRow (pReport);
	
	ReportLayoutBeginTableRow (pReport);	
	ReportLayoutAddTableCell (pReport, "Bayshore", 50, ALIGN_LEFT, "Times New Roman",  10, false, false, false);
	ReportLayoutAddTableCell (pReport, "Bayshore", 50, ALIGN_LEFT, "Times New Roman",  10, false, false, false);
	ReportLayoutEndTableRow (pReport);
	
	ReportLayoutBeginTableRow (pReport);	
	ReportLayoutAddTableCell (pReport, "CA", 50, ALIGN_LEFT, "Times New Roman",  10, false, false, false);
	ReportLayoutAddTableCell (pReport, "CA", 50, ALIGN_LEFT, "Times New Roman",  10, false, false, false);
	ReportLayoutEndTableRow (pReport);
	
	ReportLayoutBeginTableRow (pReport);	
	ReportLayoutAddTableCell (pReport, "94326", 50, ALIGN_LEFT, "Times New Roman",  10, false, false, false);
	ReportLayoutAddTableCell (pReport, "94326", 50, ALIGN_LEFT, "Times New Roman",  10, false, false, false);
	ReportLayoutEndTableRow (pReport);
	
	// Bill To and Ship To are now done
	ReportLayoutEndTable (pReport);

	// PO/term, etc
	// table is 100 pct of the page
	ReportLayoutBeginTable (pReport, 100, false);
	
	ReportLayoutBeginTableRow (pReport);	
	ReportLayoutAddTableCell (pReport, "PO", 20, ALIGN_LEFT, "Times New Roman",  10, true, false, true);
	ReportLayoutAddTableCell (pReport, "Term", 15, ALIGN_LEFT, "Times New Roman",  10, true, false, true);
	ReportLayoutAddTableCell (pReport, "Rep", 15, ALIGN_LEFT, "Times New Roman",  10, true, false, true);
	ReportLayoutAddTableCell (pReport, "Ship", 20, ALIGN_LEFT, "Times New Roman",  10, true, false, true);
	ReportLayoutAddTableCell (pReport, "Via", 15, ALIGN_LEFT, "Times New Roman",  10, true, false, true);
	ReportLayoutAddTableCell (pReport, "FOB", 15, ALIGN_LEFT, "Times New Roman",  10, true, false, true);
	ReportLayoutEndTableRow (pReport);
	
	ReportLayoutBeginTableRow (pReport);	
	ReportLayoutAddTableCell (pReport, "", 20, ALIGN_LEFT, "Times New Roman",  10, false, false, true);
	ReportLayoutAddTableCell (pReport, "", 15, ALIGN_LEFT, "Times New Roman",  10, false, false, true);
	ReportLayoutAddTableCell (pReport, "", 15, ALIGN_LEFT, "Times New Roman",  10, false, false, true);
	ReportLayoutAddTableCell (pReport, "", 20, ALIGN_LEFT, "Times New Roman",  10, false, false, true);
	ReportLayoutAddTableCell (pReport, "", 15, ALIGN_LEFT, "Times New Roman",  10, false, false, true);
	ReportLayoutAddTableCell (pReport, "", 15, ALIGN_LEFT, "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, "Qty", 10, ALIGN_RIGHT, "Times New Roman",  10, true, false, true);
	ReportLayoutAddTableCell (pReport, "Description", 50, ALIGN_LEFT, "Times New Roman",  10, true, false, true);
	ReportLayoutAddTableCell (pReport, "Price", 20, ALIGN_RIGHT, "Times New Roman",  10, true, false, true);
	ReportLayoutAddTableCell (pReport, "Amount", 20, ALIGN_RIGHT, "Times New Roman",  10, true, false, true);
	ReportLayoutEndTableRow (pReport);
	
	ReportLayoutBeginTableRow (pReport);	
	ReportLayoutAddTableCell (pReport, "1", 10, ALIGN_RIGHT, "Times New Roman",  10, false, false, true);
	ReportLayoutAddTableCell (pReport, "Cabinets", 50, ALIGN_LEFT, "Times New Roman",  10, false, false, true);
	ReportLayoutAddTableCell (pReport, "0.00", 20, ALIGN_RIGHT, "Times New Roman",  10, false, false, true);
	ReportLayoutAddTableCell (pReport, "0.00", 20, ALIGN_RIGHT, "Times New Roman",  10, false, false, true);
	ReportLayoutEndTableRow (pReport);
	
	ReportLayoutBeginTableRow (pReport);	
	ReportLayoutAddTableCell (pReport, "1", 10, ALIGN_RIGHT, "Times New Roman",  10, false, false, true);
	ReportLayoutAddTableCell (pReport, "standard interior door frame", 50, ALIGN_LEFT, "Times New Roman",  10, false, false, true);
	ReportLayoutAddTableCell (pReport, "0.00", 20, ALIGN_RIGHT, "Times New Roman",  10, false, false, true);
	ReportLayoutAddTableCell (pReport, "0.00", 20, ALIGN_RIGHT, "Times New Roman",  10, false, false, true);
	ReportLayoutEndTableRow (pReport);
	
	ReportLayoutBeginTableRow (pReport);	
	ReportLayoutAddTableCell (pReport, "1", 10, ALIGN_RIGHT, "Times New Roman",  10, false, false, true);
	ReportLayoutAddTableCell (pReport, "Exterior wood door", 50, ALIGN_LEFT, "Times New Roman",  10, false, false, true);
	ReportLayoutAddTableCell (pReport, "120.00", 20, ALIGN_RIGHT, "Times New Roman",  10, false, false, true);
	ReportLayoutAddTableCell (pReport, "120.00", 20, ALIGN_RIGHT, "Times New Roman",  10, false, false, true);
	ReportLayoutEndTableRow (pReport);
	
	// End Items table
	ReportLayoutEndTable (pReport);

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

	ReportLayoutBeginTableRow (pReport);	

	ReportLayoutAddTableCell (pReport, "", 60, ALIGN_LEFT, "Times New Roman",  10, false, false, true);
	ReportLayoutAddTableCell (pReport, "Sub Total", 20, ALIGN_LEFT, "Times New Roman",  10, false, false, true);
	ReportLayoutAddTableCell (pReport, "120.00", 20, ALIGN_RIGHT, "Times New Roman",  10, false, false, true);
	ReportLayoutEndTableRow (pReport);

	ReportLayoutBeginTableRow (pReport);	
	ReportLayoutAddTableCell (pReport, "", 60, ALIGN_LEFT, "Times New Roman",  10, false, false, false);
	ReportLayoutAddTableCell (pReport, "Tax", 20, ALIGN_LEFT, "Times New Roman",  10, false, false, true);
	ReportLayoutAddTableCell (pReport, "9.30", 20, ALIGN_RIGHT, "Times New Roman",  10, false, false, true);
	ReportLayoutEndTableRow (pReport);

	ReportLayoutBeginTableRow (pReport);	
	ReportLayoutAddTableCell (pReport, "", 60, ALIGN_LEFT, "Times New Roman",  10, true, false, false);
	ReportLayoutAddTableCell (pReport, "Total", 20, ALIGN_LEFT, "Times New Roman",  10, true, false, true);
	ReportLayoutAddTableCell (pReport, "129.30", 20, ALIGN_RIGHT, "Times New Roman",  10, true, false, true);
	ReportLayoutEndTableRow (pReport);

	ReportLayoutBeginTableRow (pReport);	
	ReportLayoutAddTableCell (pReport, "", 60, ALIGN_LEFT, "Times New Roman",  10, false, false, false);
	ReportLayoutAddTableCell (pReport, "Applied", 20, ALIGN_LEFT, "Times New Roman",  10, false, false, true);
	ReportLayoutAddTableCell (pReport, "0.00", 20, ALIGN_RIGHT, "Times New Roman",  10, false, false, true);
	ReportLayoutEndTableRow (pReport);

	ReportLayoutBeginTableRow (pReport);	

 	ReportLayoutAddTableCell (pReport, "", 60, ALIGN_LEFT, "Times New Roman",  10, false, false, false);
 	ReportLayoutAddTableCell (pReport, "Balance", 20, ALIGN_LEFT, "Times New Roman",  10, false, false, true);
 	ReportLayoutAddTableCell (pReport, "129.30", 20, ALIGN_RIGHT, "Times New Roman",  10, false, false, true);
 	ReportLayoutEndTableRow (pReport);

   	// Totals are now done
 	ReportLayoutEndTable (pReport);

	// end the report layout
	ReportLayoutEnd (pReport);

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

Copyright 2003 Bachmann Software & Services, LLC