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

Side by Side Diff: src/pdf/SkPDFMetadata.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 unified diff | Download patch
« no previous file with comments | « src/pdf/SkPDFDocument.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkMilestone.h" 8 #include "SkMilestone.h"
9 #include "SkPDFMetadata.h" 9 #include "SkPDFMetadata.h"
10 #include "SkPDFTypes.h" 10 #include "SkPDFTypes.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 dict->insertString("Producer", "Skia/PDF m" SKPDF_STRING(SK_MILESTONE)); 45 dict->insertString("Producer", "Skia/PDF m" SKPDF_STRING(SK_MILESTONE));
46 if (fCreation) { 46 if (fCreation) {
47 dict->insertString("CreationDate", pdf_date(*fCreation.get())); 47 dict->insertString("CreationDate", pdf_date(*fCreation.get()));
48 } 48 }
49 if (fModified) { 49 if (fModified) {
50 dict->insertString("ModDate", pdf_date(*fModified.get())); 50 dict->insertString("ModDate", pdf_date(*fModified.get()));
51 } 51 }
52 return dict.release(); 52 return dict.release();
53 } 53 }
54 54
55 #undef SKPDF_STRING
56 #undef SKPDF_STRING_IMPL
57
58 #ifdef SK_PDF_GENERATE_PDFA 55 #ifdef SK_PDF_GENERATE_PDFA
59 SkPDFMetadata::UUID SkPDFMetadata::uuid() const { 56 SkPDFMetadata::UUID SkPDFMetadata::uuid() const {
60 // The main requirement is for the UUID to be unique; the exact 57 // The main requirement is for the UUID to be unique; the exact
61 // format of the data that will be hashed is not important. 58 // format of the data that will be hashed is not important.
62 SkMD5 md5; 59 SkMD5 md5;
63 const char uuidNamespace[] = "org.skia.pdf\n"; 60 const char uuidNamespace[] = "org.skia.pdf\n";
64 md5.write(uuidNamespace, strlen(uuidNamespace)); 61 md5.write(uuidNamespace, strlen(uuidNamespace));
65 double msec = SkTime::GetMSecs(); 62 double msec = SkTime::GetMSecs();
66 md5.write(&msec, sizeof(msec)); 63 md5.write(&msec, sizeof(msec));
67 SkTime::DateTime dateTime; 64 SkTime::DateTime dateTime;
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 "%s" // CreateDate 287 "%s" // CreateDate
291 "%s" // MetadataDate 288 "%s" // MetadataDate
292 "%s" // xmp:CreatorTool 289 "%s" // xmp:CreatorTool
293 "<dc:format>application/pdf</dc:format>\n" 290 "<dc:format>application/pdf</dc:format>\n"
294 "%s" // dc:title 291 "%s" // dc:title
295 "%s" // dc:description 292 "%s" // dc:description
296 "%s" // author 293 "%s" // author
297 "%s" // keywords 294 "%s" // keywords
298 "<xmpMM:DocumentID>uuid:%s</xmpMM:DocumentID>\n" 295 "<xmpMM:DocumentID>uuid:%s</xmpMM:DocumentID>\n"
299 "<xmpMM:InstanceID>uuid:%s</xmpMM:InstanceID>\n" 296 "<xmpMM:InstanceID>uuid:%s</xmpMM:InstanceID>\n"
300 "<pdf:Producer>Skia/PDF</pdf:Producer>\n" 297 "<pdf:Producer>Skia/PDF m" SKPDF_STRING(SK_MILESTONE) "</pdf:Produce r>\n"
301 "%s" // pdf:Keywords 298 "%s" // pdf:Keywords
302 "</rdf:Description>\n" 299 "</rdf:Description>\n"
303 "</rdf:RDF>\n" 300 "</rdf:RDF>\n"
304 "</x:xmpmeta>\n" // Note: the standard suggests 4k of padding. 301 "</x:xmpmeta>\n" // Note: the standard suggests 4k of padding.
305 "<?xpacket end=\"w\"?>\n"; 302 "<?xpacket end=\"w\"?>\n";
306 303
307 SkString creationDate; 304 SkString creationDate;
308 SkString modificationDate; 305 SkString modificationDate;
309 SkString metadataDate; 306 SkString metadataDate;
310 if (fCreation) { 307 if (fCreation) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 SkString instanceID = uuid_to_string(instance); 346 SkString instanceID = uuid_to_string(instance);
350 SkASSERT(0 == count_xml_escape_size(instanceID)); 347 SkASSERT(0 == count_xml_escape_size(instanceID));
351 return new PDFXMLObject(sk_string_printf( 348 return new PDFXMLObject(sk_string_printf(
352 templateString, modificationDate.c_str(), creationDate.c_str(), 349 templateString, modificationDate.c_str(), creationDate.c_str(),
353 metadataDate.c_str(), creator.c_str(), title.c_str(), 350 metadataDate.c_str(), creator.c_str(), title.c_str(),
354 subject.c_str(), author.c_str(), keywords1.c_str(), 351 subject.c_str(), author.c_str(), keywords1.c_str(),
355 documentID.c_str(), instanceID.c_str(), keywords2.c_str())); 352 documentID.c_str(), instanceID.c_str(), keywords2.c_str()));
356 } 353 }
357 354
358 #endif // SK_PDF_GENERATE_PDFA 355 #endif // SK_PDF_GENERATE_PDFA
356
357 #undef SKPDF_STRING
358 #undef SKPDF_STRING_IMPL
359
OLDNEW
« no previous file with comments | « src/pdf/SkPDFDocument.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698