Package org.apache.pdfbox.tools
Class TextToPDF
java.lang.Object
org.apache.pdfbox.tools.TextToPDF
This will take a text file and output a pdf with that text.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Charsetprivate static final intThe default font sizeprivate PDFontprivate static final intThe scaling factor for font units to PDF unitsprivate intprivate Fileprivate booleanprivate static final floatThe line height as a factor of the font sizeprivate PDRectangleprivate Fileprivate TextToPDF.PageSizesprivate Standard14Fonts.FontNameprivate final PrintStreamprivate File -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncall()createPDFFromText(Reader text) Create a PDF document with some text.voidcreatePDFFromText(PDDocument doc, Reader text) Create a PDF document with some text.getFont()intSets page size of produced PDF.booleanTells the paper orientation.static voidThis will create a PDF document with some text in it.voidvoidsetFontSize(int aFontSize) voidsetLandscape(boolean landscape) Sets paper orientation.voidsetMediaBox(PDRectangle mediaBox) Sets page size of produced PDF.
-
Field Details
-
FONTSCALE
private static final int FONTSCALEThe scaling factor for font units to PDF units- See Also:
-
DEFAULT_FONT_SIZE
private static final int DEFAULT_FONT_SIZEThe default font size- See Also:
-
LINE_HEIGHT_FACTOR
private static final float LINE_HEIGHT_FACTORThe line height as a factor of the font size- See Also:
-
mediaBox
-
font
-
SYSERR
-
fontSize
private int fontSize -
landscape
private boolean landscape -
pageSize
-
charset
-
standardFont
-
ttf
-
infile
-
outfile
-
-
Constructor Details
-
TextToPDF
public TextToPDF()Constructor.
-
-
Method Details
-
main
This will create a PDF document with some text in it.
see usage() for commandline- Parameters:
args- Command line arguments.
-
call
-
createPDFFromText
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
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.
-
getFont
- Returns:
- Returns the font.
-
setFont
- 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
Sets page size of produced PDF.- Returns:
- returns the page size (media box)
-
setMediaBox
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
-