A library which makes it easier to manually create a simple PDF document with Apache PDFBox.
- HTML-like element model.
- Reversed Y-axis so a point (0, 0) is at the top-left corner of the page.
- Basic elements for drawing boxes, texts, tables and arrows.
-
Include the library into your project.
// build.gradle.kts repositories { maven("https://jitpack.io") } dependencies { implementation("com.github.vkuzel:Simple-PDF-Layout:2.1.2") }
-
Use it
// Create page of size A4. Page page = Page.a4() // Create a text box of width 100 points on the page and align it to right. .addText(text -> text .setTopLeft(100, 100) .setWidth(100) .setAlignment(Text.Alignment.RIGHT) .setText("Hello World!")) // Add an arrow pointing to the the previous element (text). .addArrow(arrow -> arrow .setStartElement(arrow.getPrevious())); // Render text to file. Document.renderPageToFile(page, "some-path.pdf");
Following image was rendered by BoxModelDocumentTest.generateBoxModelDocumentTest()
method in this project.