Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(389)

Unified Diff: src/pdf/SkPDFDocument.cpp

Issue 1864163004: SkPDF: fix PDF/A (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/pdf/SkPDFDocument.h ('k') | src/pdf/SkPDFMetadata.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pdf/SkPDFDocument.cpp
diff --git a/src/pdf/SkPDFDocument.cpp b/src/pdf/SkPDFDocument.cpp
index 740fa7dd5e89792840a2d7285f7cf1861f9845d5..178b521fbaceb878fd5962579344023fee125913 100644
--- a/src/pdf/SkPDFDocument.cpp
+++ b/src/pdf/SkPDFDocument.cpp
@@ -238,6 +238,18 @@ SkCanvas* SkPDFDocument::onBeginPage(SkScalar width, SkScalar height,
// if this is the first page if the document.
fObjectSerializer.serializeHeader(this->getStream(), fMetadata);
fDests = sk_make_sp<SkPDFDict>();
+ #ifdef SK_PDF_GENERATE_PDFA
+ SkPDFMetadata::UUID uuid = fMetadata.uuid();
+ // We use the same UUID for Document ID and Instance ID since this
+ // is the first revision of this document (and Skia does not
+ // support revising existing PDF documents).
+ // If we are not in PDF/A mode, don't use a UUID since testing
+ // works best with reproducible outputs.
+ fID.reset(SkPDFMetadata::CreatePdfId(uuid, uuid));
+ fXMP.reset(fMetadata.createXMPObject(uuid, uuid));
+ fObjectSerializer.addObjectRecursively(fXMP);
+ fObjectSerializer.serializeObjects(this->getStream());
+ #endif
}
SkISize pageSize = SkISize::Make(
SkScalarRoundToInt(width), SkScalarRoundToInt(height));
@@ -297,18 +309,9 @@ bool SkPDFDocument::onClose(SkWStream* stream) {
return false;
}
auto docCatalog = sk_make_sp<SkPDFDict>("Catalog");
- sk_sp<SkPDFObject> id, xmp;
#ifdef SK_PDF_GENERATE_PDFA
- SkPDFMetadata::UUID uuid = metadata.uuid();
- // We use the same UUID for Document ID and Instance ID since this
- // is the first revision of this document (and Skia does not
- // support revising existing PDF documents).
- // If we are not in PDF/A mode, don't use a UUID since testing
- // works best with reproducible outputs.
- id.reset(SkPDFMetadata::CreatePdfId(uuid, uuid));
- xmp.reset(metadata.createXMPObject(uuid, uuid));
- docCatalog->insertObjRef("Metadata", std::move(xmp));
-
+ SkASSERT(fXMP);
+ docCatalog->insertObjRef("Metadata", fXMP);
// sRGB is specified by HTML, CSS, and SVG.
auto outputIntent = sk_make_sp<SkPDFDict>("OutputIntent");
outputIntent->insertName("S", "GTS_PDFA1");
@@ -321,7 +324,6 @@ bool SkPDFDocument::onClose(SkWStream* stream) {
// no one has ever asked for this feature.
docCatalog->insertObject("OutputIntents", std::move(intentArray));
#endif
-
docCatalog->insertObjRef("Pages", generate_page_tree(&fPages));
if (fDests->size() > 0) {
@@ -340,9 +342,12 @@ bool SkPDFDocument::onClose(SkWStream* stream) {
fObjectSerializer.addObjectRecursively(docCatalog);
fObjectSerializer.serializeObjects(this->getStream());
- fObjectSerializer.serializeFooter(
- this->getStream(), docCatalog, std::move(id));
-
+ #ifdef SK_PDF_GENERATE_PDFA
+ fObjectSerializer.serializeFooter(this->getStream(), docCatalog, fID);
+ #else
+ fObjectSerializer.serializeFooter(
+ this->getStream(), docCatalog, nullptr);
+ #endif
SkASSERT(fPages.count() == 0);
fCanon.reset();
renew(&fObjectSerializer);
« no previous file with comments | « src/pdf/SkPDFDocument.h ('k') | src/pdf/SkPDFMetadata.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698