|
|
Chris Hardekopf Software Engineer |
|
he BBj Form Printing article in the last issue of the BASIS International Advantage discussed how the BBjForm API allows a
BBj® programmer to use object syntax to build printer forms such as invoices or data entry forms. With new enhancements, the
BBjForm API that builds these printer forms now can create PDF (Portable Document Format) forms directly from BBj. In contrast
|
PDF is an industry standard file format developed by Adobe Systems Incorporated for the portable
representation of documents. Free PDF readers for many different platforms are available for download on
the Internet.
|
|
to formats such as HTML, PDF encodes both the contents and exact look of a document in a device and operating
system-independent manner. BBj now merges these two technologies, giving BBj programmers a new and very useful tool for their
repertoire.
The standard use of the BBjForm API involves getting a BBjPrinter object from BBjAPI and then creating a BBjForm for that
printer. However, a PDF file clearly does not have an associated printer, as it is simply a file residing on a disk.
Therefore, the programmer gets a BBjForm object for a PDF file directly from BBjAPI using the getBBjPDFForm method. The programmer must provide a file name for the PDF file and can
optionally specify several parameters to control the PDF output using javax.print.attribute.PrintRequestAttributeSet. Below is
a list of the possible parameters for the attributes set.
|
Parameter |
|
|
Controlled by an Instance of |
|
Page Size |
|
|
javax.print.attribute.standard.MediaName or |
|
|
|
|
javax.print.attribute.standard.MediaSizeName |
|
|
|
|
|
|
Margins |
|
|
javax.print.attribute.standard.MediaPrintableArea |
|
Orientation |
|
|
javax.print.attribute.standard.OrientationRequested |
|
Once developers create the new BBjForm, they can use it just like a standard BBjForm for a printer with a couple of
exceptions. First, the "preview" method does not allow a developer to preview the PDF form. Second, the "print" method does
not actually print the document to a printer, but instead flushes the document to disk as a PDF file. In addition, only FONT,
SIZE, UNDERLINE, and SUPERSCRIPT string attributes work in text fields.
|
|
Figure 1. TechCon2004 form demo |
A Real Purchase Requisition
To illustrate how this works, consider the familiar purchase requisition demo from BASIS TechCon2004. In this demo, BASIS
created purchase requisitions using BBjPrintForm capabilities. The actual program that ran that demo appears in Figure
1. Automating the creation of purchase requisitions with BASIS technology was a great first step, but we had bigger plans.
In BBj 6.0, a user can prepare this form and send it electronically to the appropriate person for approval, regardless of
where in the world the approver may be. In the form demo, only a few lines of code required modification to produce the new
end result a PDF file ready for print or electronic distribution. The code sample below uses the new getBBjPDFForm method.
REM Create the page object
myPDF$ = dir("") + "/PurchaseRequisition.pdf"
erase myPDF$,err=*NEXT
doc!=myAPI!.getBBjPDFForm(myPDF$,requiestAttributes!)
page!=doc!.createPage()
|
The applications for using a PDF file are endless and will positively impact the way today's transactions occur in the
workplace. Figure 2 shows how this purchase requistion form appears in the Adobe Reader.
|
|
Figure 2. PDF view of the purchase requisition |
SUMMARY
Providing recipients with a PDF form ensures they will view the electronic and/or printed version of that file exactly as
designed, regardless of the operating system. Also, the appearance of the invoice is always consistent. Having a means to
create consistent documents that appear just as the author intends opens the doors wide to the possibilities and ways to
improve day-to-day operations.
Read BBj Form Printing.
|
|