public class PDFPage extends PDFPart
Modifier and Type | Class and Description |
---|---|
static class |
PDFPage.BoxTextContent
This class stores the way a text was calculated or printed inside a box.
|
static class |
PDFPage.FontAndSize
An utility class allowing to store font and font size in a same object
|
Modifier and Type | Field and Description |
---|---|
static float |
A4_LONGSIDE_IN_MM |
static float |
A4_SHORTSIDE_IN_MM |
static int |
TEXTTYPE_BULLET_L1 |
static int |
TEXTTYPE_BULLET_L2 |
static int |
TEXTTYPE_BULLET_L3 |
static int |
TEXTTYPE_LABEL |
static int |
TEXTTYPE_PARAGRAPH_HEADER |
static int |
TEXTTYPE_PLAIN |
static int |
TEXTTYPE_PLAIN_BOLD |
static int |
TEXTTYPE_PLAIN_BOLD_ITALIC |
static int |
TEXTTYPE_PLAIN_ITALIC |
static int |
TEXTTYPE_SECTION_HEADER |
static int |
TEXTTYPE_TITLE |
Constructor and Description |
---|
PDFPage(boolean portrait,
float leftrightmargin,
float topbottommargin)
generates an A4 page with margin size indicated in mm, with topatzero = true
|
PDFPage(boolean portrait,
float leftrightmargin,
float topbottommargin,
boolean topatzero)
Generates an A4 format page with dimensions indicated in mm
|
PDFPage(float customwidth,
float customheight,
float leftrightmargin,
float topbottommargin,
boolean topatzero) |
Modifier and Type | Method and Description |
---|---|
void |
addHeader(PDFPageBandHeaders header) |
static PDFPage.BoxTextContent |
calculateBoxAndMaybeWriteText(float left,
float top,
float right,
java.lang.String text,
boolean write,
boolean partial,
float maxheight,
PDFPage page,
int texttype,
boolean splitparagraph) |
static PDFPage.BoxTextContent |
calculateBoxAndMaybeWriteText(float left,
float top,
float right,
java.lang.String text,
boolean write,
boolean partial,
float maxheight,
PDFPage page,
int texttype,
boolean splitparagraph,
boolean compactprint) |
static PDFPage.BoxTextContent |
calculateBoxAndMaybeWriteText(float left,
float top,
float right,
java.lang.String text,
boolean write,
boolean partial,
float maxheight,
PDFPage page,
int texttype,
boolean splitparagraph,
boolean compactprint,
java.awt.Color color,
float startfirstlineoffset,
int startatline,
int startatparagraph) |
static PDFPage.BoxTextContent |
calculateBoxAndMaybeWriteText(float left,
float top,
float right,
java.lang.String text,
boolean write,
PDFPage page,
int texttype) |
PDFPage.BoxTextContent |
calculateTextSize(float left,
float right,
java.lang.String text) |
void |
closepage()
this needs to be called at the end the work on the page.
|
void |
drawBox(boolean fatline,
float left,
float top,
float right,
float bottom)
Draws a rectangular box
|
void |
drawBox(boolean fatline,
float left,
float top,
float right,
float bottom,
java.awt.Color color) |
void |
drawBox(boolean fatline,
float left,
float top,
float right,
float bottom,
java.awt.Color color,
boolean drawtop,
boolean drawbottom,
boolean drawleft,
boolean drawright) |
float |
drawBoxWithLineNumber(boolean fatline,
float left,
float top,
float right,
int numberoflines) |
float |
drawBoxWithLineNumber(boolean fatline,
float left,
float top,
float right,
int numberoflines,
int numberofparagraphs) |
void |
drawBoxWithWidthAndHeight(boolean fatline,
float left,
float top,
float width,
float height) |
void |
drawBoxWithWidthAndHeight(boolean fatline,
float left,
float top,
float width,
float height,
boolean drawtop,
boolean drawbottom,
boolean drawleft,
boolean drawright) |
void |
drawCalculatedText(boolean label,
float xcoordinates,
float top,
int linenumber,
int paragraphnumber,
boolean alignleft,
TextAfterLayout calculatedtext) |
void |
drawCalculatedText(float xcoordinates,
float top,
int linenumber,
int paragraphnumber,
boolean alignleft,
TextAfterLayout calculatedtext) |
void |
drawCenteredTextAt(boolean title,
float top,
int paragraphnumber,
java.lang.String text) |
void |
drawCircle(java.awt.Color bordercolor,
java.awt.Color fillcolor,
float centerx,
float centery,
float radius) |
void |
drawFixWidthRightAlignedTextAt(float rightForColumn,
float topofline,
int lineindex,
int paragraphindex,
java.lang.String text)
This method will write with current HELVETICA font a fix width per character
text (typically number) padded on the right considering usual margins.
|
void |
drawFreeFontTextAt(float left,
float top,
java.awt.Color color,
boolean bold,
boolean italic,
boolean serif,
float fontinpoint,
java.lang.String text) |
void |
drawImageAt(float left,
float top,
byte[] filecontent,
java.lang.String filename,
float targetwidth) |
void |
drawImageAt(float left,
float top,
java.lang.String imagepath,
float targetwidth) |
void |
drawImageInsideBox(float left,
float top,
float right,
float bottom,
byte[] filecontent,
java.lang.String filename)
will automatically scale the image respecting aspect ratio to fit inside the
box.
|
float |
drawLeftPaddedTextAt(int texttype,
float left,
float top,
int linenumber,
int paragraphnumber,
java.lang.String text) |
float |
drawLeftPaddedTextAt(int texttype,
float left,
float top,
int linenumber,
int paragraphnumber,
java.lang.String text,
boolean compactprint) |
float |
drawLeftPaddedTextAt(int texttype,
float left,
float top,
int linenumber,
int paragraphnumber,
java.lang.String text,
boolean compactprint,
java.awt.Color color) |
void |
drawLine(boolean fatline,
float startx,
float starty,
float endx,
float endy,
java.awt.Color color) |
void |
drawParagraphHeaderAt(float left,
float top,
int linenumber,
int paragraphnumber,
java.lang.String text) |
void |
drawSimpleTextAt(boolean label,
float left,
float top,
int linenumber,
int paragraphnumber,
java.lang.String text)
Draws a single text from the point of origin (adding necessary margins).
|
void |
drawSimpleTextAt(boolean label,
float left,
float top,
int linenumber,
int paragraphnumber,
java.lang.String text,
boolean horizontalparagraphmargin)
Draws a single text from the point of origin (adding necessary margins).
|
PDFPage.BoxTextContent |
drawTextInBox(float left,
float top,
float right,
java.lang.String text) |
PDFPage.BoxTextContent |
drawTextInBox(float left,
float top,
float right,
java.lang.String text,
int texttype) |
PDFPage.BoxTextContent |
drawTextInBox(float left,
float top,
float right,
java.lang.String text,
int texttype,
int maxline) |
void |
drawTextWidget(int texttype,
float left,
float top,
float newleft,
int linenumber,
int paragraphnumber,
boolean newparagraph,
boolean compactprint,
java.awt.Color color) |
PDFPage.BoxTextContent |
drawTextWithLabelInBox(float left,
float top,
float right,
java.lang.String label,
java.lang.String text,
int maxline)
This method writes on the left a label (with label type of text), and the
text content on the right, making sure not to get outside of the specified
box.
Note: this will align on the bottom the label line with the first line |
void |
fillBox(java.awt.Color color,
float left,
float top,
float right,
float bottom) |
float |
fillBoxWithLineNumber(java.awt.Color color,
float left,
float top,
float right,
int numberoflines,
int numberofparagraphs) |
float |
getHeight() |
static int |
getNumberOfLinesAvailableForParagraph(float spaceinmm) |
float |
getPageBottom() |
int |
getPageIndex()
This method should only be called during the final layout.
|
float |
getPageLeft() |
protected int |
getPageNumber()
This method should be called at the end of the layout phase or during the
printing.
|
float |
getPageRight() |
float |
getPagetop() |
float |
getParagraphHeaderTextWidth(java.lang.String[] lines)
returns the maximum length of the lines provided with paragraphheaderfont
|
static float |
getTextSize(java.lang.String[] lines,
int texttype) |
static float |
getTextWidth(boolean label,
java.lang.String line) |
static float |
getTextWidth(boolean label,
java.lang.String line,
boolean paragraphspacing) |
float |
getWidth() |
protected void |
initialize()
This method is called just before the actual printing in order to initialize
widgets that depend from the content of the full document.
|
boolean |
isTopAtZero() |
static boolean |
isValid(char currentchar) |
protected void |
layoutPages(int pagesbefore)
This method is called just after initalize and before print.
|
protected void |
print(org.apache.pdfbox.pdmodel.PDDocument document)
This method actually prints the document.
|
static java.lang.String |
remove(java.lang.String text)
Removes all non win-ansi characters.
|
static void |
securedShowText(org.apache.pdfbox.pdmodel.PDPageContentStream contentStream,
java.lang.String text) |
static PDFPage.BoxTextContent |
writeAsMuchTextAsPossible(float left,
float top,
float right,
float remainingheight,
java.lang.String text,
PDFPage page,
int texttype,
boolean splitparagraph) |
static PDFPage.BoxTextContent |
writeAsMuchTextAsPossible(float left,
float top,
float right,
float remainingheight,
java.lang.String text,
PDFPage page,
int texttype,
boolean splitparagraph,
boolean compactprint) |
getParent, setParentPDFDocument
public static final float A4_LONGSIDE_IN_MM
public static final float A4_SHORTSIDE_IN_MM
public static final int TEXTTYPE_PLAIN
public static final int TEXTTYPE_LABEL
public static final int TEXTTYPE_SECTION_HEADER
public static final int TEXTTYPE_TITLE
public static final int TEXTTYPE_BULLET_L1
public static final int TEXTTYPE_BULLET_L2
public static final int TEXTTYPE_BULLET_L3
public static final int TEXTTYPE_PARAGRAPH_HEADER
public static final int TEXTTYPE_PLAIN_ITALIC
public static final int TEXTTYPE_PLAIN_BOLD
public static final int TEXTTYPE_PLAIN_BOLD_ITALIC
public PDFPage(boolean portrait, float leftrightmargin, float topbottommargin, boolean topatzero) throws java.io.IOException
portrait
- leftrightmargin
- margin at left and right in mmtopbottommargin
- margin at top and bottom in mmtopatzero
- java.io.IOException
public PDFPage(float customwidth, float customheight, float leftrightmargin, float topbottommargin, boolean topatzero) throws java.io.IOException
customwidth
- custom width in mmcustomheight
- custom height in mmleftrightmargin
- margin at left and right in mmtopbottommargin
- margin at top and bottom in mmtopatzero
- java.io.IOException
- if any issue related to file system happens creating the
PDF pagepublic PDFPage(boolean portrait, float leftrightmargin, float topbottommargin) throws java.io.IOException
portrait
- true if portrait, false is landscapeleftrightmargin
- margin at left and right in mmtopbottommargin
- margin at top and bottom in mmjava.io.IOException
public int getPageIndex()
public float getHeight()
public float getWidth()
public static float getTextSize(java.lang.String[] lines, int texttype) throws java.io.IOException
lines
- lines of text, the function returns the maximum of text sizestexttype
- texttype as defined in PDFBoxjava.io.IOException
public boolean isTopAtZero()
public void addHeader(PDFPageBandHeaders header) throws java.io.IOException
java.io.IOException
public void closepage() throws java.io.IOException
java.io.IOException
protected void print(org.apache.pdfbox.pdmodel.PDDocument document) throws java.io.IOException
PDFPart
public void drawBoxWithWidthAndHeight(boolean fatline, float left, float top, float width, float height, boolean drawtop, boolean drawbottom, boolean drawleft, boolean drawright) throws java.io.IOException
fatline
- fatline true if line is fat, false if line is standard
(thinner)left
- left coordinates in mm (note: in PDF, left starts at zero)top
- top coordinates in mm (note: in PDF, bottom starts at zero
except if topatzero is set)width
- width in mm, a positive numberheight
- height in mm, a positive numberdrawtop
- if true, draw the top linedrawbottom
- if true, draw the bottom linedrawleft
- if true, draw the left linedrawright
- if true, draw the right linejava.io.IOException
public void drawBoxWithWidthAndHeight(boolean fatline, float left, float top, float width, float height) throws java.io.IOException
fatline
- fatline true if line is fat, false if line is standard
(thinner)left
- left coordinates in mm (note: in PDF, left starts at zero)top
- top coordinates in mm (note: in PDF, bottom starts at zero
except if topatzero is set)width
- width in mm, a positive numberheight
- height in mm, a positive numberjava.io.IOException
public void drawCircle(java.awt.Color bordercolor, java.awt.Color fillcolor, float centerx, float centery, float radius) throws java.io.IOException
bordercolor
- fillcolor
- centerx
- centery
- radius
- java.io.IOException
public void drawBox(boolean fatline, float left, float top, float right, float bottom, java.awt.Color color, boolean drawtop, boolean drawbottom, boolean drawleft, boolean drawright) throws java.io.IOException
fatline
- true if line is fat, false if line is standard (thinner)left
- left coordinates in mm (note: in PDF, left starts at zero)top
- top coordinates in mm (note: in PDF, bottom starts at zero
except if topatzero is set)right
- right coordinates in mm (note: in PDF, left starts at zero)bottom
- bottom coordinates in mm (note: in PDF, bottom starts at
zero except if topatzero is set)color
- color of the box.drawtop
- if true, draw the top line of the boxdrawbottom
- if bottom, draw the bottom line of the boxdrawleft
- if left ... well, draw the left line of the boxdrawright
- if right (I think you got it) draw the right line of the
boxjava.io.IOException
- if anything bad happens with the file being printedpublic void drawBox(boolean fatline, float left, float top, float right, float bottom, java.awt.Color color) throws java.io.IOException
fatline
- true if line is fat, false if line is standard (thinner)left
- left coordinates in mm (note: in PDF, left starts at zero)top
- top coordinates in mm (note: in PDF, bottom starts at zero
except if topatzero is set)right
- right coordinates in mm (note: in PDF, left starts at zero)bottom
- bottom coordinates in mm (note: in PDF, bottom starts at zero
except if topatzero is set)color
- color of the box.java.io.IOException
public void drawBox(boolean fatline, float left, float top, float right, float bottom) throws java.io.IOException
fatline
- true if line is fat, false if line is standard (thinner)left
- left coordinates in mm (note: in PDF, left starts at zero)top
- top coordinates in mm (note: in PDF, bottom starts at zero
except if topatzero is set)right
- right coordinates in mm (note: in PDF, left starts at zero)bottom
- bottom coordinates in mm (note: in PDF, bottom starts at zero
except if topatzero is set)java.io.IOException
public void drawLine(boolean fatline, float startx, float starty, float endx, float endy, java.awt.Color color) throws java.io.IOException
fatline
- startx
- starty
- endx
- endy
- color
- java.io.IOException
public static float getTextWidth(boolean label, java.lang.String line) throws java.io.IOException
label
- true if shown as label, false if shown as normal textline
- the line of textjava.io.IOException
public static float getTextWidth(boolean label, java.lang.String line, boolean paragraphspacing) throws java.io.IOException
label
- true if shown as label, false if shown as normal textline
- the line of textparagraphspacing
- if true, 2 times the paragraph left margin will be
added.java.io.IOException
public float getParagraphHeaderTextWidth(java.lang.String[] lines) throws java.io.IOException
lines
- the lines of textjava.io.IOException
public float drawBoxWithLineNumber(boolean fatline, float left, float top, float right, int numberoflines) throws java.io.IOException
fatline
- left
- top
- right
- numberoflines
- java.io.IOException
public float drawBoxWithLineNumber(boolean fatline, float left, float top, float right, int numberoflines, int numberofparagraphs) throws java.io.IOException
fatline
- left
- top
- right
- numberoflines
- numberofparagraphs
- java.io.IOException
public float fillBoxWithLineNumber(java.awt.Color color, float left, float top, float right, int numberoflines, int numberofparagraphs) throws java.io.IOException
java.io.IOException
public void fillBox(java.awt.Color color, float left, float top, float right, float bottom) throws java.io.IOException
java.io.IOException
public void drawFreeFontTextAt(float left, float top, java.awt.Color color, boolean bold, boolean italic, boolean serif, float fontinpoint, java.lang.String text) throws java.io.IOException
left
- left coordinates for the text (left of the margin)top
- top coordinates for the text (top of the margin)color
- Color expressed as java.awt.Colorbold
- true if bolditalic
- true if italicserif
- if true, police is times, if false, police is helveticafontinpoint
- the font size in pointtext
- Textjava.io.IOException
public void drawParagraphHeaderAt(float left, float top, int linenumber, int paragraphnumber, java.lang.String text) throws java.io.IOException
java.io.IOException
public void drawCalculatedText(boolean label, float xcoordinates, float top, int linenumber, int paragraphnumber, boolean alignleft, TextAfterLayout calculatedtext) throws java.io.IOException
label
- xcoordinates
- leftcoordinates if alignleft = true, else right
coordinatestop
- top of the boxlinenumber
- line number of text (starting at 0)paragraphnumber
- paragraph number of text (starting at 0)alignleft
- if true, align on left, if false, align on rightcalculatedtext
- text to writejava.io.IOException
public void drawCalculatedText(float xcoordinates, float top, int linenumber, int paragraphnumber, boolean alignleft, TextAfterLayout calculatedtext) throws java.io.IOException
xcoordinates
- leftcoordinates if alignleft = true, else right
coordinatestop
- top of the boxlinenumber
- line number of text (starting at 0)paragraphnumber
- paragraph number of text (starting at 0)alignleft
- if true, align on left, if false, align on rightcalculatedtext
- text to writejava.io.IOException
public static int getNumberOfLinesAvailableForParagraph(float spaceinmm)
public void drawSimpleTextAt(boolean label, float left, float top, int linenumber, int paragraphnumber, java.lang.String text) throws java.io.IOException
label
- true of label, right if normal textleft
- left coordinates for the text (left of the margin)top
- top coordinates for the text (top of the margin)linenumber
- line number of text (starting at 0)paragraphnumber
- paragraph number of text (starting at 0)text
- the text to writejava.io.IOException
public void drawSimpleTextAt(boolean label, float left, float top, int linenumber, int paragraphnumber, java.lang.String text, boolean horizontalparagraphmargin) throws java.io.IOException
label
- true of label, right if normal textleft
- left coordinates for the text (left of the
margin)top
- top coordinates for the text (top of the
margin)linenumber
- line number of text (starting at 0)paragraphnumber
- paragraph number of text (starting at 0)text
- the text to writehorizontalparagraphmargin
- if true, write with normal margin, if false,
write text exactly at point specified. The
false option is especially suitable for
diagram axisjava.io.IOException
public void drawTextWidget(int texttype, float left, float top, float newleft, int linenumber, int paragraphnumber, boolean newparagraph, boolean compactprint, java.awt.Color color) throws java.io.IOException
texttype
- left
- top
- linenumber
- paragraphnumber
- newparagraph
- compactprint
- color
- java.io.IOException
public float drawLeftPaddedTextAt(int texttype, float left, float top, int linenumber, int paragraphnumber, java.lang.String text) throws java.io.IOException
texttype
- left
- top
- linenumber
- paragraphnumber
- text
- java.io.IOException
public float drawLeftPaddedTextAt(int texttype, float left, float top, int linenumber, int paragraphnumber, java.lang.String text, boolean compactprint, java.awt.Color color) throws java.io.IOException
texttype
- left
- top
- linenumber
- paragraphnumber
- text
- compactprint
- color
- java.io.IOException
public float drawLeftPaddedTextAt(int texttype, float left, float top, int linenumber, int paragraphnumber, java.lang.String text, boolean compactprint) throws java.io.IOException
texttype
- type of text as a constant integer declared in this
classleft
- left coordinates in mm from the border of the pagetop
- top coordinates in mm (either from top or bottom)linenumber
- number of lines already writtenparagraphnumber
- number of paragraphes already writtentext
- text to writejava.io.IOException
public void drawCenteredTextAt(boolean title, float top, int paragraphnumber, java.lang.String text) throws java.io.IOException
title
- if true, write big title text, false writes normal
texttop
- top coordinated (top of the margin)paragraphnumber
- starts with 0, and allows to write several lines
without calculating coordinatestext
- the text to writejava.io.IOException
public float getPagetop()
public float getPageBottom()
public float getPageLeft()
public float getPageRight()
public static PDFPage.BoxTextContent writeAsMuchTextAsPossible(float left, float top, float right, float remainingheight, java.lang.String text, PDFPage page, int texttype, boolean splitparagraph) throws java.io.IOException
left
- left of the printing zone in mmtop
- top of the prining zone in mmright
- right of the printing zone in mmremainingheight
- the maximum height to printtext
- the full text to writepage
- page to print intexttype
- text type as defined in PDFPage constantsplitparagraph:
- true if this is the non-first part of
a split paragraph. Typically, widget does not have to
be printedjava.io.IOException
public static PDFPage.BoxTextContent writeAsMuchTextAsPossible(float left, float top, float right, float remainingheight, java.lang.String text, PDFPage page, int texttype, boolean splitparagraph, boolean compactprint) throws java.io.IOException
left
- left of the printing zone in mmtop
- top of the prining zone in mmright
- right of the printing zone in mmremainingheight
- the maximum height to printtext
- the full text to writepage
- page to print intexttype
- text type as defined in PDFPage constantsplitparagraph:
- true if this is the non-first part of
a split paragraph. Typically, widget does not have to
be printedjava.io.IOException
public static PDFPage.BoxTextContent calculateBoxAndMaybeWriteText(float left, float top, float right, java.lang.String text, boolean write, PDFPage page, int texttype) throws java.io.IOException
left
- left of the printing zone in mmtop
- top of the prining zone in mmright
- right of the printing zone in mmremainingheight
- the maximum height to printtext
- the full text to writepage
- page to print inwrite
- true to write the text, false just to calculatetexttype
- text type as defined in PDFPage constantjava.io.IOException
public static PDFPage.BoxTextContent calculateBoxAndMaybeWriteText(float left, float top, float right, java.lang.String text, boolean write, boolean partial, float maxheight, PDFPage page, int texttype, boolean splitparagraph, boolean compactprint, java.awt.Color color, float startfirstlineoffset, int startatline, int startatparagraph) throws java.io.IOException
left
- left of the printing zone in mmtop
- top of the prining zone in mmright
- right of the printing zone in mmtext
- the full text to writewrite
- true to write the text, false just to calculatepartial
- true to write only partial content within the
maximum height limit specifiedmaxheight
- max height to print partial contentpage
- page to print intexttype
- one of the constants prefixed by 'TEXTTYPE_' in
the classsplitparagraph
- : true if this is the non-first part of a section
split across pages. Typically bullet character is
not printed if this argument is true.compactprint
- if true, text is written without paragraphmargincolor
- color of textstartfirstlineoffset
- first line will be printed with the given offset
in mmstartatline
- start printing at line number (default is zero if
first line)startatparagraph
- start at paragraph number (default is zero if
first line)java.io.IOException
- if anything bad happened during the printingpublic static PDFPage.BoxTextContent calculateBoxAndMaybeWriteText(float left, float top, float right, java.lang.String text, boolean write, boolean partial, float maxheight, PDFPage page, int texttype, boolean splitparagraph, boolean compactprint) throws java.io.IOException
left
- left of the printing zone in mmtop
- top of the prining zone in mmright
- right of the printing zone in mmtext
- the full text to writewrite
- true to write the text, false just to calculatepartial
- true to write only partial content within the maximum
height limit specifiedmaxheight
- max height to print partial contentpage
- page to print intexttype
- one of the constants prefixed by 'TEXTTYPE_' in the
classsplitparagraph
- : true if this is the non-first part of a section split
across pages. Typically bullet character is not printed
if this argument is true.compactprint
- if true, text is written without paragraphmarginjava.io.IOException
- if anything bad happenspublic static PDFPage.BoxTextContent calculateBoxAndMaybeWriteText(float left, float top, float right, java.lang.String text, boolean write, boolean partial, float maxheight, PDFPage page, int texttype, boolean splitparagraph) throws java.io.IOException
left
- left of the printing zone in mmtop
- top of the prining zone in mmright
- right of the printing zone in mmtext
- the full text to writewrite
- true to write the text, false just to calculatepartial
- true to write only partial content within the maximum
height limit specifiedmaxheight
- max height to print partial contentpage
- page to print intexttype
- one of the constants prefixed by 'TEXTTYPE_' in the
classsplitparagraph
- : true if this is the non-first part of a section split
across pages. Typically bullet character is not printed
if this argument is true.java.io.IOException
public PDFPage.BoxTextContent drawTextInBox(float left, float top, float right, java.lang.String text) throws java.io.IOException
left
- the left limit in mm (note: margins are inside)top
- the top of the box in mm (note: margins are inside)right
- the right limit in mm (note: margins are inside)text
- the text to printjava.io.IOException
public PDFPage.BoxTextContent drawTextWithLabelInBox(float left, float top, float right, java.lang.String label, java.lang.String text, int maxline) throws java.io.IOException
left
- the left limit in mm (note: margins are inside)top
- the top of the box in mm (note: margins are inside)right
- the right limit in mm (note: margins are inside)label
- label texttext
- payload textmaxline
- : zero if the number of lines of text should not be limited ,
or a strictly positive figure to limit the number of lines in
total. If text is cut, it will get "..." in the endjava.io.IOException
public PDFPage.BoxTextContent drawTextInBox(float left, float top, float right, java.lang.String text, int texttype) throws java.io.IOException
left
- the left limit in mm (note: margins are inside)top
- the top of the box in mm (note: margins are inside)right
- the right limit in mm (note: margins are inside)text
- the text to printtexttype
- the text type as defined in PDFPAGE as TEXTTYPE...java.io.IOException
public PDFPage.BoxTextContent drawTextInBox(float left, float top, float right, java.lang.String text, int texttype, int maxline) throws java.io.IOException
left
- the left limit in mm (note: margins are inside)top
- the top of the box in mm (note: margins are inside)right
- the right limit in mm (note: margins are inside)text
- the text to printtexttype
- the text type as defined in PDFPAGE as TEXTTYPE...maxline
- the maximum number of lines to write, or zero if no limit.java.io.IOException
public PDFPage.BoxTextContent calculateTextSize(float left, float right, java.lang.String text) throws java.io.IOException
left
- left the left limit in mm (note: margins are inside)right
- top the top of the box in mm (note: margins are inside)text
- the text to printjava.io.IOException
public void drawImageAt(float left, float top, java.lang.String imagepath, float targetwidth)
left
- in page coordinates. This attribute and next defines the
top-left point for the image.top
- in page coordinates. This attribute and next defines the
top-left point for the image.imagepath
- a valid path for server execution (either relative to
classpath home, or absolute)targetwidth
- the width of the image in mm. Height will be scaled
automatically to respect aspect ratio.public void drawImageInsideBox(float left, float top, float right, float bottom, byte[] filecontent, java.lang.String filename)
left
- in page coordinates. This attribute and next defines the
top-left point for the image.top
- in page coordinates. This attribute and next defines the
top-left point for the image.right
- in page coordinates (right reference for image in
milimeter (0 is left of page)bottom
- in page coordinates (right reference for image in
milimeter (0 is left of page)filecontent
- a byte array with the file contentfilename
- the name of the file with suffixpublic void drawImageAt(float left, float top, byte[] filecontent, java.lang.String filename, float targetwidth)
left
- in page coordinates. This attribute and next defines the
top-left point for the image.top
- in page coordinates. This attribute and next defines the
top-left point for the image.filecontent
- a byte array with the file contentfilename
- the name of the file with suffixtargetwidth
- the width the image will be scaled to, preserving aspect
ratiopublic void drawFixWidthRightAlignedTextAt(float rightForColumn, float topofline, int lineindex, int paragraphindex, java.lang.String text) throws java.io.IOException
rightForColumn
- topofline
- lineindex
- text
- java.io.IOException
public static boolean isValid(char currentchar)
public static java.lang.String remove(java.lang.String text)
text
- public static void securedShowText(org.apache.pdfbox.pdmodel.PDPageContentStream contentStream, java.lang.String text)
protected int getPageNumber()
PDFPart
getPageNumber
in class PDFPart
protected void initialize()
PDFPart
initialize
in class PDFPart
protected void layoutPages(int pagesbefore)
PDFPart
layoutPages
in class PDFPart
pagesbefore
- the number of pages layed-out before.