Skip to content

FOP-3367: Use the user agent creation date for MetadataDate and, optionally, the file ID - #132

Closed
vejeta wants to merge 3 commits into
apache:mainfrom
vejeta:creation-date-everywhere
Closed

vejeta wants to merge 3 commits into
apache:mainfrom
vejeta:creation-date-everywhere

Conversation

@vejeta

@vejeta vejeta commented Nov 2, 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 xmp:MetadataDate and the file ID still come from the clock, so the same input and creation date never give the same PDF.

  • IFRenderer and PDFRenderingUtil: MetadataDate is 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 exactly as before.
  • PDFCreationDateTestCase: MetadataDate, two renders with the option give the same bytes, two renders without it do not. The first two fail on main (1301bcf).

Enable it in the configuration file:

<renderer mime="application/pdf">
  <file-id-from-creation-date>true</file-id-from-creation-date>
</renderer>

This completes the API route suggested in https://issues.apache.org/jira/browse/FOP-2854: with the option enabled and a creation date set, the same input gives the same PDF in the same environment (checked in two separate processes). Dates are still written in the local time zone, as before, so a different time zone gives a different file, and the fop command cannot set a creation date yet. Those would be separate changes.

A smaller alternative with only the MetadataDate part is #133. Please merge whichever you prefer.

The full fop-core suite passes (3732 tests) and checkstyle reports no violations.

When a creation date is set with FOUserAgent.setCreationDate(), use it
for xmp:MetadataDate and for the date hashed into the trailer /ID, so
the same input and creation date give the same PDF. Without a creation
date the current time is used, as before.
@vejeta vejeta changed the title Use the user agent creation date for MetadataDate and file ID FOP-3367: Use the user agent creation date for MetadataDate and file ID Nov 3, 2026
The PDF specification recommends the current time as part of the file
ID digest, so only use the user agent creation date for
xmp:MetadataDate.
@vejeta vejeta changed the title FOP-3367: Use the user agent creation date for MetadataDate and file ID FOP-3367: Use the user agent creation date for xmp:MetadataDate Nov 3, 2026
The file ID keeps the current time by default, as ISO 32000-1 14.4
recommends. With <file-id-from-creation-date>true</file-id-from-creation-date>
in the PDF renderer configuration, or the same renderer option on the
user agent, the creation date set on the user agent is used instead, so
the same input and creation date give the same file.
@vejeta vejeta changed the title FOP-3367: Use the user agent creation date for xmp:MetadataDate FOP-3367: Use the user agent creation date for MetadataDate and, optionally, the file ID Nov 3, 2026
@vejeta

vejeta commented Nov 3, 2026

Copy link
Copy Markdown
Author

Superseded by #134, which keeps the current time in the file ID by default.

@vejeta vejeta closed this Nov 3, 2026
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