{"id":50436727,"url":"https://github.com/carlos7ags/folio-java","last_synced_at":"2026-05-31T17:03:02.292Z","repository":{"id":350246192,"uuid":"1205876247","full_name":"carlos7ags/folio-java","owner":"carlos7ags","description":"Java PDF generation, signing, and processing library. Apache 2.0 licensed.","archived":false,"fork":false,"pushed_at":"2026-05-23T13:57:13.000Z","size":54668,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-23T15:26:55.196Z","etag":null,"topics":["apache-license","digital-signatures","html-to-pdf","java","panama-ffi","pdf","pdf-converter","pdf-generation","pdf-library","pdf-parser"],"latest_commit_sha":null,"homepage":"https://foliopdf.dev","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/carlos7ags.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":"NOTICE","maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-09T11:15:39.000Z","updated_at":"2026-05-23T13:57:17.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/carlos7ags/folio-java","commit_stats":null,"previous_names":["carlos7ags/folio-java"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/carlos7ags/folio-java","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carlos7ags%2Ffolio-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carlos7ags%2Ffolio-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carlos7ags%2Ffolio-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carlos7ags%2Ffolio-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/carlos7ags","download_url":"https://codeload.github.com/carlos7ags/folio-java/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carlos7ags%2Ffolio-java/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33739861,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-31T02:00:06.040Z","response_time":95,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apache-license","digital-signatures","html-to-pdf","java","panama-ffi","pdf","pdf-converter","pdf-generation","pdf-library","pdf-parser"],"created_at":"2026-05-31T17:03:01.547Z","updated_at":"2026-05-31T17:03:02.283Z","avatar_url":"https://github.com/carlos7ags.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Folio Java SDK\n\n[![CI](https://github.com/carlos7ags/folio-java/actions/workflows/ci.yml/badge.svg)](https://github.com/carlos7ags/folio-java/actions/workflows/ci.yml)\n[![Maven Central](https://img.shields.io/maven-central/v/dev.foliopdf/folio-java)](https://central.sonatype.com/artifact/dev.foliopdf/folio-java)\n[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)\n[![JDK](https://img.shields.io/badge/JDK-22%2B-orange.svg)](https://openjdk.org/projects/jdk/22/)\n\nA fluent Java API for PDF generation, signing, and processing. Backed by the [Folio](https://github.com/carlos7ags/folio) Go engine via [Panama FFI](https://openjdk.org/jeps/454). Apache 2.0 licensed.\n\n**Requires JDK 22+** | Zero runtime dependencies | Bundles folio engine v0.7.1 | [foliopdf.dev](https://foliopdf.dev) | [Playground](https://playground.foliopdf.dev)\n\n## Requirements\n\nFolio uses the [Foreign Function \u0026 Memory API](https://openjdk.org/jeps/454) (Panama FFI) to call into the native engine. This requires two things:\n\n1. **JDK 22 or later** (Temurin, Corretto, GraalVM, or any OpenJDK distribution)\n2. The JVM flag `--enable-native-access=ALL-UNNAMED`\n\n**Gradle:**\n```kotlin\ntasks.withType\u003cJavaExec\u003e {\n    jvmArgs(\"--enable-native-access=ALL-UNNAMED\")\n}\n```\n\n**Maven (Surefire / exec-maven-plugin):**\n```xml\n\u003cargLine\u003e--enable-native-access=ALL-UNNAMED\u003c/argLine\u003e\n```\n\n**Command line:**\n```bash\njava --enable-native-access=ALL-UNNAMED -jar myapp.jar\n```\n\nNative libraries for Linux (x86_64, ARM64), macOS (x86_64, ARM64), and Windows (x86_64) are bundled in the JAR and extracted automatically at runtime.\n\n## Quick start\n\n```xml\n\u003c!-- Maven --\u003e\n\u003cdependency\u003e\n    \u003cgroupId\u003edev.foliopdf\u003c/groupId\u003e\n    \u003cartifactId\u003efolio-java\u003c/artifactId\u003e\n    \u003cversion\u003e0.2.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n```kotlin\n// Gradle\nimplementation(\"dev.foliopdf:folio-java:0.2.0\")\n```\n\n## Usage\n\n### Create a PDF\n\nThe simplest way to create a PDF:\n\n```java\nDocument.create(\"report.pdf\", doc -\u003e {\n    doc.add(Heading.of(\"Q3 Report\", HeadingLevel.H1));\n    doc.add(Paragraph.of(\"Revenue grew 23% year over year.\"));\n    doc.add(Table.of(\n        new String[]{\"Product\", \"Units\", \"Revenue\"},\n        new String[]{\"Widget A\", \"1,200\", \"$48,000\"},\n        new String[]{\"Widget B\", \"850\", \"$34,000\"}\n    ));\n});\n```\n\nFor more control, use the builder:\n\n```java\ntry (var doc = Document.builder()\n        .a4()\n        .title(\"Q3 Report\")\n        .margins(36)\n        .build()) {\n\n    doc.add(Heading.of(\"Q3 Report\", HeadingLevel.H1));\n    doc.add(Paragraph.of(\"Revenue grew 23% year over year.\"));\n    doc.save(\"report.pdf\");\n}\n```\n\n### HTML to PDF\n\n```java\nHtmlConverter.toPdf(\"\u003ch1\u003eInvoice\u003c/h1\u003e\u003cp\u003eDue: $1,200\u003c/p\u003e\", \"invoice.pdf\");\n\n// Or get bytes directly for HTTP responses\nbyte[] pdf = HtmlConverter.toBytes(\"\u003ch1\u003eHello\u003c/h1\u003e\u003cp\u003eWorld\u003c/p\u003e\");\n```\n\n### Read an existing PDF\n\n```java\ntry (var reader = PdfReader.open(\"input.pdf\")) {\n    System.out.println(\"Pages: \" + reader.pageCount());\n    System.out.println(\"Title: \" + reader.title());\n    System.out.println(\"Text: \" + reader.extractAllText());\n}\n```\n\n### Merge PDFs\n\n```java\nPdfMerger.merge(\"annual.pdf\", \"q3-report.pdf\", \"q4-report.pdf\");\n```\n\nOr with more control:\n\n```java\ntry (var r1 = PdfReader.open(\"report-q3.pdf\");\n     var r2 = PdfReader.open(\"report-q4.pdf\");\n     var merged = PdfMerger.merge(r1, r2)) {\n    merged.setInfo(\"Annual Report\", \"ACME Corp\");\n    merged.save(\"annual.pdf\");\n}\n```\n\n### Digital signatures\n\nSign with PAdES B-B through B-LTA:\n\n```java\ntry (var signer = PdfSigner.fromPem(keyPem, certPem)) {\n    byte[] signed = signer.sign(pdfBytes, PadesLevel.B_B, opts -\u003e opts\n        .name(\"Jane Doe\")\n        .reason(\"Approval\")\n        .location(\"Berlin\"));\n    Files.write(Path.of(\"signed.pdf\"), signed);\n}\n```\n\n### Redaction\n\nPermanently remove sensitive text from PDFs:\n\n```java\ntry (var reader = PdfReader.open(\"confidential.pdf\");\n     var opts = PdfRedactor.opts().fillColor(0, 0, 0).stripMetadata(true)) {\n    byte[] redacted = PdfRedactor.text(reader, List.of(\"SSN: 123-45-6789\"), opts);\n    Files.write(Path.of(\"redacted.pdf\"), redacted);\n}\n```\n\n### Headers and footers\n\n```java\ndoc.setHeaderText(\"CONFIDENTIAL\", Font.helvetica(), 9, Align.RIGHT);\ndoc.setFooterText(\"Page {page} of {pages}\", Font.helvetica(), 8, Align.CENTER);\n```\n\nFor full control, use callbacks:\n\n```java\ndoc.header((pageIndex, totalPages, page) -\u003e\n    page.addText(\"Custom header\", Font.helvetica(), 9, 72, 20));\n```\n\n### Flexbox layout\n\n```java\nvar flex = Flex.of()\n    .direction(FlexDirection.ROW)\n    .gap(10)\n    .justifyContent(JustifyContent.SPACE_BETWEEN);\nflex.add(Paragraph.of(\"Left\"));\nflex.add(Paragraph.of(\"Right\"));\ndoc.add(flex);\n```\n\n### Grid layout\n\n```java\nvar grid = Grid.of()\n    .templateColumns(\n        new GridTrackType[]{GridTrackType.FR, GridTrackType.FR},\n        new double[]{1, 2})\n    .gap(10, 10);\ngrid.addChild(Paragraph.of(\"Narrow column\"));\ngrid.addChild(Paragraph.of(\"Wide column\"));\ndoc.add(grid);\n```\n\n### Barcodes and QR codes\n\n```java\ntry (var qr = Barcode.qr(\"https://example.com\", 150)) {\n    qr.align(Align.CENTER);\n    doc.add(qr);\n}\n```\n\n### SVG\n\n```java\ntry (var svg = SvgElement.parse(\"\u003csvg\u003e...\u003c/svg\u003e\")) {\n    svg.size(200, 200);\n    doc.add(svg);\n}\n```\n\n### Forms\n\n```java\ntry (var form = Form.of()) {\n    form.addTextField(\"name\", 72, 700, 300, 720, 0);\n    form.addCheckbox(\"agree\", 72, 680, 90, 695, 0, false);\n    doc.form(form);\n}\n```\n\n### PDF/A and encryption\n\n```java\ndoc.pdfA(PdfALevel.PDF_A_3B);\ndoc.encryption(\"user-pass\", \"owner-pass\", EncryptionAlgorithm.AES_256);\n```\n\n### Writer optimizer (v0.7.1)\n\n`WriteOptions` exposes the per-feature toggles of the v0.7.1 PDF writer:\ncross-reference streams (ISO 32000-1 §7.5.8), object streams (§7.5.7),\norphan sweep, content-stream cleanup, object deduplication, and stream\nrecompression.\n\n```java\ntry (var doc = Document.builder().a4().build();\n     var opts = WriteOptions.builder()\n         .useXrefStream(true)\n         .useObjectStreams(true)\n         .objectStreamCapacity(64)\n         .deduplicateObjects(true)\n         .recompressStreams(true)\n         .build()) {\n    doc.add(Paragraph.of(\"Hello\"));\n    doc.saveWithOptions(\"optimized.pdf\", opts);\n}\n```\n\nBoth `Document.saveWithOptions(...)` and `Document.toBytesWithOptions(...)`\naccept `null` for the options argument to use engine defaults, so callers\nthat want a single optimized write do not need to allocate a `WriteOptions`\ninstance.\n\n### Right-to-left text (v0.7.1)\n\nSet the writing direction on paragraphs, lists, or tables with the\n`Direction` enum. `AUTO` defers to the Unicode Bidi algorithm; `LTR` and\n`RTL` force the direction.\n\n```java\ndoc.add(Paragraph.of(\"שלום עולם\").setDirection(Direction.RTL));\ndoc.add(ListElement.of().setDirection(Direction.AUTO).item(\"بند\"));\n\nvar table = Table.builder().row(\"الأول\", \"الثاني\", \"الثالث\").build();\ntable.setDirection(Direction.RTL);\ndoc.add(table);\n```\n\nRTL tables reverse the visual column order; RTL lists place markers on\nthe right.\n\n### `/ActualText` toggle (v0.7.1)\n\nTagged-PDF output emits `/ActualText` entries on marked-content sequences\nby default (ISO 32000-1 §14.9.4). Disable them when accessibility is not\nrequired to reduce file size.\n\n```java\ndoc.tagged(true);\ndoc.setActualText(false);\n```\n\n### Balanced multi-column fill (v0.7.1)\n\n`Columns.setBalanced(true)` fills columns to roughly equal heights,\nmatching the CSS `column-fill: balance` model. The default is sequential\nfill (each column reaches full height before the next begins).\n\n```java\nvar cols = Columns.of(2).gap(20).setBalanced(true);\ncols.add(0, Paragraph.of(\"First fragment\"));\ncols.add(1, Paragraph.of(\"Second fragment\"));\ndoc.add(cols);\n```\n\n## Features\n\n| Feature | Status |\n|---------|--------|\n| Document creation (paragraphs, headings, tables, images) | ✅ |\n| Fluent builder API with `Document.create()` one-liner | ✅ |\n| HTML to PDF conversion | ✅ |\n| PDF reading and text extraction | ✅ |\n| PDF merging with page manipulation | ✅ |\n| Digital signatures (PAdES B-B through B-LTA) | ✅ |\n| PDF redaction (text, regex, regions) | ✅ |\n| Tagged PDF / PDF/UA accessibility | ✅ |\n| Page import for template workflows | ✅ |\n| Flexbox and CSS Grid layout | ✅ |\n| Multi-column layout (balanced or sequential) | ✅ |\n| Writer optimizer (xref streams, object streams, dedup) | ✅ |\n| Right-to-left text (paragraph, list, table) | ✅ |\n| `/ActualText` toggle for tagged PDFs | ✅ |\n| Barcodes (QR, Code128, EAN-13) | ✅ |\n| SVG rendering | ✅ |\n| Hyperlinks and internal navigation | ✅ |\n| Interactive forms (AcroForm) | ✅ |\n| Form filling and flattening | ✅ |\n| PDF/A compliance (1a/1b/2a/2b/2u/3b) | ✅ |\n| Password encryption (RC4, AES-128/256) | ✅ |\n| Granular permission flags | ✅ |\n| Watermarks | ✅ |\n| Headers and footers (text and callbacks) | ✅ |\n| Bookmarks and outlines | ✅ |\n| File attachments (PDF/A-3b) | ✅ |\n| Drawing primitives (lines, rectangles) | ✅ |\n| All 14 standard PDF fonts | ✅ |\n| Custom TTF font embedding | ✅ |\n| JPMS module support | ✅ |\n| Thread safety | ✅ |\n| Zero runtime dependencies | ✅ |\n\n## Element types\n\nAll layout elements implement the `Element` interface and can be added to a `Document`, `Div`, `Flex`, or `Grid`:\n\n`Paragraph` · `Heading` · `Table` · `Image` · `Div` · `ListElement` · `Link` · `Barcode` · `SvgElement` · `Flex` · `Grid` · `Columns` · `FloatElement` · `TabbedLine` · `LineSeparator` · `AreaBreak`\n\n## Examples\n\nThere are 12 runnable examples in the [`examples/`](examples/) directory:\n\n```bash\n./gradlew examples:run                                                    # Hello world\n./gradlew examples:run -PmainClass=dev.foliopdf.examples.Report           # Multi-page report\n./gradlew examples:run -PmainClass=dev.foliopdf.examples.Invoice          # HTML invoice\n./gradlew examples:run -PmainClass=dev.foliopdf.examples.HtmlToPdf        # HTML to PDF\n./gradlew examples:run -PmainClass=dev.foliopdf.examples.Merge            # PDF merging\n./gradlew examples:run -PmainClass=dev.foliopdf.examples.Sign             # Digital signatures\n./gradlew examples:run -PmainClass=dev.foliopdf.examples.Redact           # PDF redaction\n./gradlew examples:run -PmainClass=dev.foliopdf.examples.ImportPage       # Page import templates\n./gradlew examples:run -PmainClass=dev.foliopdf.examples.Forms            # Interactive forms\n./gradlew examples:run -PmainClass=dev.foliopdf.examples.Fonts            # Font showcase\n./gradlew examples:run -PmainClass=dev.foliopdf.examples.Links            # Hyperlinks and bookmarks\n./gradlew examples:run -PmainClass=dev.foliopdf.examples.ZugferdInvoice   # PDF/A-3B invoice\n```\n\n## Architecture\n\n```\nYour Java code\n      ↓\ndev.foliopdf.*                ← fluent public API (this SDK)\n      ↓\ndev.foliopdf.internal.*       ← Panama FFI bindings (372 method handles)\n      ↓\nlibfolio.so / .dylib / .dll   ← Folio Go engine (bundled in JAR)\n```\n\nAll calls into the native library are serialized through a lock for thread safety.\n\n## Building from source\n\n```bash\ngit clone https://github.com/carlos7ags/folio-java.git\ncd folio-java\n./gradlew build\n```\n\n## License\n\nApache 2.0. See [LICENSE](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarlos7ags%2Ffolio-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcarlos7ags%2Ffolio-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarlos7ags%2Ffolio-java/lists"}