OLD | NEW |
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 "SkMD5.h" | 8 #include "SkMD5.h" |
9 #include "SkMilestone.h" | 9 #include "SkMilestone.h" |
10 #include "SkPDFMetadata.h" | 10 #include "SkPDFMetadata.h" |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 SkASSERT(data == uuid.fData + 16); | 161 SkASSERT(data == uuid.fData + 16); |
162 return SkString(buffer, 36); | 162 return SkString(buffer, 36); |
163 } | 163 } |
164 #undef HEXIFY | 164 #undef HEXIFY |
165 | 165 |
166 namespace { | 166 namespace { |
167 class PDFXMLObject final : public SkPDFObject { | 167 class PDFXMLObject final : public SkPDFObject { |
168 public: | 168 public: |
169 PDFXMLObject(SkString xml) : fXML(std::move(xml)) {} | 169 PDFXMLObject(SkString xml) : fXML(std::move(xml)) {} |
170 void emitObject(SkWStream* stream, | 170 void emitObject(SkWStream* stream, |
171 const SkPDFObjNumMap& omap, | 171 const SkPDFObjNumMap& omap) const override { |
172 const SkPDFSubstituteMap& smap) const override { | |
173 SkPDFDict dict("Metadata"); | 172 SkPDFDict dict("Metadata"); |
174 dict.insertName("Subtype", "XML"); | 173 dict.insertName("Subtype", "XML"); |
175 dict.insertInt("Length", fXML.size()); | 174 dict.insertInt("Length", fXML.size()); |
176 dict.emitObject(stream, omap, smap); | 175 dict.emitObject(stream, omap); |
177 static const char streamBegin[] = " stream\n"; | 176 static const char streamBegin[] = " stream\n"; |
178 stream->write(streamBegin, strlen(streamBegin)); | 177 stream->write(streamBegin, strlen(streamBegin)); |
179 // Do not compress this. The standard requires that a | 178 // Do not compress this. The standard requires that a |
180 // program that does not understand PDF can grep for | 179 // program that does not understand PDF can grep for |
181 // "<?xpacket" and extracť the entire XML. | 180 // "<?xpacket" and extracť the entire XML. |
182 stream->write(fXML.c_str(), fXML.size()); | 181 stream->write(fXML.c_str(), fXML.size()); |
183 static const char streamEnd[] = "\nendstream"; | 182 static const char streamEnd[] = "\nendstream"; |
184 stream->write(streamEnd, strlen(streamEnd)); | 183 stream->write(streamEnd, strlen(streamEnd)); |
185 } | 184 } |
186 | 185 |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 templateString, modificationDate.c_str(), creationDate.c_str(), | 333 templateString, modificationDate.c_str(), creationDate.c_str(), |
335 creator.c_str(), title.c_str(), subject.c_str(), author.c_str(), | 334 creator.c_str(), title.c_str(), subject.c_str(), author.c_str(), |
336 keywords1.c_str(), documentID.c_str(), instanceID.c_str(), | 335 keywords1.c_str(), documentID.c_str(), instanceID.c_str(), |
337 producer.c_str(), keywords2.c_str())); | 336 producer.c_str(), keywords2.c_str())); |
338 } | 337 } |
339 | 338 |
340 #undef SKPDF_CUSTOM_PRODUCER_KEY | 339 #undef SKPDF_CUSTOM_PRODUCER_KEY |
341 #undef SKPDF_PRODUCER | 340 #undef SKPDF_PRODUCER |
342 #undef SKPDF_STRING | 341 #undef SKPDF_STRING |
343 #undef SKPDF_STRING_IMPL | 342 #undef SKPDF_STRING_IMPL |
OLD | NEW |