Skip to content

Commit de2d123

Browse files
author
Open Lowcode SAS
committed
Added an example of text in a box
1 parent c90ef4e commit de2d123

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/org/openlowcode/samples/pdf/SampleOpenLowcodePDFDocument.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.openlowcode.tools.pdf.PDFDocument;
2121
import org.openlowcode.tools.pdf.PDFMultiPageTable;
2222
import org.openlowcode.tools.pdf.PDFPage;
23+
import org.openlowcode.tools.pdf.PDFPage.BoxTextContent;
2324
import org.openlowcode.tools.pdf.PDFPageBand;
2425
import org.openlowcode.tools.pdf.PDFPageBandHeaders;
2526
import org.openlowcode.tools.pdf.ParagraphHeader;
@@ -69,7 +70,14 @@ private static void feedcontent(PDFDocument document) throws IOException {
6970
coverpage.drawCenteredTextAt(true, coverpage.getPagetop() + 100, 0, "Open Lowcode PDF");
7071
coverpage.drawCenteredTextAt(false, coverpage.getPagetop() + 130, 0, "automatically generated document");
7172
document.addPDFPart(coverpage);
72-
73+
// demonstrate facilities to write text in box
74+
BoxTextContent boxsize = coverpage.drawTextInBox(coverpage.getPageLeft(),coverpage.getPagetop()+160, coverpage.getPageLeft()+60,"A real example showing main features of the library (excluding images)");
75+
float bottomofbox1 = coverpage.drawBoxWithLineNumber(false,coverpage.getPageLeft(),coverpage.getPagetop()+160, coverpage.getPageLeft()+60, boxsize.getNblines(),boxsize.getNbparagraph());
76+
// second box is put just 5 mm after first box
77+
BoxTextContent boxsize2 = coverpage.drawTextInBox(coverpage.getPageLeft(),bottomofbox1+5, coverpage.getPageLeft()+60,"All you see is quick to code.");
78+
coverpage.drawBoxWithLineNumber(false,coverpage.getPageLeft(),bottomofbox1+5, coverpage.getPageLeft()+60, boxsize2.getNblines(),boxsize2.getNbparagraph());
79+
80+
7381
// create document body
7482
PDFPageBand documentbody = new PDFPageBand(header, true, 15, 10);
7583
document.addPDFPart(documentbody);

0 commit comments

Comments
 (0)