Class PDFPrintSupport


  • public final class PDFPrintSupport
    extends java.lang.Object
    Creates simple PDF documents. PDF support is not built in; to use this class the core-PDFOutput.selibrary library must be installed. (That library provides a concrete implementation of the PDFPrintSupport.PDFWriter interface defined in this class.) You can test whether PDF support is available by calling isAvailable().

    For easy PDF creation, use one of the static printToPDF methods that take a Printable or DeckEditor. Alternatively, call createPDFWriter() to obtain a high-level interface to the PDF engine.

    Since:
    3.0
    Author:
    Chris Jennings
    • Method Detail

      • isAvailable

        public static boolean isAvailable()
        Returns true if PDF support is available.
        Returns:
        true if createPDFWriter() will not throw an UnsupportedOperationException exception
      • printToPDF

        public static void printToPDF​(java.lang.String title,
                                      java.awt.print.PageFormat pageFormat,
                                      java.awt.print.Printable printable,
                                      java.io.File pdfFile)
        Prints the contents of any Printable object to a PDF file.
        Parameters:
        title - the title of the PDF file
        pageFormat - the page format to use
        printable - the content to print
        pdfFile - the PDF file to create
      • printToPDF

        public static void printToPDF​(java.lang.String title,
                                      PaperProperties paper,
                                      java.awt.print.Printable printable,
                                      java.io.File pdfFile)
        Prints the contents of any Printable object to a PDF file.
        Parameters:
        title - the title of the PDF file
        paper - the paper type to use
        printable - the content to print
        pdfFile - the PDF file to create
      • printToPDF

        public static void printToPDF​(DeckEditor deckEditor,
                                      java.io.File pdfFile)
        Prints a the contents of a deck to a PDF file.
        Parameters:
        deckEditor - the editor displaying the deck to print
        pdfFile - the PDF file to write
        Throws:
        java.lang.UnsupportedOperationException - if PDF support is not available
        See Also:
        isAvailable()
      • createPDFWriter

        public static PDFPrintSupport.PDFWriter createPDFWriter()
        Returns a new instance of a PDFPrintSupport.PDFWriter.
        Returns:
        a new, uninitialized PDF writer instance
        Throws:
        java.lang.UnsupportedOperationException - if no PDF support is available
      • getDefaultOutputQuality

        public static float getDefaultOutputQuality()
        Returns the default output quality level for new PDFPrintSupport.Configurations.
        Returns:
        the default quality setting
      • setDefaultOutputQuality

        public static void setDefaultOutputQuality​(float quality)
        Sets the default output quality level. This is a value between 0 and 1 inclusive, where higher values suggest higher quality output, generally at the cost of larger file size. This is the default quality level for new PDFPrintSupport.Configurations.
        Parameters:
        quality - the new quality setting
        Throws:
        java.lang.IllegalArgumentException - if the quality is not in the range 0 to 1.
        See Also:
        PDFPrintSupport.Configuration.setQuality(float)
      • setImplementationClassName

        public static void setImplementationClassName​(java.lang.String className)
        Sets the name of the concrete PDFPrintSupport.PDFWriter class to use.
        Parameters:
        className - the fully qualified name of a class with a no-arg constructor that implements PDFPrintSupport.PDFWriter, or null to use the default class
      • getImplementationClassName

        public static java.lang.String getImplementationClassName()
        Returns the name of the concrete PDFPrintSupport.PDFWriter class to use.
        Returns:
        the fully qualified name of a class use to create new PDFPrintSupport.PDFWriters