Class PdfParagraph
java.lang.Object
com.codename1.pdf.PdfParagraph
A block of text for PdfLayout, wrapped to the available width. It is
made of runs, each with its own font, size, color and optional link:
PdfDocument doc = new PdfDocument();
PdfLayout layout = new PdfLayout(doc, PdfPageSize.A4, 54);
layout.add(new PdfParagraph()
.append("Total due: ", PdfFont.HELVETICA, 11)
.append("$1,240.00", PdfFont.HELVETICA_BOLD, 11)
.setAlignment(PdfParagraph.ALIGN_RIGHT));
Lines break at spaces and after hyphens; a word wider than the line is
broken between characters. A \n in the text forces a line break.
Text is given in reading order. Each line is ordered for display by the
Unicode bidirectional algorithm, so Hebrew and Arabic read right to left
with numbers and Latin words inside them kept left to right, and Arabic
letters are joined. The paragraph direction comes from its first strong
character unless set with setDirection(int); it decides which side
lines start from when no alignment is set and which side the first-line
indent is on.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intLines are centered.static final intLines fill the width by widening the spaces, except the last.static final intLines start at the left edge.static final intLines end at the right edge.static final intLines start at the side the paragraph direction reads from: the left for left-to-right text, the right for right-to-left.static final intThe direction comes from the first strong character.static final intLeft to right.static final intRight to left. -
Constructor Summary
ConstructorsConstructorDescriptionAn empty paragraph; add text with theappendmethods.PdfParagraph(String text, PdfFont font, float size) A paragraph oftextin one font. -
Method Summary
Modifier and TypeMethodDescriptionAdds black text.Adds text in colorrgb(0xRRGGBB).appendLink(String text, String uri, PdfFont font, float size, int rgb) Adds text that opensuriwhen clicked, in colorrgb.setAlignment(int alignment) Sets the alignment, one of theALIGN_constants.setDirection(int direction) Sets the paragraph direction, one of theDIRECTION_constants.setFirstLineIndent(float points) Indents the first line bypoints.setLineSpacing(float multiple) Sets the distance between baselines as a multiple of the largest font's natural line height; 1.15 by default.setSpaceAfter(float points) Sets the space below the paragraph in points; 6 by default.setSpaceBefore(float points) Sets the space above the paragraph in points; 0 by default.
-
Field Details
-
ALIGN_LEFT
public static final int ALIGN_LEFTLines start at the left edge.- See Also:
-
ALIGN_CENTER
public static final int ALIGN_CENTERLines are centered.- See Also:
-
ALIGN_RIGHT
public static final int ALIGN_RIGHTLines end at the right edge.- See Also:
-
ALIGN_JUSTIFY
public static final int ALIGN_JUSTIFYLines fill the width by widening the spaces, except the last.- See Also:
-
ALIGN_START
public static final int ALIGN_STARTLines start at the side the paragraph direction reads from: the left for left-to-right text, the right for right-to-left. The default.- See Also:
-
DIRECTION_AUTO
public static final int DIRECTION_AUTOThe direction comes from the first strong character. The default.- See Also:
-
DIRECTION_LTR
public static final int DIRECTION_LTRLeft to right.- See Also:
-
DIRECTION_RTL
public static final int DIRECTION_RTLRight to left.- See Also:
-
-
Constructor Details
-
PdfParagraph
public PdfParagraph()An empty paragraph; add text with theappendmethods. -
PdfParagraph
-
-
Method Details
-
append
Adds black text. -
append
Adds text in colorrgb(0xRRGGBB). -
appendLink
Adds text that opensuriwhen clicked, in colorrgb. -
setAlignment
Sets the alignment, one of theALIGN_constants. -
setDirection
Sets the paragraph direction, one of theDIRECTION_constants. -
setLineSpacing
Sets the distance between baselines as a multiple of the largest font's natural line height; 1.15 by default. -
setSpaceBefore
Sets the space above the paragraph in points; 0 by default. -
setSpaceAfter
Sets the space below the paragraph in points; 6 by default. -
setFirstLineIndent
Indents the first line bypoints.
-