Class TextToPDF

java.lang.Object
org.apache.pdfbox.tools.TextToPDF

public class TextToPDF extends Object
This will take a text file and output a pdf with that text.
Author:
Ben Litchfield
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.apache.pdfbox.pdmodel.PDDocument
    Create a PDF document with some text.
    void
    createPDFFromText(org.apache.pdfbox.pdmodel.PDDocument doc, Reader text)
    Create a PDF document with some text.
    org.apache.pdfbox.pdmodel.font.PDFont
     
    int
     
    org.apache.pdfbox.pdmodel.common.PDRectangle
    Sets page size of produced PDF.
    boolean
    Tells the paper orientation.
    static void
    main(String[] args)
    This will create a PDF document with some text in it.
    void
    setFont(org.apache.pdfbox.pdmodel.font.PDFont aFont)
     
    void
    setFontSize(int aFontSize)
     
    void
    setLandscape(boolean landscape)
    Sets paper orientation.
    void
    setMediaBox(org.apache.pdfbox.pdmodel.common.PDRectangle mediaBox)
    Sets page size of produced PDF.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • TextToPDF

      public TextToPDF()
  • Method Details

    • createPDFFromText

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

      public void createPDFFromText(org.apache.pdfbox.pdmodel.PDDocument doc, Reader text) throws IOException
      Create a PDF document with some text.
      Parameters:
      doc - The document.
      text - The stream of text data.
      Throws:
      IOException - If there is an error writing the data.
    • main

      public static void main(String[] args) throws IOException
      This will create a PDF document with some text in it.
      see usage() for commandline
      Parameters:
      args - Command line arguments.
      Throws:
      IOException - If there is an error with the PDF.
    • getFont

      public org.apache.pdfbox.pdmodel.font.PDFont getFont()
      Returns:
      Returns the font.
    • setFont

      public void setFont(org.apache.pdfbox.pdmodel.font.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 org.apache.pdfbox.pdmodel.common.PDRectangle getMediaBox()
      Sets page size of produced PDF.
      Returns:
      returns the page size (media box)
    • setMediaBox

      public void setMediaBox(org.apache.pdfbox.pdmodel.common.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