Print function

Start page  Previous page  Next page

 

Direct printing of PDF documents

 

The interface to the toolbox service of webPDF makes it possible for you to print PDF documents directly with n2pdf.

 

This allows you to print previously existing PDF documents or to print a PDF document that is just being created. You may specify different settings, such as the name of the printer or the number of copies.

 

The following settings allow you to control the use of the print service from within n2pdf. All options are set via the function N2PDFSetOption. You can choose from the following function parameters:

 

112

webPDF is required to be able to use the print function.

 

 

N2PDFOPTION_TOOLBOX_PRINT_PRINTER_NAME (Default: "")

This parameter is used to declare the name of the printer that should be used to print the PDF document. If a printer is not declared, then the system's default printer will be used for printing.

 

Call N2PDFSetOption ( JobID,_

N2PDFOPTION_TOOLBOX_PRINT_PRINTER_NAME, "Microsoft XPS Document Writer", "" )

 

N2PDFOPTION_TOOLBOX_PRINT_PAGE_NUMBER (Default: all pages)

Defines which page(s) should be printed. The page number can be used to declare a single page, a range of pages, or a comma-separated list (e.g., "1,5-6,9"). To specify "all pages," use an asterisk ("*").

 

Call N2PDFSetOption ( JobID,_

N2PDFOPTION_TOOLBOX_PRINT_PAGE_NUMBER, "3,5", "" )

 

N2PDFOPTION_TOOLBOX_PRINT_JOB_NAME (Default: webPDF Print Job)

This parameter is used to define the name of the print job (as shown in the print spooler in Windows, for example).

 

Call N2PDFSetOption ( JobID,_

N2PDFOPTION_TOOLBOX_PRINT_JOB_NAME, “Monthly evaluation", "" )

 

N2PDFOPTION_TOOLBOX_PRINT_NUMBEROFCOPIES (Default: 1)

Defines the number of copies that should be printed.

 

Call N2PDFSetOption ( JobID,_

N2PDFOPTION_TOOLBOX_PRINT_NUMBEROFCOPIES, "3", "" )

 

N2PDFOPTION_TOOLBOX_PRINT_AUTO_ROTATE (Default: true)

If "true," the PDF document's orientation will be automatically adjusted in line with the printer's configured paper orientation.

 

N2PDFVALUE_TRUE

Adapt the contents to the current paper orientation of the printer

N2PDFVALUE_FALSE

Do not align the content

 

Call N2PDFSetOption ( JobID,_

N2PDFOPTION_TOOLBOX_PRINT_AUTO_ROTATE, N2PDFVALUE_True, "" )

 

N2PDFOPTION_TOOLBOX_PRINT_SHRINK_TO_MARG (Default: false)

If "true," any PDF page that is larger than the paper will be shrunk to fit the paper size.

 

N2PDFVALUE_TRUE

Adapt the content to the paper size

N2PDFVALUE_FALSE

Do not adapt the content

 

Call N2PDFSetOption ( JobID,_

N2PDFOPTION_TOOLBOX_PRINT_SHRINK_TO_MARG, N2PDFVALUE_True, "" )

 

N2PDFOPTION_TOOLBOX_PRINT_EXPAND_TO_MARG (Default: false)

If "true," any PDF page that is smaller than the paper will be enlarged to fit the paper size.

 

N2PDFVALUE_TRUE

Adapt the content to the paper size

N2PDFVALUE_FALSE

Do not adapt the content

 

Call N2PDFSetOption ( JobID,_

N2PDFOPTION_TOOLBOX_PRINT_EXPAND_TO_MARG, N2PDFVALUE_True, "" )

 

N2PDFOPTION_TOOLBOX_PRINT_CENTER_IN_PAGE (Default: true)

If "true," the PDF page will be centered in the middle of the paper.

 

N2PDFVALUE_TRUE

Align the content at the center of the paper

N2PDFVALUE_FALSE

Do not align the content

 

Call N2PDFSetOption ( JobID,_

N2PDFOPTION_TOOLBOX_PRINT_CENTER_IN_PAGE, N2PDFVALUE_True, "" )

 

 

Example of printing using n2pdf:

 

Printing a PDF created by n2pdf

' Do not release job after creation

Call N2PDFSetOption ( JobID, N2PDFOPTION_SYSTEM_RELEASE_JOB, N2PDFVALUE_FALSE, "" )

 

' Create the PDF

Call N2PDFProcess ( JobID, PDFFileName, 0 )

 

' Selection of the printer on which the content is to be printed out

Call N2PDFSetOption ( JobID, N2PDFOPTION_TOOLBOX_PRINT_PRINTER_NAME, "Microsoft XPS Document Writer", "" )

 

' Print created PDF

Call N2PDFPrint ( JobID, "" )

 

' Release the job ID

Call N2PDFTerm ( JobID )

 

 

Print any PDF desired

' Create a new job

JobID = N2PDFInit ( 0 )

 

' Selection of the printer on which the content is to be printed out

Call N2PDFSetOption ( JobID, N2PDFOPTION_TOOLBOX_PRINT_PRINTER_NAME, "Microsoft XPS Document Writer", "" )

 

' Print created PDF

Call N2PDFPrint ( JobID, "C:\test.pdf" )

 

' Close job

Call N2PDFTerm ( JobID )