Output to a File
Choose either of these two methods to select PDF output and its destination. The following fragments assume an initialized job or native instance. Replace the sample path with a path in an existing directory.
Option 1: Set the output type and filename separately
Select the format with PrinterType and supply the filename or path with OutputName. No printer name is required.
' Select PDF output to /temp/out.pdf with PrinterType and OutputName '
printJob.PrinterType = PrinterType_PdfFile
printJob.OutputName = "/temp/out.pdf"
Option 2: Set both using a prefix
Pass a prefix and filename together to PrinterName. This selects the same PDF output and destination.
' Select PDF output to /temp/out.pdf with the PDFFILE prefix '
printJob.PrinterName = "PDFFILE:/Temp/out.pdf"
For either method:
Include the desired extension. The extension alone does not select the format, and an explicit PDF filename such as
resultremainsresultwithout an added extension.Use a full path or a relative path. Relative paths use the application's working directory, not the layout directory.
Create the destination directory before generating output.
Combining Output Settings
Prefer one selection method for a straightforward request. Combining them is supported, with these rules:
The Job applies the separate output type and output name before the printer name when generating output, regardless of the order in which you set them. A file-output prefix such as PDF: in PrinterName therefore takes precedence over a separately supplied output type and filename.
A printer-output prefix such as ZPLPRINTER: selects the output type and printer, but leaves the separately supplied print-job title unchanged.
Automatic File Names
These rules apply to filenames supplied through OutputName or a file-output prefix.
Directory only
Supply a directory with a trailing separator, such asexport/. The SDK uses the document name to complete the filename.Filename with
*
Include*in the base name, such asprefix-*.pdf. The SDK uses the document name for the variable part.Empty output name
An empty output name is not a file destination.
Document name selection
For the directory-only and * forms, the SDK uses the first available value in this order:
The nonempty system data field
tfDocumentName.The layout's Document Name expression.
The layout name.
For PDF output and a document name of ProductLabel:
Filename or path | Result |
|---|---|
|
|
|
|
|
|
One File per Page
This section applies to single-page image formats and SVG/SVGZ, not to a single PDF or multipage TIFF file. Several output pages produce several files. With a fixed name such as page.png, the first file keeps that name; following files are page_002.png, page_003.png, and so on.
To include a number in every filename, use consecutive # characters: page-###.png produces page-001.png, page-002.png, and so on. These are output-page numbers, not necessarily record numbers.
Data-Dependent File Names
For image and SVG outputs with one file per output page, enable eval-file-name-per-page to use data-dependent filenames. With this option enabled, the layout's Document Name expression is evaluated for each output page. A nonempty result replaces the fixed filename, even if an explicit output name was supplied. Relative results use the output name's directory; absolute results select their own path. An empty result uses the ordinary filename pattern.
Warning
Only immediately repeated names are automatically numbered. If an expression returns A, then B, then A again, the last A file replaces the first. Use unique names or include a page-number pattern such as ArticleNumber + "-###" in the expression when all pages must be retained.
See Print Options for the option and its supported output types.
For other file formats and prefixes, see Output Format Prefix Reference.
Windows Printer Driver Output
On Windows, you can also save a printer driver's output to a file using the print-to-file option. See Print to a File through a Windows Printer Driver for details.