Class TextToPDF

  • All Implemented Interfaces:
    java.util.concurrent.Callable<java.lang.Integer>

    public class TextToPDF
    extends java.lang.Object
    implements java.util.concurrent.Callable<java.lang.Integer>
    This will take a text file and output a pdf with that text.
    • Field Detail

      • FONTSCALE

        private static final int FONTSCALE
        The scaling factor for font units to PDF units
        See Also:
        Constant Field Values
      • DEFAULT_FONT_SIZE

        private static final int DEFAULT_FONT_SIZE
        The default font size
        See Also:
        Constant Field Values
      • LINE_HEIGHT_FACTOR

        private static final float LINE_HEIGHT_FACTOR
        The line height as a factor of the font size
        See Also:
        Constant Field Values
      • SYSERR

        private final java.io.PrintStream SYSERR
      • fontSize

        private int fontSize
      • landscape

        private boolean landscape
      • charset

        private java.nio.charset.Charset charset
      • ttf

        private java.io.File ttf
      • infile

        private java.io.File infile
      • outfile

        private java.io.File outfile
    • Constructor Detail

      • TextToPDF

        public TextToPDF()
        Constructor.
    • Method Detail

      • main

        public static void main​(java.lang.String[] args)
        This will create a PDF document with some text in it.
        see usage() for commandline
        Parameters:
        args - Command line arguments.
      • call

        public java.lang.Integer call()
        Specified by:
        call in interface java.util.concurrent.Callable<java.lang.Integer>
      • createPDFFromText

        public PDDocument createPDFFromText​(java.io.Reader text)
                                     throws java.io.IOException
        Create a PDF document with some text.
        Parameters:
        text - The stream of text data.
        Returns:
        The document with the text in it.
        Throws:
        java.io.IOException - If there is an error writing the data.
      • createPDFFromText

        public void createPDFFromText​(PDDocument doc,
                                      java.io.Reader text)
                               throws java.io.IOException
        Create a PDF document with some text.
        Parameters:
        doc - The document.
        text - The stream of text data.
        Throws:
        java.io.IOException - If there is an error writing the data.
      • getFont

        public PDFont getFont()
        Returns:
        Returns the font.
      • setFont

        public void setFont​(PDFont aFont)
        Parameters:
        aFont - The font to set.
      • getFontSize

        public int getFontSize()
        Returns:
        Returns the fontSize.
      • setFontSize

        public void setFontSize​(int aFontSize)
        Parameters:
        aFontSize - The fontSize to set.
      • getMediaBox

        public PDRectangle getMediaBox()
        Sets page size of produced PDF.
        Returns:
        returns the page size (media box)
      • setMediaBox

        public void setMediaBox​(PDRectangle mediaBox)
        Sets page size of produced PDF.
        Parameters:
        mediaBox -
      • isLandscape

        public boolean isLandscape()
        Tells the paper orientation.
        Returns:
        true for landscape orientation
      • setLandscape

        public void setLandscape​(boolean landscape)
        Sets paper orientation.
        Parameters:
        landscape - true for landscape orientation