public class TextToPDF
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static PDType1Font |
DEFAULT_FONT
The default font
|
private static int |
DEFAULT_FONT_SIZE
The default font size
|
private PDFont |
font |
private static int |
FONTSCALE
The scaling factor for font units to PDF units
|
private int |
fontSize |
private boolean |
landscape |
private static float |
LINE_HEIGHT_FACTOR
The line height as a factor of the font size
|
private PDRectangle |
mediaBox |
private static java.util.Map<java.lang.String,PDType1Font> |
STANDARD_14 |
Constructor and Description |
---|
TextToPDF() |
Modifier and Type | Method and Description |
---|---|
void |
createPDFFromText(PDDocument doc,
java.io.Reader text)
Create a PDF document with some text.
|
PDDocument |
createPDFFromText(java.io.Reader text)
Create a PDF document with some text.
|
private static PDRectangle |
createRectangle(java.lang.String paperSize) |
PDFont |
getFont() |
int |
getFontSize() |
PDRectangle |
getMediaBox()
Sets page size of produced PDF.
|
private static java.lang.String[] |
getStandard14Names()
This will get the names of the standard 14 fonts.
|
private static PDType1Font |
getStandardFont(java.lang.String name)
A convenience method to get one of the standard 14 font from name.
|
boolean |
isLandscape()
Tells the paper orientation.
|
static void |
main(java.lang.String[] args)
This will create a PDF document with some text in it.
|
void |
setFont(PDFont aFont) |
void |
setFontSize(int aFontSize) |
void |
setLandscape(boolean landscape)
Sets paper orientation.
|
void |
setMediaBox(PDRectangle mediaBox)
Sets page size of produced PDF.
|
private void |
usage()
This will print out a message telling how to use this example.
|
private static final int FONTSCALE
private static final PDType1Font DEFAULT_FONT
private static final int DEFAULT_FONT_SIZE
private static final float LINE_HEIGHT_FACTOR
private int fontSize
private PDRectangle mediaBox
private boolean landscape
private PDFont font
private static final java.util.Map<java.lang.String,PDType1Font> STANDARD_14
public PDDocument createPDFFromText(java.io.Reader text) throws java.io.IOException
text
- The stream of text data.java.io.IOException
- If there is an error writing the data.public void createPDFFromText(PDDocument doc, java.io.Reader text) throws java.io.IOException
doc
- The document.text
- The stream of text data.java.io.IOException
- If there is an error writing the data.public static void main(java.lang.String[] args) throws java.io.IOException
args
- Command line arguments.java.io.IOException
- If there is an error with the PDF.private static PDRectangle createRectangle(java.lang.String paperSize)
private void usage()
private static PDType1Font getStandardFont(java.lang.String name)
name
- The name of the font to get.private static java.lang.String[] getStandard14Names()
public PDFont getFont()
public void setFont(PDFont aFont)
aFont
- The font to set.public int getFontSize()
public void setFontSize(int aFontSize)
aFontSize
- The fontSize to set.public PDRectangle getMediaBox()
public void setMediaBox(PDRectangle mediaBox)
mediaBox
- public boolean isLandscape()
public void setLandscape(boolean landscape)
landscape
-