Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FOP-2854: Allow to override CreationDate #65

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fop-core/src/main/java/org/apache/fop/pdf/PDFDocument.java
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,7 @@ private TrailerDictionary createTrailerDictionary(boolean addRoot) {
if (addRoot) {
trailerDictionary.setRoot(root).setInfo(info);
}
trailerDictionary.setFileID(gen.getOriginalFileID(), gen.getUpdatedFileID());
trailerDictionary.setFileID("279B5BE7BC0E1B4FE4D4A16B1C28B990".getBytes(), "3D096A7D6223E7A468C7AB8CAD3F6602".getBytes());
if (isEncryptionActive()) {
trailerDictionary.setEncryption(encryption);
}
Expand Down
4 changes: 3 additions & 1 deletion fop-core/src/main/java/org/apache/fop/pdf/PDFMetadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ public static Metadata createXMPFromPDFDocument(PDFDocument pdfDoc) {

//Set creation date if not available, yet
if (info.getCreationDate() == null) {
Date d = new Date();
Date d = System.getenv("SOURCE_DATE_EPOCH") == null ?
new Date() :
new Date(1000 * Long.parseLong(System.getenv("SOURCE_DATE_EPOCH")));
info.setCreationDate(d);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,10 @@ private Metadata createDefaultDocumentMetadata() {
} else {
xmpBasic.setCreatorTool(Version.getVersion());
}
xmpBasic.setMetadataDate(new java.util.Date());
java.util.Date d = System.getenv("SOURCE_DATE_EPOCH") == null ?
new java.util.Date() :
new java.util.Date(1000 * Long.parseLong(System.getenv("SOURCE_DATE_EPOCH")));
xmpBasic.setMetadataDate(d);
if (getUserAgent().getCreationDate() != null) {
xmpBasic.setCreateDate(getUserAgent().getCreationDate());
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,10 @@ public void renderXMPMetadata(XMPMetadata metadata) {
fopXMP.mergeInto(docXMP, exclude);
XMPBasicAdapter xmpBasic = XMPBasicSchema.getAdapter(docXMP);
//Metadata was changed so update metadata date
xmpBasic.setMetadataDate(new java.util.Date());
java.util.Date d = System.getenv("SOURCE_DATE_EPOCH") == null ?
new java.util.Date() :
new java.util.Date(1000 * Long.parseLong(System.getenv("SOURCE_DATE_EPOCH")));
xmpBasic.setMetadataDate(d);
PDFMetadata.updateInfoFromMetadata(docXMP, pdfDoc.getInfo());

PDFMetadata pdfMetadata = pdfDoc.getFactory().makeMetadata(
Expand Down