Package org.apache.pdfbox.tools
Class TextToPDF
- java.lang.Object
-
- org.apache.pdfbox.tools.TextToPDF
-
public class TextToPDF extends java.lang.ObjectThis will take a text file and output a pdf with that text.- Author:
- Ben Litchfield
-
-
Constructor Summary
Constructors Constructor Description TextToPDF()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description org.apache.pdfbox.pdmodel.PDDocumentcreatePDFFromText(java.io.Reader text)Create a PDF document with some text.voidcreatePDFFromText(org.apache.pdfbox.pdmodel.PDDocument doc, java.io.Reader text)Create a PDF document with some text.floatgetBottomMargin()org.apache.pdfbox.pdmodel.font.PDFontgetFont()intgetFontSize()floatgetLeftMargin()floatgetLineSpacing()org.apache.pdfbox.pdmodel.common.PDRectanglegetMediaBox()Sets page size of produced PDF.floatgetRightMargin()floatgetTopMargin()booleanisLandscape()Tells the paper orientation.static voidmain(java.lang.String[] args)This will create a PDF document with some text in it.voidsetBottomMargin(float bottomMargin)voidsetFont(org.apache.pdfbox.pdmodel.font.PDFont aFont)voidsetFontSize(float aFontSize)voidsetFontSize(int aFontSize)Deprecated.voidsetLandscape(boolean landscape)Sets paper orientation.voidsetLeftMargin(float leftMargin)voidsetLineSpacing(float lineSpacing)voidsetMediaBox(org.apache.pdfbox.pdmodel.common.PDRectangle mediaBox)Sets page size of produced PDF.voidsetRightMargin(float rightMargin)voidsetTopMargin(float topMargin)
-
-
-
Method Detail
-
createPDFFromText
public org.apache.pdfbox.pdmodel.PDDocument createPDFFromText(java.io.Reader text) throws java.io.IOExceptionCreate 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(org.apache.pdfbox.pdmodel.PDDocument doc, java.io.Reader text) throws java.io.IOExceptionCreate 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.
-
main
public static void main(java.lang.String[] args) throws java.io.IOExceptionThis will create a PDF document with some text in it.
see usage() for commandline- Parameters:
args- Command line arguments.- Throws:
java.io.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, truncated to integer.
-
setFontSize
@Deprecated public void setFontSize(int aFontSize)
Deprecated.- Parameters:
aFontSize- The fontSize to set.
-
setFontSize
public void setFontSize(float aFontSize)
- Parameters:
aFontSize- The fontSize to set.
-
getLineSpacing
public float getLineSpacing()
- Returns:
- Returns the lineSpacing.
-
setLineSpacing
public void setLineSpacing(float lineSpacing)
- Parameters:
lineSpacing- The lineSpacing to set.
-
getLeftMargin
public float getLeftMargin()
- Returns:
- Returns the left margin.
-
setLeftMargin
public void setLeftMargin(float leftMargin)
- Parameters:
leftMargin- The left margin to be set.
-
getRightMargin
public float getRightMargin()
- Returns:
- Returns the right margin.
-
setRightMargin
public void setRightMargin(float rightMargin)
- Parameters:
rightMargin- The right margin to be set.
-
getTopMargin
public float getTopMargin()
- Returns:
- Returns the top margin.
-
setTopMargin
public void setTopMargin(float topMargin)
- Parameters:
topMargin- The top margin to be set.
-
getBottomMargin
public float getBottomMargin()
- Returns:
- Returns the bottom margin.
-
setBottomMargin
public void setBottomMargin(float bottomMargin)
- Parameters:
bottomMargin- The bottom margin to be 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
-
-