Skip to content

Render form fields/annotations, strip catalog data, and embed JPEG in FlattenMode.FULL - #303

Merged
balazs-szucs merged 8 commits into
Stirling-Tools:mainfrom
balazs-szucs:fix/flatten-full-fidelity
Nov 21, 2026
Merged

balazs-szucs merged 8 commits into
Stirling-Tools:mainfrom
balazs-szucs:fix/flatten-full-fidelity

Conversation

@balazs-szucs

@balazs-szucs balazs-szucs commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Description of Changes

Fixes FlattenMode.FULL to render filled AcroForm fields and non-printing annotations, strip original catalog data (/AcroForm, outlines, embedded attachments), and embed rasterized pages as JPEG instead of Flate-compressed raw bitmaps.


Checklist

General

  • I have read the Contributing Guide
  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • Notable user-facing changes are recorded under ## [Unreleased] in CHANGELOG.md

Library changes

  • Javadoc covers any new or changed public type or member
  • Public API changes are additive, or .github/workflows/compatibility.yml excludes the break with a reason
  • Version references stay consistent across the README, docs/installation.md, and the POMs

Native or FFM changes

  • Rebuilt the bridge with bash native/build-real.sh
  • Ran ./gradlew :jpdfium:integrationTest
  • Updated native/bridge/include/jpdfium.h and the ABI notes for any ABI change

Testing

  • Added or updated tests that cover the change
  • ./gradlew test passes

@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Explain Change →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • Resume reviews
  • Trigger review
Summary

Summary by CodeRabbit

  • New Features
    • Full-document flattening converts pages into JPEG images at the selected DPI. Higher DPI can preserve more detail, while lower DPI may produce smaller files.
    • You can choose whether to include non-printable annotations when flattening. By default, these annotations are included.
  • Changes
    • Flattened documents no longer retain interactive form fields, bookmarks, or attachments.
    • Full flattening now returns an error for secured PDFs.

Full flattening renders pages at the requested DPI, encodes them as JPEG, replaces them through native bridge operations, and rebuilds the document. A new overload controls whether rendering includes non-printable annotations. The OSV scan now uses a configuration file with a vulnerability ignore entry.

Changes: Full PDF flattening

Layer / File(s) Summary
Native page operations
native/bridge/include/jpdfium.h, native/bridge/src/jpdfium_render.cpp, native/bridge/src/jpdfium_stub.cpp
The native bridge adds document rebuilding and JPEG page replacement. The replacement path validates inputs and page indices, and deletes the original page only after importing the replacement succeeds.
Java bindings for native operations
jpdfium/src/main/java/stirling/software/jpdfium/panama/JpdfiumH.java, jpdfium/src/main/java/stirling/software/jpdfium/panama/JpdfiumLib.java, jpdfium/build.gradle.kts, jpdfium/src/main/resources/META-INF/native-image/com.stirling/jpdfium/reachability-metadata.json, reachability-metadata/metadata/com.stirling/jpdfium/1.2.0/reachability-metadata.json
Java bindings expose the native rebuild and page-replacement operations. The build binding list and reachability metadata include the new downcalls.
Java flattening and validation
jpdfium/src/main/java/stirling/software/jpdfium/PdfDocument.java, jpdfium/src/main/java/stirling/software/jpdfium/PdfPage.java, jpdfium/src/test/java/stirling/software/jpdfium/FlattenApiTest.java
Full document flattening renders and encodes each page as JPEG at quality 0.85, replaces the pages, rebuilds the document, and invalidates open page handles. The new overload controls whether rendering includes non-printable annotations. Full flattening rejects encrypted documents. Page-level full flattening also replaces the page with JPEG data. Tests check document structures and output size at different DPIs.

OSV scanner configuration

Layer / File(s) Summary
Configure OSV vulnerability scan
.github/workflows/security.yml, osv-scanner.toml
The workflow passes osv-scanner.toml to the recursive scan. The configuration ignores RUSTSEC-2026-0543 and records the stated reason.

Possibly related issues

  • Stirling-Tools/JPDFium#191 — This change renders filled form fields and non-printable annotations in the full-flattening path. The issue also covers other operations that this change does not modify.

Possibly related PRs

Change: Bug fix

Merge Risk: Moderate · previous review 4f3d4

FlattenMode.FULL may bake hidden annotations into the output, and several partial-failure, memory and test-coverage concerns remain open. The OSV security scan is also likely misconfigured and may fail in CI. Resolve these before merging.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the three main changes: rendering form fields and annotations, stripping catalog data, and embedding JPEG in FlattenMode.FULL. The changeset matches these points: per-page JPEG replace…
Description check Passed The description states the purpose of the change: FULL flattening renders AcroForm fields and non-printing annotations, strips catalog data, and embeds JPEG pages. It uses the template headings and mo…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the three main changes: rendering form fields and annotations, stripping catalog data, and embedding JPEG in FlattenMode.FULL. The changeset matches these points: per-page JPEG replacement in FULL mode, annotation and widget baking, and removal of catalog data such as /AcroForm and outlines. The title is long (86 characters) but accurate.

Full details: Description check

Explanation

The description states the purpose of the change: FULL flattening renders AcroForm fields and non-printing annotations, strips catalog data, and embeds JPEG pages. It uses the template headings and most checklist items. Two items are unchecked: the CHANGELOG.md entry under Unreleased and the integration test run (./gradlew :jpdfium:integrationTest). The description does not link an issue, although the template asks for one.

Resolution

Before merge, the author should: (1) add a CHANGELOG.md entry under ## [Unreleased] for the user-facing change to FlattenMode.FULL, or confirm none is needed; (2) run ./gradlew :jpdfium:integrationTest, since the native bridge and FFM bindings changed, and check the box or state why it was skipped; (3) add a 'Closes #' issue reference if one exists.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

coderabbitai[bot]

This comment was marked as resolved.

@balazs-szucs balazs-szucs changed the title fix(flatten): render form fields/annotations, strip catalog data, and embed JPEG in FlattenMode.FULL Render form fields/annotations, strip catalog data, and embed JPEG in FlattenMode.FULL Nov 18, 2026
@balazs-szucs
balazs-szucs force-pushed the fix/flatten-full-fidelity branch from bf8bc47 to ab14699 Compare November 18, 2026 17:36
coderabbitai[bot]

This comment was marked as resolved.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between ab14699 and 42325dc.

Files selected for processing: 4

  • jpdfium/src/main/java/stirling/software/jpdfium/PdfDocument.java
  • jpdfium/src/main/java/stirling/software/jpdfium/PdfPage.java
  • jpdfium/src/main/resources/META-INF/native-image/com.stirling/jpdfium/reachability-metadata.json
  • native/bridge/src/jpdfium_render.cpp

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Review details

Context from checks skipped due to timeout: 22

  • GitHub Check: build-natives (windows-arm64, windows-11-arm)
  • GitHub Check: build-natives (windows-x64, windows-latest)
  • GitHub Check: build-natives (freebsd-x64, ubuntu-latest)
  • GitHub Check: build-natives (linux-x64, ubuntu-24.04)
  • GitHub Check: build-natives (linux-arm64, ubuntu-24.04-arm)
  • GitHub Check: build-natives (darwin-x64, macos-15-intel, 78)
  • GitHub Check: build-natives (linux-musl-arm64, ubuntu-24.04-arm, musl)
  • GitHub Check: build-natives (linux-musl-x64, ubuntu-latest, musl)
  • GitHub Check: build-natives (darwin-arm64, macos-15, 79)
  • GitHub Check: CodeRabbit
  • GitHub Check: build-natives (darwin-x64, macos-15-intel)
  • GitHub Check: build-natives (windows-arm64, windows-11-arm)
  • GitHub Check: CodeQL Analysis (java-kotlin)
  • GitHub Check: Build patched PDFium and run Ghent V50
  • GitHub Check: CodeQL (java-kotlin)
  • GitHub Check: GraalVM Native Image Smoke & E2E Test (Linux x64)
  • GitHub Check: Corpus (generate + native)
  • GitHub Check: JMH Benchmarks (advisory)
  • GitHub Check: CodeQL Analysis (c-cpp)
  • GitHub Check: CLI correctness & no-corruption tests
  • GitHub Check: Restricted-env compat (no execstack + hermetic bundle)
  • GitHub Check: Native bridge libFuzzer (ASan/UBSan, real PDFium)
CI failures not shown inline: 14

GitHub Actions: Coverage / 0_JaCoCo coverage (non-blocking ratchet).txt: Render form fields/annotations, strip catalog data, and embed JPEG in FlattenMode.FULL

Conclusion: failure

View job details

##[group]Run ./gradlew :jpdfium:test :jpdfium:jacocoTestReport --no-daemon
 �[36;1m./gradlew :jpdfium:test :jpdfium:jacocoTestReport --no-daemon�[0m
 �[36;1mtest -f jpdfium/build/reports/jacoco/test/jacocoTestReport.xml || {�[0m
 �[36;1m  echo "::error::JaCoCo report missing - coverage gate cannot run"�[0m
...
 You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
 For more on this, please refer to https://docs.gradle.org/9.9.0/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
 21 actionable tasks: 15 executed, 6 from cache
 ##[error]Process completed with exit code 1.

GitHub Actions: Coverage / JaCoCo coverage (non-blocking ratchet): Render form fields/annotations, strip catalog data, and embed JPEG in FlattenMode.FULL

Conclusion: failure

View job details

##[group]Run ./gradlew :jpdfium:test :jpdfium:jacocoTestReport --no-daemon
 �[36;1m./gradlew :jpdfium:test :jpdfium:jacocoTestReport --no-daemon�[0m
 �[36;1mtest -f jpdfium/build/reports/jacoco/test/jacocoTestReport.xml || {�[0m
 �[36;1m  echo "::error::JaCoCo report missing - coverage gate cannot run"�[0m
...
 You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
 For more on this, please refer to https://docs.gradle.org/9.9.0/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
 21 actionable tasks: 15 executed, 6 from cache
 ##[error]Process completed with exit code 1.

GitHub Actions: Static Analysis / 1_Java - SpotBugs + Checkstyle + PMD + Spotless.txt: Render form fields/annotations, strip catalog data, and embed JPEG in FlattenMode.FULL

Conclusion: failure

View job details

m/src/test/java/stirling/software/jpdfium/corpus/PathologicalPdfFactory.java:207:	ConsecutiveAppendsShouldReuse:	StringBuffer (or StringBuilder).append is called consecutively without reusing the target variable.
 /home/runner/work/JPDFium/JPDFium/jpdfium/src/test/java/stirling/software/jpdfium/corpus/PathologicalPdfFactory.java:208:	ConsecutiveAppendsShouldReuse:	StringBuffer (or StringBuilder).append is called consecutively without reusing the target variable.
 /home/runner/work/JPDFium/JPDFium/jpdfium/src/test/java/stirling/software/jpdfium/corpus/PathologicalPdfFactory.java:215:	InsufficientStringBufferDeclaration:	StringBuilder has been initialized with size 25, but has at least 182 characters appended.
 /home/runner/work/JPDFium/JPDFium/jpdfium/src/test/java/stirling/software/jpdfium/corpus/PathologicalPdfFactory.java:215:	ConsecutiveLiteralAppends:	StringBuffer (or StringBuilder).append is called 2 consecutive times with literals. Use a single append with a single combined String.
 /home/runner/work/JPDFium/JPDFium/jpdfium/src/test/java/stirling/software/jpdfium/corpus/PathologicalPdfFactory.java:229:	InsufficientStringBufferDeclaration:	StringBuilder has been initialized with size 25, but has at least 172 characters appended.
 /home/runner/work/JPDFium/JPDFium/jpdfium/src/test/java/stirling/software/jpdfium/corpus/PathologicalPdfFactory.java:229:	ConsecutiveLiteralAppends:	StringBuffer (or StringBuilder).append is called 4 consecutive times with literals. Use a single append with a single combined String.
 /home/runner/work/JPDFium/JPDFium/jpdfium/src/test/java/stirling/software/jpdfium/corpus/PathologicalPdfFactory.java:230:	ConsecutiveAppendsShouldReuse:	StringBuffer (or StringBuilder).append is called consecutively without reusing the target variable.
 /home/runner/work/JPDFium/JPDFium/jpdfium/src/test/java/stirling/software/jpdfium/corpus/PathologicalPdfFactory.java:231:	ConsecutiveAppendsShouldReuse:	StringBuffer (or StringBuilder).append is called c...

GitHub Actions: Static Analysis / Java - SpotBugs + Checkstyle + PMD + Spotless: Render form fields/annotations, strip catalog data, and embed JPEG in FlattenMode.FULL

Conclusion: failure

View job details

m/src/test/java/stirling/software/jpdfium/corpus/PathologicalPdfFactory.java:207:	ConsecutiveAppendsShouldReuse:	StringBuffer (or StringBuilder).append is called consecutively without reusing the target variable.
 /home/runner/work/JPDFium/JPDFium/jpdfium/src/test/java/stirling/software/jpdfium/corpus/PathologicalPdfFactory.java:208:	ConsecutiveAppendsShouldReuse:	StringBuffer (or StringBuilder).append is called consecutively without reusing the target variable.
 /home/runner/work/JPDFium/JPDFium/jpdfium/src/test/java/stirling/software/jpdfium/corpus/PathologicalPdfFactory.java:215:	InsufficientStringBufferDeclaration:	StringBuilder has been initialized with size 25, but has at least 182 characters appended.
 /home/runner/work/JPDFium/JPDFium/jpdfium/src/test/java/stirling/software/jpdfium/corpus/PathologicalPdfFactory.java:215:	ConsecutiveLiteralAppends:	StringBuffer (or StringBuilder).append is called 2 consecutive times with literals. Use a single append with a single combined String.
 /home/runner/work/JPDFium/JPDFium/jpdfium/src/test/java/stirling/software/jpdfium/corpus/PathologicalPdfFactory.java:229:	InsufficientStringBufferDeclaration:	StringBuilder has been initialized with size 25, but has at least 172 characters appended.
 /home/runner/work/JPDFium/JPDFium/jpdfium/src/test/java/stirling/software/jpdfium/corpus/PathologicalPdfFactory.java:229:	ConsecutiveLiteralAppends:	StringBuffer (or StringBuilder).append is called 4 consecutive times with literals. Use a single append with a single combined String.
 /home/runner/work/JPDFium/JPDFium/jpdfium/src/test/java/stirling/software/jpdfium/corpus/PathologicalPdfFactory.java:230:	ConsecutiveAppendsShouldReuse:	StringBuffer (or StringBuilder).append is called consecutively without reusing the target variable.
 /home/runner/work/JPDFium/JPDFium/jpdfium/src/test/java/stirling/software/jpdfium/corpus/PathologicalPdfFactory.java:231:	ConsecutiveAppendsShouldReuse:	StringBuffer (or StringBuilder).append is called c...

GitHub Actions: Compatibility / 0_FFM layout vs pinned PDFium headers.txt: Render form fields/annotations, strip catalog data, and embed JPEG in FlattenMode.FULL

Conclusion: failure

View job details

##[group]Run bash native/build-stub.sh
 �[36;1mbash native/build-stub.sh�[0m
 �[36;1m./gradlew :jpdfium:generateBindings :jpdfium:patchBindingsForCrossPlatform --no-daemon�[0m
 �[36;1m# Verify the committed JpdfiumH.java files match the regenerated output.�[0m
 �[36;1mif git diff --quiet -- jpdfium/src/main/java/stirling/software/jpdfium/panama/; then�[0m
 �[36;1m  echo "FFM bindings are in sync with native/bridge/include/jpdfium.h"�[0m
 �[36;1melse�[0m
 �[36;1m  echo "::error::FFM bindings drift from jpdfium.h — run ./gradlew :jpdfium:generateBindings :jpdfium:patchBindingsForCrossPlatform locally and commit the result"�[0m
...
 For more on this, please refer to https://docs.gradle.org/9.9.0/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
 BUILD SUCCESSFUL in 12s
 12 actionable tasks: 6 executed, 6 from cache
 Consider enabling configuration cache to speed up this build: https://docs.gradle.org/9.9.0/userguide/configuration_cache_enabling.html
 ##[error]FFM bindings drift from jpdfium.h — run ./gradlew :jpdfium:generateBindings :jpdfium:patchBindingsForCrossPlatform locally and commit the result
...
 -    }
 -
      private static class jpdfium_doc_flatten_annotations {
          public static final FunctionDescriptor DESC = FunctionDescriptor.of(
              JpdfiumH.C_INT,
 ##[error]Process completed with exit code 1.

GitHub Actions: Compatibility / FFM layout vs pinned PDFium headers: Render form fields/annotations, strip catalog data, and embed JPEG in FlattenMode.FULL

Conclusion: failure

View job details

##[group]Run bash native/build-stub.sh
 �[36;1mbash native/build-stub.sh�[0m
 �[36;1m./gradlew :jpdfium:generateBindings :jpdfium:patchBindingsForCrossPlatform --no-daemon�[0m
 �[36;1m# Verify the committed JpdfiumH.java files match the regenerated output.�[0m
 �[36;1mif git diff --quiet -- jpdfium/src/main/java/stirling/software/jpdfium/panama/; then�[0m
 �[36;1m  echo "FFM bindings are in sync with native/bridge/include/jpdfium.h"�[0m
 �[36;1melse�[0m
 �[36;1m  echo "::error::FFM bindings drift from jpdfium.h — run ./gradlew :jpdfium:generateBindings :jpdfium:patchBindingsForCrossPlatform locally and commit the result"�[0m
...
 For more on this, please refer to https://docs.gradle.org/9.9.0/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
 BUILD SUCCESSFUL in 12s
 12 actionable tasks: 6 executed, 6 from cache
 Consider enabling configuration cache to speed up this build: https://docs.gradle.org/9.9.0/userguide/configuration_cache_enabling.html
 ##[error]FFM bindings drift from jpdfium.h — run ./gradlew :jpdfium:generateBindings :jpdfium:patchBindingsForCrossPlatform locally and commit the result
...
 -    }
 -
      private static class jpdfium_doc_flatten_annotations {
          public static final FunctionDescriptor DESC = FunctionDescriptor.of(
              JpdfiumH.C_INT,
 ##[error]Process completed with exit code 1.

GitHub Actions: Compatibility / 1_Public API compatibility (japicmp vs last release).txt: Render form fields/annotations, strip catalog data, and embed JPEG in FlattenMode.FULL

Conclusion: failure

View job details

##[group]Run BASE_JAR=/tmp/japicmp-baseline/jpdfium-baseline.jar
 �[36;1mBASE_JAR=/tmp/japicmp-baseline/jpdfium-baseline.jar�[0m
 �[36;1mCURR_JAR=$(find jpdfium/build/libs -name 'jpdfium-*.jar' ! -name '*-sources.jar' ! -name '*-javadoc.jar' | head -n1)�[0m
 �[36;1mtest -f "$BASE_JAR" || { echo "Baseline jar missing — skipping"; exit 0; }�[0m
 �[36;1mtest -f "$CURR_JAR" || { echo "Current jar missing — $CURR_JAR"; exit 1; }�[0m
 �[36;1mJAPICMP_VER=0.23.0�[0m
 �[36;1mcurl -fsSL --max-time 60 "https://repo1.maven.org/maven2/com/github/siom79/japicmp/japicmp/${JAPICMP_VER}/japicmp-${JAPICMP_VER}-jar-with-dependencies.jar" -o /tmp/japicmp.jar�[0m
 �[36;1mset +e  # japicmp exits non-zero on incompatibilities; handle below�[0m
 �[36;1m# Accepted breakage (whole-class removals only): NativeGuard was a�[0m
 �[36;1m# deprecated facade whose documented contract no longer holds (it�[0m
 �[36;1m# cannot admit the execution domain), it has no in-repo callers, and�[0m
 �[36;1m# removal turns cryptic runtime failures into clear compile errors�[0m
 �[36;1m# toward PdfiumRuntime. PdfAConverter was a Ghostscript-backed helper�[0m
 �[36;1m# removed together with the Ghostscript dependency; PDF/A conformance�[0m
 �[36;1m# handling now lives in the in-process compression pipeline (see�[0m
 �[36;1m# PdfCompressor). Both are removed classes, so a class-level exclude is�[0m
 �[36;1m# exact. The compression members and PdfEncryption.isQpdfAvailable()�[0m
 �[36;1m# that the overhaul had dropped were restored for binary compatibility,�[0m
 �[36;1m# so they are no longer excluded — every remaining type and member must�[0m
 �[36;1m# stay compatible. TextEditor was an empty placeholder (private�[0m
 �[36;1m# constructor, no methods) that was removed together with its package.�[0m
 �[36;1m# Nothing in the API, the tests, or the javadoc referenced it and it�[0m
 �[36;1m# could not be instantiated, so dropping it is an accepted, deliberate�[0m
 �[36;1m# break rather than one the gate should catc...

GitHub Actions: Compatibility / Public API compatibility (japicmp vs last release): Render form fields/annotations, strip catalog data, and embed JPEG in FlattenMode.FULL

Conclusion: failure

View job details

##[group]Run BASE_JAR=/tmp/japicmp-baseline/jpdfium-baseline.jar
 �[36;1mBASE_JAR=/tmp/japicmp-baseline/jpdfium-baseline.jar�[0m
 �[36;1mCURR_JAR=$(find jpdfium/build/libs -name 'jpdfium-*.jar' ! -name '*-sources.jar' ! -name '*-javadoc.jar' | head -n1)�[0m
 �[36;1mtest -f "$BASE_JAR" || { echo "Baseline jar missing — skipping"; exit 0; }�[0m
 �[36;1mtest -f "$CURR_JAR" || { echo "Current jar missing — $CURR_JAR"; exit 1; }�[0m
 �[36;1mJAPICMP_VER=0.23.0�[0m
 �[36;1mcurl -fsSL --max-time 60 "https://repo1.maven.org/maven2/com/github/siom79/japicmp/japicmp/${JAPICMP_VER}/japicmp-${JAPICMP_VER}-jar-with-dependencies.jar" -o /tmp/japicmp.jar�[0m
 �[36;1mset +e  # japicmp exits non-zero on incompatibilities; handle below�[0m
 �[36;1m# Accepted breakage (whole-class removals only): NativeGuard was a�[0m
 �[36;1m# deprecated facade whose documented contract no longer holds (it�[0m
 �[36;1m# cannot admit the execution domain), it has no in-repo callers, and�[0m
 �[36;1m# removal turns cryptic runtime failures into clear compile errors�[0m
 �[36;1m# toward PdfiumRuntime. PdfAConverter was a Ghostscript-backed helper�[0m
 �[36;1m# removed together with the Ghostscript dependency; PDF/A conformance�[0m
 �[36;1m# handling now lives in the in-process compression pipeline (see�[0m
 �[36;1m# PdfCompressor). Both are removed classes, so a class-level exclude is�[0m
 �[36;1m# exact. The compression members and PdfEncryption.isQpdfAvailable()�[0m
 �[36;1m# that the overhaul had dropped were restored for binary compatibility,�[0m
 �[36;1m# so they are no longer excluded — every remaining type and member must�[0m
 �[36;1m# stay compatible. TextEditor was an empty placeholder (private�[0m
 �[36;1m# constructor, no methods) that was removed together with its package.�[0m
 �[36;1m# Nothing in the API, the tests, or the javadoc referenced it and it�[0m
 �[36;1m# could not be instantiated, so dropping it is an accepted, deliberate�[0m
 �[36;1m# break rather than one the gate should catc...

GitHub Actions: Compatibility / 2_Module descriptor integrity.txt: Render form fields/annotations, strip catalog data, and embed JPEG in FlattenMode.FULL

Conclusion: failure

View job details

##[group]Run ./gradlew :jpdfium:jar --no-daemon
 �[36;1m./gradlew :jpdfium:jar --no-daemon�[0m
 �[36;1mJAR=$(find jpdfium/build/libs -name 'jpdfium-*.jar' ! -name '*-sources.jar' ! -name '*-javadoc.jar' | head -n1)�[0m
 �[36;1mecho "Describing module from $JAR"�[0m
 �[36;1mjar --describe-module --file="$JAR"�[0m
 �[36;1mXZ_JAR="$GITHUB_WORKSPACE/buildSrc/libs/xz-1.10.jar"�[0m
 �[36;1mif [ ! -f "$XZ_JAR" ]; then�[0m
 �[36;1m  echo "::error::vendored xz runtime jar is missing"�[0m
 �[36;1m  exit 1�[0m
 �[36;1mfi�[0m
 �[36;1mjdeps --multi-release 25 --module-path "$JAR:$XZ_JAR" -s "$JAR" 2>&1 | tee /tmp/jdeps.txt�[0m
 �[36;1mif grep -q "not found" /tmp/jdeps.txt; then�[0m
 �[36;1m  echo "::error::Module descriptor has missing dependencies"�[0m

GitHub Actions: Compatibility / Module descriptor integrity: Render form fields/annotations, strip catalog data, and embed JPEG in FlattenMode.FULL

Conclusion: failure

View job details

##[group]Run ./gradlew :jpdfium:jar --no-daemon
 �[36;1m./gradlew :jpdfium:jar --no-daemon�[0m
 �[36;1mJAR=$(find jpdfium/build/libs -name 'jpdfium-*.jar' ! -name '*-sources.jar' ! -name '*-javadoc.jar' | head -n1)�[0m
 �[36;1mecho "Describing module from $JAR"�[0m
 �[36;1mjar --describe-module --file="$JAR"�[0m
 �[36;1mXZ_JAR="$GITHUB_WORKSPACE/buildSrc/libs/xz-1.10.jar"�[0m
 �[36;1mif [ ! -f "$XZ_JAR" ]; then�[0m
 �[36;1m  echo "::error::vendored xz runtime jar is missing"�[0m
 �[36;1m  exit 1�[0m
 �[36;1mfi�[0m
 �[36;1mjdeps --multi-release 25 --module-path "$JAR:$XZ_JAR" -s "$JAR" 2>&1 | tee /tmp/jdeps.txt�[0m
 �[36;1mif grep -q "not found" /tmp/jdeps.txt; then�[0m
 �[36;1m  echo "::error::Module descriptor has missing dependencies"�[0m

GitHub Actions: E2E / 0_Flaky-test guard (3× rerun).txt: Render form fields/annotations, strip catalog data, and embed JPEG in FlattenMode.FULL

Conclusion: failure

View job details

##[group]Run for i in 1 2 3; do
 �[36;1mfor i in 1 2 3; do�[0m
 �[36;1m  echo "=== run $i/3 ==="�[0m
 �[36;1m  ./gradlew :jpdfium:test --rerun-tasks --no-daemon || exit 1�[0m
 �[36;1mdone�[0m
 �[36;1mecho "No flake in 3 runs"�[0m
 shell: /usr/bin/bash -e {0}
 env:
   JAVA_HOME: /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/25.0.5-8/x64
   JAVA_HOME_25_X64: /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/25.0.5-8/x64
   MAVEN_ARGS: -ntp
   JEXTRACT_HOME: /home/runner/jextract-install
   GRADLE_ACTION_ID: gradle/actions/setup-gradle
   GRADLE_USER_HOME: /home/runner/.gradle
   GRADLE_BUILD_ACTION_SETUP_COMPLETED: true
   DEVELOCITY_INJECTION_INIT_SCRIPT_NAME: gradle-actions.inject-develocity.init.gradle
   DEVELOCITY_INJECTION_CUSTOM_VALUE: gradle-actions
   GITHUB_DEPENDENCY_GRAPH_ENABLED: false
 ##[endgroup]
 === run 1/3 ===
 To honour the JVM settings for this build a single-use Daemon process will be forked. For more on this, please refer to https://docs.gradle.org/9.9.0/userguide/gradle_daemon.html#sec:disabling_the_daemon in the Gradle documentation.
 Daemon will be stopped at the end of the build
 > Task :buildSrc:checkKotlinCompilerVersion
 > Task :buildSrc:checkKotlinGradlePluginConfigurationErrors SKIPPED
 > Task :buildSrc:generateExternalPluginSpecBuilders
 > Task :buildSrc:extractPrecompiledScriptPluginPlugins
 > Task :buildSrc:generateScriptPluginAdapters
 > Task :buildSrc:pluginDescriptors
 > Task :buildSrc:processResources
 > Task :buildSrc:compilePluginsBlocks
 > Task :buildSrc:generatePrecompiledScriptPluginAccessors
 > Task :buildSrc:compileKotlin
 > Task :buildSrc:compileJava NO-SOURCE
 > Task :buildSrc:compileGroovy NO-SOURCE
 > Task :buildSrc:classes
 > Task :buildSrc:jar
 > Task :jpdfium:compileJava
 > Task :jpdfium:writeVersionProperties
 > Task :jpdfium:processResources
 > Task :jpdfium:classes
 > Task :jpdfium:compileTestJava
 > Task :jpdfium:processTestResources
 > Task :jpdfium:testClasses
 > Task :jpdfium-natives:jpdfium-natives-linux-x64:...

GitHub Actions: E2E / Flaky-test guard (3× rerun): Render form fields/annotations, strip catalog data, and embed JPEG in FlattenMode.FULL

Conclusion: failure

View job details

##[group]Run for i in 1 2 3; do
 �[36;1mfor i in 1 2 3; do�[0m
 �[36;1m  echo "=== run $i/3 ==="�[0m
 �[36;1m  ./gradlew :jpdfium:test --rerun-tasks --no-daemon || exit 1�[0m
 �[36;1mdone�[0m
 �[36;1mecho "No flake in 3 runs"�[0m
 shell: /usr/bin/bash -e {0}
 env:
   JAVA_HOME: /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/25.0.5-8/x64
   JAVA_HOME_25_X64: /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/25.0.5-8/x64
   MAVEN_ARGS: -ntp
   JEXTRACT_HOME: /home/runner/jextract-install
   GRADLE_ACTION_ID: gradle/actions/setup-gradle
   GRADLE_USER_HOME: /home/runner/.gradle
   GRADLE_BUILD_ACTION_SETUP_COMPLETED: true
   DEVELOCITY_INJECTION_INIT_SCRIPT_NAME: gradle-actions.inject-develocity.init.gradle
   DEVELOCITY_INJECTION_CUSTOM_VALUE: gradle-actions
   GITHUB_DEPENDENCY_GRAPH_ENABLED: false
 ##[endgroup]
 === run 1/3 ===
 To honour the JVM settings for this build a single-use Daemon process will be forked. For more on this, please refer to https://docs.gradle.org/9.9.0/userguide/gradle_daemon.html#sec:disabling_the_daemon in the Gradle documentation.
 Daemon will be stopped at the end of the build
 > Task :buildSrc:checkKotlinCompilerVersion
 > Task :buildSrc:checkKotlinGradlePluginConfigurationErrors SKIPPED
 > Task :buildSrc:generateExternalPluginSpecBuilders
 > Task :buildSrc:extractPrecompiledScriptPluginPlugins
 > Task :buildSrc:generateScriptPluginAdapters
 > Task :buildSrc:pluginDescriptors
 > Task :buildSrc:processResources
 > Task :buildSrc:compilePluginsBlocks
 > Task :buildSrc:generatePrecompiledScriptPluginAccessors
 > Task :buildSrc:compileKotlin
 > Task :buildSrc:compileJava NO-SOURCE
 > Task :buildSrc:compileGroovy NO-SOURCE
 > Task :buildSrc:classes
 > Task :buildSrc:jar
 > Task :jpdfium:compileJava
 > Task :jpdfium:writeVersionProperties
 > Task :jpdfium:processResources
 > Task :jpdfium:classes
 > Task :jpdfium:compileTestJava
 > Task :jpdfium:processTestResources
 > Task :jpdfium:testClasses
 > Task :jpdfium-natives:jpdfium-natives-linux-x64:...

GitHub Actions: E2E / 1_Samples E2E (88 features via RunAllSamples).txt: Render form fields/annotations, strip catalog data, and embed JPEG in FlattenMode.FULL

Conclusion: failure

View job details

samples-output/S85_annot-stats/redact-test-multiline-annot-stats.json
   -> ~/work/JPDFium/JPDFium/samples-output/S85_annot-stats/redact-test-multistream-annot-stats.json
   -> ~/work/JPDFium/JPDFium/samples-output/S85_annot-stats/redact-test-nbsp-annot-stats.json
   -> ~/work/JPDFium/JPDFium/samples-output/S85_annot-stats/redact-test-nested-q-annot-stats.json
   -> ~/work/JPDFium/JPDFium/samples-output/S85_annot-stats/redact-test-nfkc-annot-stats.json
   -> ~/work/JPDFium/JPDFium/samples-output/S85_annot-stats/redact-test-ocr-hebrew-points-annot-stats.json
   -> ~/work/JPDFium/JPDFium/samples-output/S85_annot-stats/redact-test-ocr-latin-annot-stats.json
   -> ~/work/JPDFium/JPDFium/samples-output/S85_annot-stats/redact-test-ocr-layer-annot-stats.json
   -> ~/work/JPDFium/JPDFium/samples-output/S85_annot-stats/redact-test-ocr-zero-width-mark-annot-stats.json
   -> ~/work/JPDFium/JPDFium/samples-output/S85_annot-stats/redact-test-over-background-annot-stats.json
   -> ~/work/JPDFium/JPDFium/samples-output/S85_annot-stats/redact-test-overlapping-match-annot-stats.json
   -> ~/work/JPDFium/JPDFium/samples-output/S85_annot-stats/redact-test-overlapping-annot-stats.json
   -> ~/work/JPDFium/JPDFium/samples-output/S85_annot-stats/redact-test-partial-image-annot-stats.json
   -> ~/work/JPDFium/JPDFium/samples-output/S85_annot-stats/redact-test-pattern-end-annot-stats.json
   -> ~/work/JPDFium/JPDFium/samples-output/S85_annot-stats/redact-test-pattern-entire-annot-stats.json
   -> ~/work/JPDFium/JPDFium/samples-output/S85_annot-stats/redact-test-pattern-start-annot-stats.json
   -> ~/work/JPDFium/JPDFium/samples-output/S85_annot-stats/redact-test-phone-annot-stats.json
   -> ~/work/JPDFium/JPDFium/samples-output/S85_annot-stats/redact-test-quote-ops-annot-stats.json
   -> ~/work/JPDFium/JPDFium/samples-output/S85_annot-stats/redact-test-rotate-0-annot-stats.json
   -> ~/work/JPDFium/JPDFium/samples-output/S85_annot-stats/redact-test-rotate-180-annot-stats.json
   -> ~/wo...

GitHub Actions: E2E / Samples E2E (88 features via RunAllSamples): Render form fields/annotations, strip catalog data, and embed JPEG in FlattenMode.FULL

Conclusion: failure

View job details

not-stats.json
   -> ~/work/JPDFium/JPDFium/samples-output/S85_annot-stats/irs_f1040a-annot-stats.json
   -> ~/work/JPDFium/JPDFium/samples-output/S85_annot-stats/irs_f1040ez-annot-stats.json
   -> ~/work/JPDFium/JPDFium/samples-output/S85_annot-stats/irs_fw4-annot-stats.json
   -> ~/work/JPDFium/JPDFium/samples-output/S85_annot-stats/irs_w2-annot-stats.json
   -> ~/work/JPDFium/JPDFium/samples-output/S85_annot-stats/irs_w9-annot-stats.json
   -> ~/work/JPDFium/JPDFium/samples-output/S85_annot-stats/minimal-annot-stats.json
   -> ~/work/JPDFium/JPDFium/samples-output/S85_annot-stats/mozilla_160F_2019-annot-stats.json
   -> ~/work/JPDFium/JPDFium/samples-output/S85_annot-stats/mozilla_tracemonkey-annot-stats.json
   -> ~/work/JPDFium/JPDFium/samples-output/S85_annot-stats/nested-page-tree-inheritance-annot-stats.json
   -> ~/work/JPDFium/JPDFium/samples-output/S85_annot-stats/pdfjs_160F-2019-annot-stats.json
   -> ~/work/JPDFium/JPDFium/samples-output/S85_annot-stats/pdfjs_ArabicCIDTrueType-annot-stats.json
   -> ~/work/JPDFium/JPDFium/samples-output/S85_annot-stats/pdfjs_Brotli-Prototype-FileA-annot-stats.json
   -> ~/work/JPDFium/JPDFium/samples-output/S85_annot-stats/pdfjs_ContentStreamCycleType3insideType3-annot-stats.json
   -> ~/work/JPDFium/JPDFium/samples-output/S85_annot-stats/pdfjs_ContentStreamNoCycleType3insideType3-annot-stats.json
   -> ~/work/JPDFium/JPDFium/samples-output/S85_annot-stats/pdfjs_IdentityToUnicodeMap_charCodeOf-annot-stats.json
   -> ~/work/JPDFium/JPDFium/samples-output/S85_annot-stats/pdfjs_IndexedCS_negative_and_high-annot-stats.json
   -> ~/work/JPDFium/JPDFium/samples-output/S85_annot-stats/pdfjs_PDFBOX-4352-0-annot-stats.json
   -> ~/work/JPDFium/JPDFium/samples-output/S85_annot-stats/pdfjs_PDFJS-7562-reduced-annot-stats.json
   -> ~/work/JPDFium/JPDFium/samples-output/S85_annot-stats/pdfjs_PDFJS-9279-reduced-annot-stats.json
   -> ~/work/JPDFium/JPDFium/samples-output/S85_annot-stats/pdfjs_S2-annot-stats.json
   -> ~/work/JPDFi...
Additional context used

Code guidelines: 1

.github/CODERABBIT_REVIEW.md — configured
Path-based instructions: 3

Apply the native ownership, C ABI, C++23, engine integration, memory, and SIMD rules from .github/CODERABBIT_REVIEW.md.

CodeRabbit configuration file

Files:

  • native/bridge/src/jpdfium_render.cpp
Apply the Java 25 and FFM rules from .github/CODERABBIT_REVIEW.md.

CodeRabbit configuration file

Files:

  • jpdfium/src/main/java/stirling/software/jpdfium/PdfDocument.java
  • jpdfium/src/main/java/stirling/software/jpdfium/PdfPage.java
Source excerpt: These rules apply to maintained source.

CodeRabbit inference engine (.github/CODERABBIT_REVIEW.md)

Files:

  • jpdfium/src/main/java/stirling/software/jpdfium/PdfDocument.java
  • jpdfium/src/main/java/stirling/software/jpdfium/PdfPage.java
  • jpdfium/src/main/resources/META-INF/native-image/com.stirling/jpdfium/reachability-metadata.json
  • native/bridge/src/jpdfium_render.cpp
Learnings: 1

Common learnings

Learnt from: CR
Repo: Stirling-Tools/JPDFium PR: 0
File: .github/CODERABBIT_REVIEW.md:0-0
Timestamp: 2026-10-20T15:53:18.441Z
Learning: Source excerpt:
# JPDFium review standards

## FFM and ABI

- Review native-image metadata and ABI probes when signatures change. Prefer reproducible generation to handwritten drift.
Learnt from: CR
Repo: Stirling-Tools/JPDFium PR: 0
File: .github/CODERABBIT_REVIEW.md:0-0
Timestamp: 2026-10-20T15:53:18.441Z
Learning: Source excerpt:
# JPDFium review standards

## Output, preservation, and security

- Define preserved/modified/rejected/unsupported behavior for forms, annotations, outlines, attachments, metadata, tagging, encryption, and signatures.

@balazs-szucs
balazs-szucs force-pushed the fix/flatten-full-fidelity branch 3 times, most recently from 2ebec1e to 1876a0e Compare November 18, 2026 19:15
…G in FlattenMode.FULL

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>
@balazs-szucs
balazs-szucs force-pushed the fix/flatten-full-fidelity branch from 1876a0e to 6cf3576 Compare November 18, 2026 19:21
@balazs-szucs

Copy link
Copy Markdown
Collaborator Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Action performed

Full review finished.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 87bc7de and 6cf3576.

Files selected for processing: 10

  • jpdfium/src/main/java/stirling/software/jpdfium/PdfDocument.java
  • jpdfium/src/main/java/stirling/software/jpdfium/PdfPage.java
  • jpdfium/src/main/java/stirling/software/jpdfium/panama/JpdfiumH.java
  • jpdfium/src/main/java/stirling/software/jpdfium/panama/JpdfiumLib.java
  • jpdfium/src/main/resources/META-INF/native-image/com.stirling/jpdfium/reachability-metadata.json
  • jpdfium/src/test/java/stirling/software/jpdfium/FlattenApiTest.java
  • native/bridge/include/jpdfium.h
  • native/bridge/src/jpdfium_render.cpp
  • native/bridge/src/jpdfium_stub.cpp
  • reachability-metadata/metadata/com.stirling/jpdfium/1.2.0/reachability-metadata.json

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Review details

CI failures not shown inline: 3

GitHub Actions: Compatibility / 0_Public API compatibility (japicmp vs last release).txt: Render form fields/annotations, strip catalog data, and embed JPEG in FlattenMode.FULL

Conclusion: failure

View job details

##[group]Run BASE_JAR=/tmp/japicmp-baseline/jpdfium-baseline.jar
 �[36;1mBASE_JAR=/tmp/japicmp-baseline/jpdfium-baseline.jar�[0m
 �[36;1mCURR_JAR=$(find jpdfium/build/libs -name 'jpdfium-*.jar' ! -name '*-sources.jar' ! -name '*-javadoc.jar' | head -n1)�[0m
 �[36;1mtest -f "$BASE_JAR" || { echo "Baseline jar missing — skipping"; exit 0; }�[0m
 �[36;1mtest -f "$CURR_JAR" || { echo "Current jar missing — $CURR_JAR"; exit 1; }�[0m
 �[36;1mJAPICMP_VER=0.23.0�[0m
 �[36;1mcurl -fsSL --max-time 60 "https://repo1.maven.org/maven2/com/github/siom79/japicmp/japicmp/${JAPICMP_VER}/japicmp-${JAPICMP_VER}-jar-with-dependencies.jar" -o /tmp/japicmp.jar�[0m
 �[36;1mset +e  # japicmp exits non-zero on incompatibilities; handle below�[0m
 �[36;1m# Accepted breakage (whole-class removals only): NativeGuard was a�[0m
 �[36;1m# deprecated facade whose documented contract no longer holds (it�[0m
 �[36;1m# cannot admit the execution domain), it has no in-repo callers, and�[0m
 �[36;1m# removal turns cryptic runtime failures into clear compile errors�[0m
 �[36;1m# toward PdfiumRuntime. PdfAConverter was a Ghostscript-backed helper�[0m
 �[36;1m# removed together with the Ghostscript dependency; PDF/A conformance�[0m
 �[36;1m# handling now lives in the in-process compression pipeline (see�[0m
 �[36;1m# PdfCompressor). Both are removed classes, so a class-level exclude is�[0m
 �[36;1m# exact. The compression members and PdfEncryption.isQpdfAvailable()�[0m
 �[36;1m# that the overhaul had dropped were restored for binary compatibility,�[0m
 �[36;1m# so they are no longer excluded — every remaining type and member must�[0m
 �[36;1m# stay compatible. TextEditor was an empty placeholder (private�[0m
 �[36;1m# constructor, no methods) that was removed together with its package.�[0m
 �[36;1m# Nothing in the API, the tests, or the javadoc referenced it and it�[0m
 �[36;1m# could not be instantiated, so dropping it is an accepted, deliberate�[0m
 �[36;1m# break rather than one the gate should catc...

GitHub Actions: Compatibility / 1_Module descriptor integrity.txt: Render form fields/annotations, strip catalog data, and embed JPEG in FlattenMode.FULL

Conclusion: failure

View job details

##[group]Run ./gradlew :jpdfium:jar --no-daemon
 �[36;1m./gradlew :jpdfium:jar --no-daemon�[0m
 �[36;1mJAR=$(find jpdfium/build/libs -name 'jpdfium-*.jar' ! -name '*-sources.jar' ! -name '*-javadoc.jar' | head -n1)�[0m
 �[36;1mecho "Describing module from $JAR"�[0m
 �[36;1mjar --describe-module --file="$JAR"�[0m
 �[36;1mXZ_JAR="$GITHUB_WORKSPACE/buildSrc/libs/xz-1.10.jar"�[0m
 �[36;1mif [ ! -f "$XZ_JAR" ]; then�[0m
 �[36;1m  echo "::error::vendored xz runtime jar is missing"�[0m
 �[36;1m  exit 1�[0m
 �[36;1mfi�[0m
 �[36;1mjdeps --multi-release 25 --module-path "$JAR:$XZ_JAR" -s "$JAR" 2>&1 | tee /tmp/jdeps.txt�[0m
 �[36;1mif grep -q "not found" /tmp/jdeps.txt; then�[0m
 �[36;1m  echo "::error::Module descriptor has missing dependencies"�[0m

GitHub Actions: Compatibility / 2_FFM layout vs pinned PDFium headers.txt: Render form fields/annotations, strip catalog data, and embed JPEG in FlattenMode.FULL

Conclusion: failure

View job details

##[group]Run bash native/build-stub.sh
 �[36;1mbash native/build-stub.sh�[0m
 �[36;1m./gradlew :jpdfium:generateBindings :jpdfium:patchBindingsForCrossPlatform --no-daemon�[0m
 �[36;1m# Verify the committed JpdfiumH.java files match the regenerated output.�[0m
 �[36;1mif git diff --quiet -- jpdfium/src/main/java/stirling/software/jpdfium/panama/; then�[0m
 �[36;1m  echo "FFM bindings are in sync with native/bridge/include/jpdfium.h"�[0m
 �[36;1melse�[0m
 �[36;1m  echo "::error::FFM bindings drift from jpdfium.h — run ./gradlew :jpdfium:generateBindings :jpdfium:patchBindingsForCrossPlatform locally and commit the result"�[0m
...
 For more on this, please refer to https://docs.gradle.org/9.9.0/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
 BUILD SUCCESSFUL in 16s
 12 actionable tasks: 6 executed, 6 from cache
 Consider enabling configuration cache to speed up this build: https://docs.gradle.org/9.9.0/userguide/configuration_cache_enabling.html
 ##[error]FFM bindings drift from jpdfium.h — run ./gradlew :jpdfium:generateBindings :jpdfium:patchBindingsForCrossPlatform locally and commit the result
...
 -    }
 -
      private static class jpdfium_doc_flatten_annotations {
          public static final FunctionDescriptor DESC = FunctionDescriptor.of(
              JpdfiumH.C_INT,
 ##[error]Process completed with exit code 1.
Additional context used

Code guidelines: 1

.github/CODERABBIT_REVIEW.md — configured
Path-based instructions: 4

Apply the native ownership, C ABI, C++23, engine integration, memory, and SIMD rules from .github/CODERABBIT_REVIEW.md.

CodeRabbit configuration file

Files:

  • native/bridge/include/jpdfium.h
  • native/bridge/src/jpdfium_render.cpp
  • native/bridge/src/jpdfium_stub.cpp
Enforce meaningful assertions, deterministic concurrency, failure-path cleanup, and explicit native/stub requirements.

CodeRabbit configuration file

Files:

  • jpdfium/src/test/java/stirling/software/jpdfium/FlattenApiTest.java
Apply the Java 25 and FFM rules from .github/CODERABBIT_REVIEW.md.

CodeRabbit configuration file

Files:

  • jpdfium/src/main/java/stirling/software/jpdfium/PdfDocument.java
  • jpdfium/src/main/java/stirling/software/jpdfium/PdfPage.java
  • jpdfium/src/main/java/stirling/software/jpdfium/panama/JpdfiumH.java
  • jpdfium/src/main/java/stirling/software/jpdfium/panama/JpdfiumLib.java
  • jpdfium/src/test/java/stirling/software/jpdfium/FlattenApiTest.java
Source excerpt: These rules apply to maintained source.

CodeRabbit inference engine (.github/CODERABBIT_REVIEW.md)

Files:

  • jpdfium/src/main/java/stirling/software/jpdfium/PdfDocument.java
  • jpdfium/src/main/java/stirling/software/jpdfium/PdfPage.java
  • jpdfium/src/main/java/stirling/software/jpdfium/panama/JpdfiumH.java
  • jpdfium/src/main/java/stirling/software/jpdfium/panama/JpdfiumLib.java
  • jpdfium/src/main/resources/META-INF/native-image/com.stirling/jpdfium/reachability-metadata.json
  • jpdfium/src/test/java/stirling/software/jpdfium/FlattenApiTest.java
  • native/bridge/include/jpdfium.h
  • native/bridge/src/jpdfium_render.cpp
  • native/bridge/src/jpdfium_stub.cpp
  • reachability-metadata/metadata/com.stirling/jpdfium/1.2.0/reachability-metadata.json
Learnings: 1

Common learnings

Learnt from: CR
Repo: Stirling-Tools/JPDFium PR: 0
File: .github/CODERABBIT_REVIEW.md:0-0
Timestamp: 2026-10-20T15:53:18.441Z
Learning: Source excerpt:
# JPDFium review standards

## FFM and ABI

- Review native-image metadata and ABI probes when signatures change. Prefer reproducible generation to handwritten drift.
Learnt from: CR
Repo: Stirling-Tools/JPDFium PR: 0
File: .github/CODERABBIT_REVIEW.md:0-0
Timestamp: 2026-10-20T15:53:18.441Z
Learning: Source excerpt:
# JPDFium review standards

## Output, preservation, and security

- Define preserved/modified/rejected/unsupported behavior for forms, annotations, outlines, attachments, metadata, tagging, encryption, and signatures.
Additional comments: 3

native/bridge/src/jpdfium_render.cpp: 1

986-987: Data Integrity & Integration

The replacement reports JPDFIUM_ERR_NATIVE after FPDF_ImportPages fails. The original page is kept, but the destination document is not guaranteed unchanged. The pinned PDFium FPDF_ImportPages and CPDF_PageExporter::ExportPage source is needed to decide whether a failed import can leave an inserted page in dw->core->doc. That source is not in this checkout, and the supplied excerpt is from a different engine revision. The comment's proposed correction (rollback or a stale-generation policy) depends on that result, so it cannot be recommended yet.

native/bridge/src/jpdfium_stub.cpp: 1

952-952: Functional Correctness

The stub's success returns are a real hazard if a published bundle is built with the stub branch. The packaging path does not exclude the stub, and the Java callers accept its JPDFIUM_OK. Whether any supported release is built this way cannot be decided from the inspected files. The release native build configuration, which selects the JPDFIUM_USE_PDFIUM branch, was not located, so the release premise remains unresolved.

jpdfium/src/main/java/stirling/software/jpdfium/PdfPage.java: 1

1235-1235: Stability & Availability

The native replacement leaves the document unchanged when it fails.

jpdfium_page_replace_with_jpeg deletes the original page only after the JPEG-backed replacement has been generated and imported at pageIndex + 1. Every earlier failure returns before that delete. After the delete, the function only increments the generation and returns success. An error therefore does not leave the document in a partially replaced state, so the other open pages do not hold stale state that the Java epoch check misses.

The Java exception at the call site skips the invalidation and modified-state update. On this path, that skip does not cause a stale-epoch problem, because the native document is still unchanged.

Comment on lines +1118 to +1119
for (int i = 0; i < count; i++) {
JpdfiumLib.pageReplaceWithJpeg(handle, i, jpegs.get(i), widths[i], heights[i]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Major · Stability & Availability · Quick win

Keep the destructive replacement phase inside one admission.

If another thread calls PdfiumRuntime.quiesce() during page 0 replacement, that replacement can finish. Page 1 then makes a new admission and throws because the runtime is QUIESCING. FULL cannot finish its accepted replacement pass or rebuild the document. Nested operations inside one admitted batch can continue after quiescence. (raw.githubusercontent.com)

Keep JPEG encoding outside the domain. Run the replacement loop, rebuild, and state reconciliation inside one executeBatch. Preserve failure bookkeeping for genuine native failures. Add a latch-controlled regression that quiesces during the first replacement and checks completion.

As per coding guidelines, “accepted batches must follow their documented continuation contract.”

Source: Coding guidelines

var sz = size();
float wPt = sz.width();
float hPt = sz.height();
byte[] jpegBytes = PdfDocument.encodeJpeg(renderAt(dpi).toBufferedImage(), 0.85f);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trivial · Performance & Scalability · Quick win

Supported by static analysis

Script executed:

rg -n 'renderImage|renderAt\(|renderAtFlags|renderPageImage|toBufferedImage' jpdfium/src/main/java/stirling/software/jpdfium/PdfPage.java
sed -n '100,130p' jpdfium/src/main/java/stirling/software/jpdfium/PdfPage.java

Repository: Stirling-Tools/JPDFium

Length of output: 2930


Script executed:

cat -n jpdfium/src/main/java/stirling/software/jpdfium/PdfPage.java | sed -n '150,240p'
cat -n jpdfium/src/main/java/stirling/software/jpdfium/PdfPage.java | sed -n '1220,1245p'
rg -n -F -e 'renderPageImage' -e 'static RenderResult renderPage' -e 'renderPage(' -- jpdfium/src/main/java/stirling/software/jpdfium/ || test "$?" -eq 1
rg -n -F -e 'static BufferedImage encodeJpeg' -e 'encodeJpeg(' -- jpdfium/src/main/java/stirling/software/jpdfium/PdfDocument.java || test "$?" -eq 1

Repository: Stirling-Tools/JPDFium

Length of output: 8557


Script executed:

cat -n jpdfium/src/main/java/stirling/software/jpdfium/panama/JpdfiumLib.java | sed -n '1074,1145p'
cat -n jpdfium/src/main/java/stirling/software/jpdfium/panama/JpdfiumLib.java | sed -n '1240,1295p'
rg -n -F -e 'toBufferedImage' -e 'class RenderResult' -e 'record RenderResult' -- jpdfium/src/main/java/stirling/software/jpdfium/ || test "$?" -eq 1

Repository: Stirling-Tools/JPDFium

Length of output: 10550


Script executed:

cat -n jpdfium/src/main/java/stirling/software/jpdfium/panama/JpdfiumLib.java | sed -n '1145,1200p'
rg -n -F -e 'jpdfium_render_page_into' -e 'jpdfium_render_page_flags' -- . || test "$?" -eq 1

Repository: Stirling-Tools/JPDFium

Length of output: 11877


Script executed:

cat -n native/bridge/src/jpdfium_render.cpp | sed -n '330,430p'
rg -n -F -e 'FPDF_LCD_TEXT' -e 'FPDF_ANNOT' -e 'FPDF_FFLDraw' -e 'FFLDraw' -e 'FPDFBitmap_FillRect' -- native/bridge/src || test "$?" -eq 1

Repository: Stirling-Tools/JPDFium

Length of output: 8939


Use renderImage(dpi) to avoid the heap RGBA copy in FULL flattening.

renderAt(dpi) copies the native RGBA buffer into a heap byte[] and then converts it with a per-pixel pack loop. renderImage(dpi) calls JpdfiumLib.renderPageImage on real natives. That path uses the same opaque white background, the same FPDF_ANNOT | FPDF_LCD_TEXT flags for flags 0, and no form drawing. It copies the native target directly into the int raster. The full-frame heap byte[] and the per-pixel pack loop are removed. A native arena target still exists, so the saving is heap traffic and pack work, not every intermediate buffer. The stub runtime keeps the current conversion.

Suggested fix

--- "a/jpdfium/src/main/java/stirling/software/jpdfium/PdfPage.java"
+++ "b/jpdfium/src/main/java/stirling/software/jpdfium/PdfPage.java"
@@ -1230,7 +1230,7 @@
                 var sz = size();
                 float wPt = sz.width();
                 float hPt = sz.height();
-                byte[] jpegBytes = PdfDocument.encodeJpeg(renderAt(dpi).toBufferedImage(), 0.85f);
+                byte[] jpegBytes = PdfDocument.encodeJpeg(renderImage(dpi), 0.85f);
                 close();
                 ownerDoc.replacePageWithJpeg(pageIndex, jpegBytes, wPt, hPt);
                 ownerDoc.invalidateOpenPages();
Committable suggestion

IMPORTANT
Review the replacement and indentation, then test before committing.

Suggested change
byte[] jpegBytes = PdfDocument.encodeJpeg(renderAt(dpi).toBufferedImage(), 0.85f);
byte[] jpegBytes = PdfDocument.encodeJpeg(renderImage(dpi), 0.85f);

batched.pages().get(i),
label + ": page " + i + " must render identically");
assertTrue(
batched.pages().get(i).length > 0,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Functional Correctness · Quick win

Keep a content comparison between both flattening paths.

A blank batched page still produces a nonempty RGBA array. With matching annotation counts, this assertion now passes even if batch flattening loses all visible content. The previous equality assertion rejected that result.

Compare raster dimensions and pixel content. If JPEG differences prevent exact equality, use a bounded pixel difference that still rejects missing content. Keep exact equality for ANNOTATIONS where applicable.

As per path instructions, “Enforce meaningful assertions.”

Source: Path instructions

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 6cf3576 and 4f3d4af.

Files selected for processing: 6

  • .github/workflows/security.yml
  • jpdfium/build.gradle.kts
  • jpdfium/src/main/java/stirling/software/jpdfium/PdfDocument.java
  • jpdfium/src/main/java/stirling/software/jpdfium/panama/JpdfiumH.java
  • jpdfium/src/test/java/stirling/software/jpdfium/FlattenApiTest.java
  • osv-scanner.toml

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Review details

Context from checks skipped due to timeout: 52

  • GitHub Check: Native bridge libFuzzer (ASan/UBSan, real PDFium)
  • GitHub Check: CodeQL Analysis (c-cpp)
  • GitHub Check: GraalVM Native Image Smoke & E2E Test (Linux x64)
  • GitHub Check: Publish Maven Dry Run
  • GitHub Check: README Quick Start Example (Linux x64)
  • GitHub Check: Concurrency Stress Tests (Linux x64)
  • GitHub Check: Samples E2E Suite (All 88 Feature Samples)
  • GitHub Check: CodeQL Analysis (java-kotlin)
  • GitHub Check: Build & Verify (Compilation) (windows-latest)
  • GitHub Check: Build & Verify (Compilation) (ubuntu-latest)
  • GitHub Check: Unit & Integration E2E Tests (Linux x64)
  • GitHub Check: Build & Verify (Compilation) (macos-15)
  • GitHub Check: Corpus (generate + native)
  • GitHub Check: Robustness, Leak & Determinism Tests (Linux x64)
  • GitHub Check: Preflight - pinned PDFium release assets
  • GitHub Check: Build patched PDFium and run Ghent V50
  • GitHub Check: build-natives (darwin-x64, macos-15-intel)
  • GitHub Check: JMH Benchmarks (advisory)
  • GitHub Check: build-natives (windows-arm64, windows-11-arm)
  • GitHub Check: build-natives (windows-x64, windows-latest)
  • GitHub Check: Natural System Libvips & Downstream Integration (Linux x64)
  • GitHub Check: Gradle wrapper validation
  • GitHub Check: Native jar checker regression tests
  • GitHub Check: Action version audit
  • GitHub Check: build-natives (darwin-arm64, macos-15)
  • GitHub Check: Corpus + integration e2e
  • GitHub Check: CLI correctness & no-corruption tests
  • GitHub Check: Shellcheck (scripts + native/*.sh)
  • GitHub Check: Docs link check
  • GitHub Check: OSV vulnerability scan
  • GitHub Check: Version bump script regression tests
  • GitHub Check: Markdown lint
  • GitHub Check: prep-windows-icu
  • GitHub Check: EditorConfig + whitespace hygiene
  • GitHub Check: build-natives (linux-arm64, ubuntu-24.04-arm)
  • GitHub Check: CodeQL (c-cpp)
  • GitHub Check: Musl Native Detection (Alpine)
  • GitHub Check: Outdated dependencies report
  • GitHub Check: Public API compatibility (japicmp vs last release)
  • GitHub Check: C++ - clang-tidy + cppcheck + clang-format
  • GitHub Check: Restricted-env compat (no execstack + hermetic bundle)
  • GitHub Check: FFM layout vs pinned PDFium headers
  • GitHub Check: build-natives (linux-x64, ubuntu-latest)
  • GitHub Check: Javadoc builds cleanly
  • GitHub Check: Samples E2E (88 features via RunAllSamples)
  • GitHub Check: Gradle lockfile freshness
  • GitHub Check: Java - SpotBugs + Checkstyle + PMD + Spotless
  • GitHub Check: CodeQL (java-kotlin)
  • GitHub Check: Module descriptor integrity
  • GitHub Check: Bundle verify (symbols, RPATH, linkage, sizes)
  • GitHub Check: Flaky-test guard (3× rerun)
  • GitHub Check: JaCoCo coverage (non-blocking ratchet)
Additional context used

Code guidelines: 1

.github/CODERABBIT_REVIEW.md — configured
Path-based instructions: 3

Enforce meaningful assertions, deterministic concurrency, failure-path cleanup, and explicit native/stub requirements.

CodeRabbit configuration file

Files:

  • jpdfium/src/test/java/stirling/software/jpdfium/FlattenApiTest.java
Apply the Java 25 and FFM rules from .github/CODERABBIT_REVIEW.md.

CodeRabbit configuration file

Files:

  • jpdfium/src/main/java/stirling/software/jpdfium/PdfDocument.java
  • jpdfium/src/main/java/stirling/software/jpdfium/panama/JpdfiumH.java
  • jpdfium/src/test/java/stirling/software/jpdfium/FlattenApiTest.java
Source excerpt: These rules apply to maintained source.

CodeRabbit inference engine (.github/CODERABBIT_REVIEW.md)

Files:

  • .github/workflows/security.yml
  • jpdfium/build.gradle.kts
  • jpdfium/src/main/java/stirling/software/jpdfium/PdfDocument.java
  • jpdfium/src/main/java/stirling/software/jpdfium/panama/JpdfiumH.java
  • jpdfium/src/test/java/stirling/software/jpdfium/FlattenApiTest.java
  • osv-scanner.toml
Learnings: 1

Common learnings

Learnt from: CR
Repo: Stirling-Tools/JPDFium PR: 0
File: .github/CODERABBIT_REVIEW.md:0-0
Timestamp: 2026-10-20T15:53:18.441Z
Learning: Source excerpt:
# JPDFium review standards

## Tests, profiling, and delivery

- Every defect fix needs a focused regression with an observable expected result. No `assertTrue(true)`, swallowed failures, or tests that silently pass when fixtures/tools/source roots are missing.
Learnt from: CR
Repo: Stirling-Tools/JPDFium PR: 0
File: .github/CODERABBIT_REVIEW.md:0-0
Timestamp: 2026-10-20T15:53:18.441Z
Learning: Source excerpt:
# JPDFium review standards

## PDFium execution and lifecycle

- Destructive reload, replacement, flattening, and page deletion need a consistent invalidate-or-reject policy. Stale objects must remain safely closeable.
Learnt from: CR
Repo: Stirling-Tools/JPDFium PR: 0
File: .github/CODERABBIT_REVIEW.md:0-0
Timestamp: 2026-10-20T15:53:18.441Z
Learning: Source excerpt:
# JPDFium review standards

## FFM and ABI

- Review native-image metadata and ABI probes when signatures change. Prefer reproducible generation to handwritten drift.
Learnt from: CR
Repo: Stirling-Tools/JPDFium PR: 0
File: .github/CODERABBIT_REVIEW.md:0-0
Timestamp: 2026-10-31T10:47:27.879Z
Learning: Source excerpt:
# JPDFium review standards

## Tests, profiling, and delivery

- Validate semantic preservation through reopen, independent structural checks, and representative rendering/text properties. A successful open is insufficient.

Comment thread .github/workflows/security.yml Resolved
boolean hadAnnotations = hasAnnotations();
try {
JpdfiumLib.docFlattenAnnotationsDisplay(handle);
JpdfiumLib.docFlattenAnnotations(handle);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Major · Functional Correctness · Quick win

Supported by static analysis

Script executed:

#!/bin/bash
set -euo pipefail
ast-grep outline jpdfium/src/main/java/stirling/software/jpdfium/panama/JpdfiumLib.java \
  --match 'docFlattenAnnotations|pageFlatten'
ast-grep outline native/bridge/src/jpdfium_redact.cpp \
  --match 'flatten|Flatten|hideNoViewAnnotations'
rg -n -A100 -B8 \
  'docFlattenAnnotations\(|jpdfium_doc_flatten_annotations\(|hideNoViewAnnotations\(|FPDFPage_Flatten\(' \
  jpdfium/src/main/java/stirling/software/jpdfium/panama/JpdfiumLib.java \
  native/bridge/src/jpdfium_redact.cpp

Repository: Stirling-Tools/JPDFium

Length of output: 29286


Use the display-only annotation bake for FULL flattening.

docFlattenAnnotations bakes no-view markup into page content as well. FULL mode rasterizes each page immediately after this bake. Any no-view annotation therefore appears in the JPEG output, though viewers hide it. Call docFlattenAnnotationsDisplay instead. It excludes no-view markup and still bakes visible annotations, which matches its documented use before rasterization.

Suggested fix

-                    JpdfiumLib.docFlattenAnnotations(handle);
+                    JpdfiumLib.docFlattenAnnotationsDisplay(handle);
Committable suggestion

IMPORTANT
Review the replacement and indentation, then test before committing.

Suggested change
JpdfiumLib.docFlattenAnnotations(handle);
JpdfiumLib.docFlattenAnnotationsDisplay(handle);

Source: Coding guidelines

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>
Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>
Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>
Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>
Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>
Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>
@balazs-szucs
balazs-szucs added this pull request to the merge queue Nov 21, 2026
Merged via the queue into Stirling-Tools:main with commit f219c3f Nov 21, 2026
82 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants