[
https://issues.apache.org/jira/browse/FOP-3367?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18137407#comment-18137407
]
Juan Manuel Méndez Rey commented on FOP-3367:
---------------------------------------------
Third attempt, after carefully looking at all the previous attempts:
Looking at ISO 32000-1 14.4 recommendation: by default the file ID should keep
the current time.
Every date FOP writes in a PDF now uses the creation date set with
FOUserAgent.setCreationDate(), as you suggested in
[apache/xmlgraphics-fop#65|https://github.com/apache/xmlgraphics-fop/pull/65]
(“You can use the fop api to override dates”). Until now xmp:MetadataDate, the
page piece LastModified date and the dates of embedded files ignored it.
* New PDF renderer option file-id-from-creation-date, default false. Only when
it is enabled does the file ID use that creation date instead of the current
time. The spec allows this in the note to 14.4: “The calculation of the file
identifier need not be reproducible; all that matters is that the identifier is
likely to be unique.” The ID still depends on the content.
* New command line option -creationdate (ISO 8601, for example
2026-11-01T00:00:00Z), which sets the creation date and enables that option, so
the fop command can do what the API does. No environment variable is read.
With -creationdate and a fixed Java time zone, as suggested in FOP-2854, two
runs of the fop command give the same PDF. Distributions can then map
SOURCE_DATE_EPOCH to -creationdate in their own fop scripts and drop their
patches.
The full fop-core suite passes and checkstyle reports no violations.
New Pull request:
[apache/xmlgraphics-fop#134|https://github.com/apache/xmlgraphics-fop/pull/134]
> Creation date set on FOUserAgent is not used for xmp:MetadataDate and the
> file ID
> ---------------------------------------------------------------------------------
>
> Key: FOP-3367
> URL: https://issues.apache.org/jira/browse/FOP-3367
> Project: FOP
> Issue Type: Bug
> Components: renderer/pdf
> Affects Versions: 2.12
> Reporter: Juan Manuel Méndez Rey
> Priority: Major
>
> [PATCH]
> When a creation date is set with FOUserAgent.setCreationDate(), FOP uses it
> for /CreationDate and xmp:CreateDate, but xmp:MetadataDate and the date
> hashed into the trailer /ID still come from the clock. So two runs with the
> same input and the same creation date give different PDFs.
> In FOP-2854 the advice was to set the dates through the FOP API. This patch
> makes the API date apply everywhere. It adds no environment variable or new
> option.
> * IFRenderer and PDFRenderingUtil: MetadataDate is the creation date when
> one is set, the current time otherwise.
> * FileIDGenerator: hashes the document creation date instead of the current
> time.
> * New test PDFCreationDateTestCase: renders the same FO twice with a fixed
> creation date. Both cases fail on main (1301bcf) and pass with the patch.
> When no creation date is set, nothing changes. The full fop-core suite passes
> (3731 tests) and checkstyle reports no violations.
> Pull request: [https://github.com/apache/xmlgraphics-fop/pull/132]
> Related: FOP-2854, FOP-3040,
> [https://github.com/apache/xmlgraphics-fop/pull/65] and
> [https://github.com/apache/xmlgraphics-fop/pull/87] (its first two commits,
> by t-8ch, cover the same two places).
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)