Skip to content

FOP-3367: Use the user agent creation date for every PDF date - #134

Open
vejeta wants to merge 1 commit into
apache:mainfrom
vejeta:fop-3367-creation-date
Open

vejeta wants to merge 1 commit into
apache:mainfrom
vejeta:fop-3367-creation-date

Conversation

@vejeta

@vejeta vejeta commented Nov 3, 2026

Copy link
Copy Markdown

https://issues.apache.org/jira/browse/FOP-3367

When a creation date is set with FOUserAgent.setCreationDate(), FOP uses it for /CreationDate and xmp:CreateDate but not for the other dates it writes, so the same input and creation date never give the same PDF.

  • IFRenderer, PDFRenderingUtil, PDFEmbeddedFile: xmp:MetadataDate, the page piece LastModified date and the dates of embedded files use the creation date when one is set, the current time otherwise.
  • New PDF renderer option file-id-from-creation-date, default false. When enabled, FileIDGenerator hashes the creation date instead of the current time. Without it the file ID is computed as before, as ISO 32000-1 14.4 recommends.
  • New command line option -creationdate (ISO 8601), which sets the creation date and enables that option. No environment variable is read.
fop -creationdate 2026-11-01T00:00:00Z -fo in.fo -pdf out.pdf

With -creationdate and a fixed Java time zone (-Duser.timezone=UTC), two runs at different times and with different TZ give the same PDF. Without a creation date nothing changes.

Tests: PDFCreationDateTestCase (new), PDFPagePieceTestCase, CommandLineOptionsTestCase. The full fop-core suite passes (3736 tests) and checkstyle reports no violations.

When a creation date is set with FOUserAgent.setCreationDate(), use it
for xmp:MetadataDate, the page piece LastModified date and the dates of
embedded files too, not only for /CreationDate and xmp:CreateDate.

The file ID keeps the current time, as ISO 32000-1 14.4 recommends.
The new PDF renderer option file-id-from-creation-date (default false)
uses the creation date for it instead.

The new command line option -creationdate sets the creation date and
enables that option, so that the fop command can give the same PDF for
the same input, as the API can.
@vejeta

vejeta commented Nov 3, 2026

Copy link
Copy Markdown
Author

CI on my fork for this commit passes all 10 jobs (Java 8 to 25, Linux and Windows): https://github.com/vejeta/xmlgraphics-fop/actions/runs/41685896137

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.

1 participant