PDF builder written in Kotlin with a statically typed DSL. Inspired by Craig's document-builder library.
Include the following in your build.gradle:
repositories {
jcenter()
}
dependencies {
implementation 'com.github.timrs2998:pdf-builder:<latest version>'
}
and you can use the library in Kotlin with its DSL:
val pdDocument = document {
text("Hello")
text("Hello, color is red!") {
fontColor = Color(1f, .1f, .1f)
}
table {
row {
text("r1 c1")
text("r1 c2")
}
row {
text("r2 c1")
text("r2 c2")
}
border = Border(1f, 2f, 3f, 4f, Color.GREEN, Color.RED, Color.BLUE, Color.BLACK)
}
}
pdDocument.use { pdDocument ->
pdDocument.save("output.pdf")
}
or Java without a DSL:
Document document = new Document();
TextElement t1 = new TextElement("Hello");
TextElement t2 = new TextElement("Hello, color is red!");
t2.setFontColor(new Color(1f, .1f, .1f));
document.getChildren().add(t1);
document.getChildren().add(t2);
To build from source:
git clone git@github.com:timrs2998/pdf-builder.git
cd pdf-builder/
./gradlew build
To release a new version, use GitHub to create release tags in "v1.0.0" format. Travis will build and publish to Bintray provided that the BINTRAY_USER and BINTRAY_KEY environment variables are set.
Travis also needs a personal access token for GitHub provided through the GITHUB_TOKEN environment variable to update GitHub pages.