printtopdf
PATH
,
OPTION
,
VALUE

The printtopdf statement prints the current database to a PDF file.


Parameters

This statement has three parameters:

path – path and filename of the desired PDF file. If only a filename is supplied, the file will be placed in the same folder as the database. If no filename is supplied, the PDF file will be given the same name as the database, but with an extension of .pdf.

option – The name of an option that modifies the printing operation. See below for descriptions of each available option. The option can be specified in either upper or lower case.

value – The option value.


Description

This statement prints the current database directly to a PDF file. (Alternately, it can also immediately print to any printer connected to the computer, see the Printers option below.) In its simplest form, all that is needed is the name of the file.

printtopdf "invoices.pdf"

In fact, you can even leave off the name of the PDF file, in which case Panorama will automatically create a PDF file with the name of the database followed by the PDF extension.

printtopdf ""

PDF Options

The operation of this statement can be customized by adding one or more pairs of option/value parameters to the printtopdf statement, like this:

printtopdf path,option1,value1,option2,value2,option3,value3,option4,value4

Each of the available options is described below.

OneRecord

The printtopdf statement normally prints all selected records to the PDF file, but if the onerecord option is true, only the current record is printed.

printtopdf "Invoice"+InvoiceNumber+".pdf","onerecord","true"

Note: You can use "currentrecord" instead of "onerecord".

Form

The printtopdf statement normally prints the current window (data sheet, form or procedure window). This option allows a different form to be printed, instead of the currently active form. The specified form does not have be open. This example will print using the Invoice Template form even if some other form window is currently the active window.

printtopdf "Invoices.pdf","Form","Invoice Template"

Note: This option will only work if the current window is a form window. If the current window is a data sheet or procedure window, that window will be printed even if an alternate form has been specified.

Note: You can use "using" or "usingform" instead of "form".

Database

This option is designed to be used with the Form option described above. It allows the form used for printing to be a form in a different database (however, the specified database must be open). This usually only makes sense if the two databases have the same fields.

printtopdf "Labels.pdf","Database","Label Templates","Form","Avery 5252"

Note: You can use "usingdatabase" instead of "database".

Printer

If this option is included, the printtopdf statement will immediately print instead of generating a PDF file (the path option is ignored, and can be left blank). If the printer is blank, the current default printer will be used.

printtopdf "","Printer","","Database","Label Templates","Form","Avery 5252"

Or, you can specify the printer to be used:

printtopdf "","Printer","Canon MP620 series","Form","Avery 5252"

Use the info(“printers”) function to find out what printers are available.

Copies

This option can only be used if the Printer option is being used for immediate printing. It specifies the number of copies to be printed (the default is 1). This example prints three copies of an invoice.

printtopdf "","Printer","","Form","Invoice","onerecord","true","Copies",3

If a PDF file is being generated, the Copies option is ignored.

Progress

The printtopdf statement normally displays a small pop-up alert that shows the progress of the PDF being generated. The progress option disables this pop-up alert.

printtopdf "Labels.pdf","progress","false"
First and Last Page

The printtopdf statement normally prints all selected records to the PDF file, but it can be restricted to only a limited set of pages. Here are some examples.

printtopdf "Report.pdf","last",1 // prints only the first page
printtopdf "Report.pdf","first",2 // skips the first page
printtopdf "Report.pdf","first",2,"last",2 // prints only the second page

Unfortunately, there isn’t any way to know in advance how many pages there are in the document, so there is no reliable way to print only the last page, or to skip only the last page.

Reverse Page Order

Use the Reverse option if you want to print the pages back to front.

printopdf "Checks.pdf","reverse","true"
Orientation (Portrait/Landscape)

The PDF is normally generated in portrait orientation, but it can be switched to landscape.

printtopdf "Report.pdf","orientation","landscape"
Paper Size

Use the Height and Width options to specify a custom paper size. This report will be printed on US Legal paper. You must specify both the height and width, or the custom size will be ignored.

printtopdf "Report.pdf","Height",14,"Width",8.5

The dimensions are normally specified in inches, but if the values are larger than 72, they are interpreted as points (72 points per inch).

Scale Factor

The Scale option modifies the scale factor. A factor of 1.0 generates the PDF at 100%, smaller numbers reduce the size while larger numbers increase it. This example prints the database at 1/2 normal size (50%).

printopdf "Report.pdf","scale",0.5

See Also


History

VersionStatusNotes
10.0NewNew in this version.