Class PrintUserParams

java.lang.Object
com.datalogics.PDFL.PrintUserParams

public class PrintUserParams extends Object
A structure used to set parameters for print jobs. Two structures provide settings for setting parameters for print jobs, PrintUserParams and PrintParams. PrintUserParams was created first, and then PrintParams was created as an extension of PrintUserParams, to provide more settings to account for changing technology.

When the system seeks to print a document it will pass the content and the print parameters, such as the page size, paper tray, and landscape v. portrait, to the print API in APDFL. If the setting is in PrintParams it will pass the document and parameters to PrintParams and then to PrintUserParams and from there to the print API to complete the printing process.

The print logic may take different code paths depending on whether or not the print content is being sent to a printer or to a file, or if the printing uses PostScript or not. When you see a print setting that appears in both PrintUserParams and PrintParams, such as "ShrinktoFit," set the appropriate value in both of these classes. Also, PrintParams offers a variety of settings related to PostScript, but the use of PrintParams is not limited to PostScript.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    When paper height and width are initialized to this value the crop box of each individual page will be used to determine the paper size.
    static final int
    When paper height and width are initialized to this value the printed product more closely resembles what comes out of most PDF Viewers.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    choosePaperSourceBySize(double width, double height)
    Choose the best paper source for a given width and height.
    void
     
    Enumerates available tray/bin names for the specified printer.
    int
    Gets whether to enable Binary data, 1 turns it on and 0 turns it off.
    boolean
    Collate property.
    Gets the Optional command line arguments on Unix.
    The unicode name of the device to print to (for example, "Distiller Assistant v3.01").
    int
    Gets the OverPrint Preview setting, 1 uses it, 0 does not.
    The unicode name of the driver (for example, "winspool").
    int
    Gets the Emit half-tones setting, 1 turns it on, 0 turns it off.
    boolean
    Gets whether a Postscript file is created.
    boolean
    Gets whether to Output the PDF document to a Postscript Printer.
    int
    Gets the page on which to finish printing, using zero-based nubmering.
    Gets the Far East Font setting.
    Unicode name used for the Windows DOCINFO structure (lpszDocName) that points to a NULL-terminated string that specifying the name of the document.
    int
    Gets the number of copies to print.
    Unicode name used for the Windows DOCINFO structure (lpszOutput).
    int
    Gets the Height of paper in points.
    int
    Paper source property.
    int
    Gets the Width of paper in points.
    The unicode name of the port (for example, "Ne00").
    int
    Gets the printing annotations setting, 1 turns it on, 0 turns it off.
    Gets the Print Parameter settings.
    int
    Gets the Postscript level.
    int
    Gets whether to reverses print order, 1 reverses it and 0 does regular order.
    boolean
    Gets the Shrink to fit setting, true turns it on, false turns it off.
    int
    Gets the page to start printing with, using zero-based numbering.
    int
    Gets the Spooler ID from StartDoc.
    int
    Gets the Transparency flattening quality control.
    boolean
    Gets whether to force the use of the paper size provided in the PaperWidth and PaperHeight parameters and not search for best fit size provided by printer.
    int
    Obtain tray/bin number by its name.
    boolean
    Set the print parameters by posing a dialog box to the user.
    void
    setBinaryOK(int binaryOK)
    Sets whether to enable Binary datam, 1 turns it on and 0 turns it off.
    void
    setCollate(boolean collate)
    Collate property.
    void
    setCommand(String command)
    Sets the Optional command line arguments on Unix.
    void
     
    void
    setDoOPP(int doOPP)
    Sets the OverPrint Preview setting, 1 uses it, 0 does not.
    void
     
    void
    setEmitHalftones(int emitHalftones)
    Sets the Emit half-tones setting, 1 turns it on, 0 turns it off.
    void
    setEmitToFile(boolean emitToFile)
    Sets whether a Postscript file is created.
    void
    setEmitToPrinter(boolean emitToPrinter)
    Sets whether to Output the PDF document to a Postscript Printer.
    void
    setEndPage(int endPage)
    Sets the page on which to finish printing, using zero-based nubmering.
    void
    Sets the Far East Font setting.
    void
     
    void
    setNCopies(int nCopies)
    Sets the number of copies to print.
    void
     
    void
    setPaperHeight(int paperHeight)
    Sets the Height of paper in points.
    void
    setPaperSource(int PaperSource)
    Paper source property.
    void
    setPaperWidth(int paperWidth)
    Sets the Width of paper in points.
    void
     
    void
    setPrintAnnots(int printAnnots)
    Sets the printing annotations setting, 1 turns it on, 0 turns it off.
    void
    setPsLevel(int psLevel)
    Sets the Postscript level.
    void
    setReverse(int reverse)
    Sets whether to reverses print order, 1 reverses it and 0 does regular order.
    void
    setShrinkToFit(boolean shrinkToFit)
    Sets the Shrink to fit setting, true turns it on, false turns it off.
    void
    setStartPage(int startPage)
    Sets the page to start printing with, using zero-based numbering.
    void
    setStartResult(int startResult)
    Sets the Spooler ID for StartDoc.
    void
    setTransQuality(int transQuality)
    Sets the Transparency flattening quality control.
    void
    setUseCustomPaperSize(boolean useCustomPaperSize)
    Sets whether to force the use of the paper size provided in the PaperWidth and PaperHeight parameters and not search for best fit size provided by printer.
    void
    Set the print parameters to the defaults.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • USE_MEDIA_BOX

      public static final int USE_MEDIA_BOX
      When paper height and width are initialized to this value the printed product more closely resembles what comes out of most PDF Viewers. This can eliminate some print problems, including PCL blank page problems.
      See Also:
    • USE_CROP_BOX

      public static final int USE_CROP_BOX
      When paper height and width are initialized to this value the crop box of each individual page will be used to determine the paper size.
      See Also:
  • Constructor Details

    • PrintUserParams

      public PrintUserParams()
  • Method Details

    • delete

      public void delete()
    • posePrintDialog

      public boolean posePrintDialog(Document doc)
      Set the print parameters by posing a dialog box to the user. The parameters set include the printer, page range, paper size, number of copies, and duplexing mode.

      Changes to these parameters made by the user will be copied into the corresponding PrintUserParams fields. If you want to override the user's choices, change these fields after calling PosePrintDialog().

      Parameters:
      doc - a Document which will be used to set the maximum page range in the dialog box.
      Returns:
      true if the user accepted the dialog box, false if it was cancelled
    • useDefaultPrinter

      public void useDefaultPrinter(Document doc)
      Set the print parameters to the defaults. The parameters set include the printer, page range, paper size, number of copies, and duplexing mode.

      Operating system defaults for these parameters will be copied into the corresponding PrintUserParams fields. If you want to override the system defaults, change these fields after calling UseDefaultPrinter().

      Parameters:
      doc - a Document which will be used to set the maximum page range.
    • getPrintParams

      public PrintParams getPrintParams()
      Gets the Print Parameter settings.
      Returns:
      the print parameter settings
    • choosePaperSourceBySize

      public void choosePaperSourceBySize(double width, double height)
      Choose the best paper source for a given width and height.

      Searches the printer's paper list for the smallest paper size that is greater than or equal to the given width and height, including with rotation, and sets up the job to print with that paper size.

      To obtain width and height, specify the Right - Left and Top - Bottom of the MediaBox of a representative Page.

      The printerName and portName must be set.

      If you use this call in conjunction with PosePrintDialog, UseDefaultPrinter, or UpdateFromPrinterSettings, call this function after those functions.

      Setting RotateAndCenter to True is recommended with this function.

      Parameters:
      width - the desired width of the output in user units
      height - the desired height of the output in user units
    • getInFileName

      public String getInFileName()
      Unicode name used for the Windows DOCINFO structure (lpszDocName) that points to a NULL-terminated string that specifying the name of the document. In case of printing/exporting to Postscript, this field sets the Title DSC comment in the generated Postscript file. If inFileName was not provided, the Title DSC comment is filled with the name of pdf document.
    • setInFileName

      public void setInFileName(String inStr)
    • getOutFileName

      public String getOutFileName()
      Unicode name used for the Windows DOCINFO structure (lpszOutput). It points to a NULL-terminated string that specifies the name of an output file. If this pointer is NULL, the output will be sent to the device identified by deviceName, driverName, and portName. It applies to a printer.
    • setOutFileName

      public void setOutFileName(String inStr)
    • getDeviceName

      public String getDeviceName()
      The unicode name of the device to print to (for example, "Distiller Assistant v3.01"). Available devices can be found in the Windows Registry at HKEY_CURRENT_USER\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Devices. It applies to a printer.
    • setDeviceName

      public void setDeviceName(String inStr)
    • getDriverName

      public String getDriverName()
      The unicode name of the driver (for example, "winspool"). See the registry key for deviceName. It applies to the printer.
    • setDriverName

      public void setDriverName(String inStr)
    • getPortName

      public String getPortName()
      The unicode name of the port (for example, "Ne00"). See the registry key for deviceName. It applies to the printer.
    • setPortName

      public void setPortName(String inStr)
    • getEmitToFile

      public boolean getEmitToFile()
      Gets whether a Postscript file is created.
      Returns:
      true if a PostScript file is created.
    • setEmitToFile

      public void setEmitToFile(boolean emitToFile)
      Sets whether a Postscript file is created. You set either this parameter or emitToPrinter, but not both.
      Parameters:
      emitToFile - pass true to emit output to a PostScript file
    • getEmitToPrinter

      public boolean getEmitToPrinter()
      Gets whether to Output the PDF document to a Postscript Printer.
      Returns:
      true if output to a printer.
    • setEmitToPrinter

      public void setEmitToPrinter(boolean emitToPrinter)
      Sets whether to Output the PDF document to a Postscript Printer. Set either this parameter or emitToFile, but not both.
      Parameters:
      emitToPrinter - pass true to emit to the printer
    • getPaperWidth

      public int getPaperWidth()
      Gets the Width of paper in points. The default value is 612. It applies to a Postscript printer.
      Returns:
      the width of the paper in points
    • setPaperWidth

      public void setPaperWidth(int paperWidth)
      Sets the Width of paper in points. The default value is 612. It applies to a Postscript printer.
      Parameters:
      paperWidth - the width of the paper in points
    • getPaperHeight

      public int getPaperHeight()
      Gets the Height of paper in points. The default value is 792. It applies to a Postscript printer.
      Returns:
      the height of the paper in points
    • setPaperHeight

      public void setPaperHeight(int paperHeight)
      Sets the Height of paper in points. The default value is 792. It applies to a Postscript printer.
      Parameters:
      paperHeight - the height of the paper in points
    • getCommand

      public String getCommand()
      Gets the Optional command line arguments on Unix. It is used only if emitToPrinter is true. For example, "lp" or "lpr" applies to a Postscript printer. This API is available on Unix only.
      Returns:
      command line arguments
    • setCommand

      public void setCommand(String command)
      Sets the Optional command line arguments on Unix. It is used only if emitToPrinter is true. For example, "lp" or "lpr" applies to a Postscript printer. This API is available on Unix only.
      Parameters:
      command - the optional command line arguments
    • getStartResult

      public int getStartResult()
      Gets the Spooler ID from StartDoc. This API is available on Windows and Unix only.
      Returns:
      the Spooler ID
    • setStartResult

      public void setStartResult(int startResult)
      Sets the Spooler ID for StartDoc. This API is available on Windows and Unix only.
      Parameters:
      startResult - the Spooler ID
    • getNCopies

      public int getNCopies()
      Gets the number of copies to print. It applies to a Postscript file.
      Returns:
      the number of copies that will be printed
    • setNCopies

      public void setNCopies(int nCopies)
      Sets the number of copies to print. It applies to a Postscript file.
      Parameters:
      nCopies - the number of copies to print.
    • getStartPage

      public int getStartPage()
      Gets the page to start printing with, using zero-based numbering. It applies to a printer. This API is only available on Windows and macOS only.
      Returns:
      the start page
    • setStartPage

      public void setStartPage(int startPage)
      Sets the page to start printing with, using zero-based numbering. It applies to a printer. This API is only available on Windows and macOS only.
      Parameters:
      startPage - the page to start on
    • getEndPage

      public int getEndPage()
      Gets the page on which to finish printing, using zero-based nubmering. It applies to a printer. This API is only available on Windows and macOS only.
      Returns:
      the page to end upon
    • setEndPage

      public void setEndPage(int endPage)
      Sets the page on which to finish printing, using zero-based nubmering. It applies to a printer. This API is only available on Windows and macOS only.
      Parameters:
      endPage - the page to end upon
    • getShrinkToFit

      public boolean getShrinkToFit()
      Gets the Shrink to fit setting, true turns it on, false turns it off. It applies to a Postscript printer. This API is available on Windows and macOS only.
      Returns:
      true if the page will be shrunk to fit
    • setShrinkToFit

      public void setShrinkToFit(boolean shrinkToFit)
      Sets the Shrink to fit setting, true turns it on, false turns it off. It applies to a PostScript printer. This API is available on Windows and macOS only.
      Parameters:
      shrinkToFit - pass true to shrink the page to fit
    • getPrintAnnots

      public int getPrintAnnots()
      Gets the printing annotations setting, 1 turns it on, 0 turns it off. It applies to a printer. This API is available on Windows and macOS only.
      Returns:
      1 if annotations will be printed, 0 if not
    • setPrintAnnots

      public void setPrintAnnots(int printAnnots)
      Sets the printing annotations setting, 1 turns it on, 0 turns it off. It applies to a printer. This API is available on Windows and macOS only.
      Parameters:
      printAnnots - 1 to print annotations, 0 to not print them.
    • getPsLevel

      public int getPsLevel()
      Gets the Postscript level. It applies to a Postscript printer. This API is available on Windows and macOS only.
      Returns:
      Postscript level setting
    • setPsLevel

      public void setPsLevel(int psLevel)
      Sets the Postscript level. It applies to a Postscript printer. This API is available on Windows and macOS only.
      Parameters:
      psLevel - Postscript Level setting.
    • getBinaryOK

      public int getBinaryOK()
      Gets whether to enable Binary data, 1 turns it on and 0 turns it off. It applies to a Postscript printer. This API is available on Windows and macOS only.
      Returns:
      Binary ok setting.
    • setBinaryOK

      public void setBinaryOK(int binaryOK)
      Sets whether to enable Binary datam, 1 turns it on and 0 turns it off. It applies to a Postscript printer. This API is available on Windows and macOS only.
      Parameters:
      binaryOK - Binary Ok setting.
    • getEmitHalftones

      public int getEmitHalftones()
      Gets the Emit half-tones setting, 1 turns it on, 0 turns it off. It applies to a Postscript printer. This API is available on Windows and macOS only.
      Returns:
      1 if halftones will be emitted, 0 if not
    • setEmitHalftones

      public void setEmitHalftones(int emitHalftones)
      Sets the Emit half-tones setting, 1 turns it on, 0 turns it off. It applies to a Postscript printer. This API is available on Windows and macOS only.
      Parameters:
      emitHalftones - 1 if halftones will be emitted, 0 if not
    • getReverse

      public int getReverse()
      Gets whether to reverses print order, 1 reverses it and 0 does regular order. It applies to a printer. This API is available on Windows and macOS only.
      Returns:
      1 to reverse page order or 0 for regular order
    • setReverse

      public void setReverse(int reverse)
      Sets whether to reverses print order, 1 reverses it and 0 does regular order. It applies to a printer. This API is available on Windows and macOS only.
      Parameters:
      reverse - 1 to reverse page order or 0 for regular order
    • getDoOPP

      public int getDoOPP()
      Gets the OverPrint Preview setting, 1 uses it, 0 does not. It applies to a printer. The default is 0. This API is available on Windows and macOS only.
      Returns:
      1 if OverPrint Preview will be used, 0 if not
    • setDoOPP

      public void setDoOPP(int doOPP)
      Sets the OverPrint Preview setting, 1 uses it, 0 does not. The default is 0. It applies to a printer. This API is available on Windows and macOS only.
      Parameters:
      doOPP - 1 if OverPrint Preview will be used, 0 if not
    • getFarEastFontOpt

      public FarEastFont getFarEastFontOpt()
      Gets the Far East Font setting. The default value is DownloadAll. PrintAsImage will not be honored. It applies to a Postscript printer. This API is available on Windows only.
      Returns:
      a PDFarEastFont value that represents the setting to be used
    • setFarEastFontOpt

      public void setFarEastFontOpt(FarEastFont farEastFontOpt)
      Sets the Far East Font setting. The default value is DownloadAll. PrintAsImage will not be honored. It applies to a Postscript printer. This API is available on Windows only.
      Parameters:
      farEastFontOpt - a PDFarEastFont value that represents the setting to be used
    • getTransQuality

      public int getTransQuality()
      Gets the Transparency flattening quality control. 1 is fastest; 5 is best. The default is 3. It applies to a printer. This API is available on Windows only.
      Returns:
      the transparency flatting quality, 1 is fastest; 5 is best
    • setTransQuality

      public void setTransQuality(int transQuality)
      Sets the Transparency flattening quality control. 1 is fastest; 5 is best. The default is 3. It applies to a printer. This API is available on Windows only.
      Parameters:
      transQuality - the transparency flatting quality, 1 is fastest; 5 is best
    • setCollate

      public void setCollate(boolean collate)
      Collate property.
      Parameters:
      collate - True if need to collate copies.
    • getCollate

      public boolean getCollate()
      Collate property.
      Returns:
      True if copies should be collated.
    • setPaperSource

      public void setPaperSource(int PaperSource)
      Paper source property.
      Parameters:
      PaperSource - paper source which must be selected.
    • getPaperSource

      public int getPaperSource()
      Paper source property.
      Returns:
      Value in DEVMODE->dmDefaultSource if initialized or index of selected paper tray or -1 if not specified.
    • setUseCustomPaperSize

      public void setUseCustomPaperSize(boolean useCustomPaperSize)
      Sets whether to force the use of the paper size provided in the PaperWidth and PaperHeight parameters and not search for best fit size provided by printer. SetPageSize must also be set.
      Parameters:
      useCustomPaperSize - pass true to use custom size.
    • getUseCustomPaperSize

      public boolean getUseCustomPaperSize()
      Gets whether to force the use of the paper size provided in the PaperWidth and PaperHeight parameters and not search for best fit size provided by printer. SetPageSize must also be set.
      Returns:
      true if force.
    • enumeratePaperSources

      public List<String> enumeratePaperSources()
      Enumerates available tray/bin names for the specified printer.
      Returns:
      Set of the tray/bin names.
    • paperSourceIdByName

      public int paperSourceIdByName(String trayName)
      Obtain tray/bin number by its name.
      Parameters:
      trayName - the tray/bin's name whose number need to obtain.
      Returns:
      Tray/Bin number corresponding to the specified name.