Skip to content

Commit 749eeac

Browse files
committed
Folio Java SDK 0.1.0
Java PDF generation, signing, and processing library backed by the Folio Go engine (v0.6.2) via Panama FFI. Apache 2.0 licensed. 372 Panama FFI bindings covering the full engine API: - Document generation with fluent builders - Advanced CSS-like layout: Flexbox, Grid, Columns, Float, TabbedLine - HTML-to-PDF conversion (one-liner) - Barcodes (QR, Code128, EAN-13) and SVG rendering - Digital signatures (PAdES B-B through B-LTA) - PDF merge with page manipulation (rotate, reorder, crop, remove) - Page import for template workflows - Form creation, filling, and flattening - PDF redaction (text, regex, regions) - Encryption with granular permissions (AES-256/128, RC4) - PDF/A compliance with validation - Tagged PDF / PDF/UA (alt text, custom tags, structure tree) - Structured content extraction (text spans, images, paths as JSON) - Drawing primitives, text highlighting, CSS length parsing 59 public API classes, 21 test files, 12 runnable examples. 5-platform native library: linux-x86_64, linux-aarch64, macos-x86_64, macos-aarch64, windows-x86_64. JPMS module: dev.foliopdf
0 parents  commit 749eeac

127 files changed

Lines changed: 15358 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitattributes

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#
2+
# https://help.github.com/articles/dealing-with-line-endings/
3+
#
4+
# Linux start script should use lf
5+
/gradlew text eol=lf
6+
7+
# These are Windows script files and should use crlf
8+
*.bat text eol=crlf
9+
10+
# Binary files should be left untouched
11+
*.jar binary
12+
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
name: Build Native Libraries
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
folio_ref:
7+
description: 'Git ref of folio Go repo to build'
8+
required: false
9+
default: 'main'
10+
11+
env:
12+
FOLIO_REPO: carlos7ags/folio
13+
14+
jobs:
15+
build-macos-arm64:
16+
runs-on: macos-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
- uses: actions/setup-go@v5
20+
with:
21+
go-version: '1.22'
22+
- name: Clone folio engine
23+
run: git clone --depth 1 --branch ${{ github.event.inputs.folio_ref }} https://github.com/${{ env.FOLIO_REPO }}.git folio-engine
24+
- name: Build libfolio.dylib (arm64)
25+
run: |
26+
cd folio-engine
27+
CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 go build -buildmode=c-shared -o libfolio.dylib ./export/
28+
- uses: actions/upload-artifact@v4
29+
with:
30+
name: native-macos-aarch64
31+
path: folio-engine/libfolio.dylib
32+
33+
build-macos-x86_64:
34+
runs-on: macos-13 # Intel runner
35+
steps:
36+
- uses: actions/checkout@v4
37+
- uses: actions/setup-go@v5
38+
with:
39+
go-version: '1.22'
40+
- name: Clone folio engine
41+
run: git clone --depth 1 --branch ${{ github.event.inputs.folio_ref }} https://github.com/${{ env.FOLIO_REPO }}.git folio-engine
42+
- name: Build libfolio.dylib (x86_64)
43+
run: |
44+
cd folio-engine
45+
CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 go build -buildmode=c-shared -o libfolio.dylib ./export/
46+
- uses: actions/upload-artifact@v4
47+
with:
48+
name: native-macos-x86_64
49+
path: folio-engine/libfolio.dylib
50+
51+
build-linux-x86_64:
52+
runs-on: ubuntu-latest
53+
steps:
54+
- uses: actions/checkout@v4
55+
- uses: actions/setup-go@v5
56+
with:
57+
go-version: '1.22'
58+
- name: Clone folio engine
59+
run: git clone --depth 1 --branch ${{ github.event.inputs.folio_ref }} https://github.com/${{ env.FOLIO_REPO }}.git folio-engine
60+
- name: Build libfolio.so (x86_64)
61+
run: |
62+
cd folio-engine
63+
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -buildmode=c-shared -o libfolio.so ./export/
64+
- uses: actions/upload-artifact@v4
65+
with:
66+
name: native-linux-x86_64
67+
path: folio-engine/libfolio.so
68+
69+
build-linux-aarch64:
70+
runs-on: ubuntu-latest
71+
steps:
72+
- uses: actions/checkout@v4
73+
- uses: actions/setup-go@v5
74+
with:
75+
go-version: '1.22'
76+
- name: Install cross-compiler
77+
run: sudo apt-get update && sudo apt-get install -y gcc-aarch64-linux-gnu
78+
- name: Clone folio engine
79+
run: git clone --depth 1 --branch ${{ github.event.inputs.folio_ref }} https://github.com/${{ env.FOLIO_REPO }}.git folio-engine
80+
- name: Build libfolio.so (aarch64)
81+
run: |
82+
cd folio-engine
83+
CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc go build -buildmode=c-shared -o libfolio.so ./export/
84+
- uses: actions/upload-artifact@v4
85+
with:
86+
name: native-linux-aarch64
87+
path: folio-engine/libfolio.so
88+
89+
build-windows-x86_64:
90+
runs-on: ubuntu-latest
91+
steps:
92+
- uses: actions/checkout@v4
93+
- uses: actions/setup-go@v5
94+
with:
95+
go-version: '1.22'
96+
- name: Install cross-compiler
97+
run: sudo apt-get update && sudo apt-get install -y gcc-mingw-w64-x86-64
98+
- name: Clone folio engine
99+
run: git clone --depth 1 --branch ${{ github.event.inputs.folio_ref }} https://github.com/${{ env.FOLIO_REPO }}.git folio-engine
100+
- name: Build folio.dll (x86_64)
101+
run: |
102+
cd folio-engine
103+
CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc go build -buildmode=c-shared -o folio.dll ./export/
104+
- uses: actions/upload-artifact@v4
105+
with:
106+
name: native-windows-x86_64
107+
path: folio-engine/folio.dll
108+
109+
bundle:
110+
needs: [build-macos-arm64, build-macos-x86_64, build-linux-x86_64, build-linux-aarch64, build-windows-x86_64]
111+
runs-on: ubuntu-latest
112+
steps:
113+
- uses: actions/checkout@v4
114+
115+
- uses: actions/download-artifact@v4
116+
with:
117+
name: native-macos-aarch64
118+
path: lib/src/main/resources/natives/macos-aarch64/
119+
120+
- uses: actions/download-artifact@v4
121+
with:
122+
name: native-macos-x86_64
123+
path: lib/src/main/resources/natives/macos-x86_64/
124+
125+
- uses: actions/download-artifact@v4
126+
with:
127+
name: native-linux-x86_64
128+
path: lib/src/main/resources/natives/linux-x86_64/
129+
130+
- uses: actions/download-artifact@v4
131+
with:
132+
name: native-linux-aarch64
133+
path: lib/src/main/resources/natives/linux-aarch64/
134+
135+
- uses: actions/download-artifact@v4
136+
with:
137+
name: native-windows-x86_64
138+
path: lib/src/main/resources/natives/windows-x86_64/
139+
140+
- name: List bundled natives
141+
run: find lib/src/main/resources/natives -type f
142+
143+
- uses: actions/upload-artifact@v4
144+
with:
145+
name: natives-all
146+
path: lib/src/main/resources/natives/

.github/workflows/ci.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
os: [ubuntu-latest, macos-latest, windows-latest]
15+
runs-on: ${{ matrix.os }}
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- uses: actions/setup-java@v4
20+
with:
21+
distribution: temurin
22+
java-version: 22
23+
24+
- uses: gradle/actions/setup-gradle@v4
25+
26+
- name: Build
27+
run: ./gradlew compileJava
28+
29+
- name: Test
30+
run: ./gradlew test
31+
32+
- name: Javadoc
33+
if: matrix.os == 'ubuntu-latest'
34+
run: ./gradlew javadoc --no-configuration-cache
35+
36+
- name: Verify binding count
37+
shell: bash
38+
run: |
39+
count=$(grep -c 'downcall("folio_' lib/src/main/java/dev/foliopdf/internal/FolioNative.java)
40+
echo "Panama bindings: $count"
41+
if [ "$count" -lt 370 ]; then
42+
echo "ERROR: Expected 370+ bindings, got $count"
43+
exit 1
44+
fi
45+
46+
- name: Upload test results
47+
if: always()
48+
uses: actions/upload-artifact@v4
49+
with:
50+
name: test-results-${{ matrix.os }}
51+
path: lib/build/reports/tests/

.github/workflows/publish.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Publish to Maven Central
2+
3+
on:
4+
push:
5+
tags: ['v*']
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
publish:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Set up JDK 22
17+
uses: actions/setup-java@v4
18+
with:
19+
distribution: temurin
20+
java-version: 22
21+
22+
- name: Setup Gradle
23+
uses: gradle/actions/setup-gradle@v4
24+
25+
- name: Set version from tag
26+
run: |
27+
VERSION="${GITHUB_REF_NAME#v}"
28+
sed -i "s/version = \".*\"/version = \"$VERSION\"/" lib/build.gradle.kts
29+
echo "VERSION=$VERSION" >> $GITHUB_ENV
30+
31+
- name: Verify native libraries are bundled
32+
run: |
33+
for platform in macos-aarch64 macos-x86_64 linux-x86_64 linux-aarch64 windows-x86_64; do
34+
dir="lib/src/main/resources/natives/$platform"
35+
if [ -z "$(ls -A $dir 2>/dev/null)" ]; then
36+
echo "ERROR: No native library found in $dir"
37+
exit 1
38+
fi
39+
done
40+
echo "All native libraries present."
41+
42+
- name: Run tests
43+
run: ./gradlew test
44+
45+
- name: Stage to local repo
46+
run: ./gradlew publishMavenPublicationToMavenLocal
47+
env:
48+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_SIGNING_KEY }}
49+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_SIGNING_PASSWORD }}
50+
51+
- name: Publish to Maven Central Portal
52+
run: ./gradlew publishToMavenCentral
53+
env:
54+
ORG_GRADLE_PROJECT_mavenCentralToken: ${{ secrets.MAVEN_CENTRAL_TOKEN }}
55+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_SIGNING_KEY }}
56+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_SIGNING_PASSWORD }}

.github/workflows/release.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Release to Maven Central
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
release:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- uses: actions/setup-java@v4
18+
with:
19+
distribution: temurin
20+
java-version: 22
21+
22+
- uses: gradle/actions/setup-gradle@v4
23+
24+
- name: Verify native libraries are bundled
25+
run: |
26+
for platform in macos-aarch64 macos-x86_64 linux-x86_64 linux-aarch64 windows-x86_64; do
27+
dir="lib/src/main/resources/natives/$platform"
28+
if [ -z "$(ls -A $dir 2>/dev/null)" ]; then
29+
echo "ERROR: No native library found in $dir"
30+
exit 1
31+
fi
32+
done
33+
echo "All native libraries present."
34+
35+
- name: Set version from tag
36+
run: |
37+
VERSION="${GITHUB_REF_NAME#v}"
38+
sed -i "s/version = \".*\"/version = \"$VERSION\"/" lib/build.gradle.kts
39+
echo "VERSION=$VERSION" >> $GITHUB_ENV
40+
41+
- name: Build
42+
run: ./gradlew build
43+
44+
- name: Publish to Maven Central
45+
run: ./gradlew publishAllPublicationsToMavenCentralRepository
46+
env:
47+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
48+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
49+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_SIGNING_KEY }}
50+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_SIGNING_PASSWORD }}
51+
52+
- name: Create GitHub Release
53+
uses: softprops/action-gh-release@v2
54+
with:
55+
generate_release_notes: true
56+
files: |
57+
lib/build/libs/*.jar

.gitignore

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Gradle
2+
.gradle
3+
build
4+
.kotlin
5+
6+
# IDE
7+
.idea
8+
*.iml
9+
.vscode
10+
.project
11+
.classpath
12+
.settings
13+
14+
# Generated PDFs
15+
*.pdf
16+
17+
# Claude Code
18+
.claude/
19+
20+
# OS
21+
.DS_Store
22+
Thumbs.db

CHANGELOG.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [0.1.0] - 2026-04-09
9+
10+
First stable release of the Folio Java SDK, bundling the folio Go engine v0.6.2.
11+
12+
### Added
13+
14+
- 372 Panama FFI bindings to the folio Go engine (`dev.foliopdf.internal.FolioNative`)
15+
- 59 public API classes with fluent builders (`dev.foliopdf.*`)
16+
- Zero runtime dependencies -- requires JDK 22+ only
17+
- 5-platform native library bundled in the JAR: linux-x86_64, linux-aarch64, macos-x86_64, macos-aarch64, windows-x86_64
18+
- Document generation: paragraphs, headings, tables, divs, lists, images, links, line separators, area breaks
19+
- Advanced layout: Flexbox (`Flex`), CSS Grid (`Grid`), multi-column (`Columns`), float (`FloatElement`), tabbed lines (`TabbedLine`)
20+
- Barcodes: QR, Code128, EAN-13 (`Barcode`)
21+
- SVG parsing and rendering (`SvgElement`)
22+
- HTML-to-PDF conversion as a one-liner (`HtmlConverter.toPdf()`)
23+
- PDF reading: text extraction, metadata, page dimensions, structure tree (`PdfReader`)
24+
- PDF merge with page manipulation -- rotate, reorder, crop, remove (`PdfMerger`)
25+
- Page import for template workflows (`PageImport`)
26+
- Digital signatures: PAdES B-B through B-LTA with PEM and PKCS#12 support (`PdfSigner`, `PadesLevel`, `TsaClient`, `OcspClient`)
27+
- Form creation, filling, and flattening (`Form`, `FormField`, `FormFiller`)
28+
- PDF redaction -- text, regex, and region-based (`PdfRedactor`, `RedactRegion`, `RedactOpts`)
29+
- Encryption with granular permissions using AES-256, AES-128, or RC4 (`EncryptionAlgorithm`, `PdfPermission`)
30+
- PDF/A compliance at levels 1-3 (B/U/A) with validation (`PdfALevel`)
31+
- Tagged PDF / PDF/UA support: alt text, custom structure tags, structure tree reading
32+
- Drawing primitives on pages: lines, rectangles (`Page`)
33+
- Text highlighting via TextRun background color
34+
- CSS length parsing utility (`CssLength`)
35+
- Headers and footers with page number placeholders (`PageDecorator`)
36+
- `OutputStream`, `InputStream`, and `Path` API support on `Document`, `PdfReader`, `HtmlConverter`, and `Font`
37+
- 12 runnable examples: Hello, Report, Invoice, HtmlToPdf, Merge, Forms, Fonts, Links, ZugferdInvoice, Redact, ImportPage, Sign
38+
39+
[0.1.0]: https://github.com/carlos7ags/folio-java/releases/tag/v0.1.0

0 commit comments

Comments
 (0)