| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #include "SkPDFCatalog.h" | 10 #include "SkPDFCatalog.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 /* TODO(vandebo): output intent | 100 /* TODO(vandebo): output intent |
| 101 SkAutoTUnref<SkPDFDict> outputIntent = new SkPDFDict("OutputIntent"); | 101 SkAutoTUnref<SkPDFDict> outputIntent = new SkPDFDict("OutputIntent"); |
| 102 outputIntent->insert("S", new SkPDFName("GTS_PDFA1"))->unref(); | 102 outputIntent->insert("S", new SkPDFName("GTS_PDFA1"))->unref(); |
| 103 outputIntent->insert("OutputConditionIdentifier", | 103 outputIntent->insert("OutputConditionIdentifier", |
| 104 new SkPDFString("sRGB"))->unref(); | 104 new SkPDFString("sRGB"))->unref(); |
| 105 SkAutoTUnref<SkPDFArray> intentArray = new SkPDFArray; | 105 SkAutoTUnref<SkPDFArray> intentArray = new SkPDFArray; |
| 106 intentArray->append(outputIntent.get()); | 106 intentArray->append(outputIntent.get()); |
| 107 fDocCatalog->insert("OutputIntent", intentArray.get()); | 107 fDocCatalog->insert("OutputIntent", intentArray.get()); |
| 108 */ | 108 */ |
| 109 | 109 |
| 110 SkPDFDict* dests = SkNEW(SkPDFDict); // fPageResources owns reference |
| 111 fCatalog->addObject(dests, true /* onFirstPage */); |
| 112 fPageResources.push(dests); |
| 113 |
| 110 bool firstPage = true; | 114 bool firstPage = true; |
| 111 for (int i = 0; i < fPages.count(); i++) { | 115 for (int i = 0; i < fPages.count(); i++) { |
| 112 int resourceCount = fPageResources.count(); | 116 int resourceCount = fPageResources.count(); |
| 113 fPages[i]->finalizePage(fCatalog.get(), firstPage, &fPageResources); | 117 fPages[i]->finalizePage(fCatalog.get(), firstPage, &fPageResources); |
| 114 addResourcesToCatalog(resourceCount, firstPage, &fPageResources, | 118 addResourcesToCatalog(resourceCount, firstPage, &fPageResources, |
| 115 fCatalog.get()); | 119 fCatalog.get()); |
| 120 fPages[i]->appendDestinations(dests); |
| 116 if (i == 0) { | 121 if (i == 0) { |
| 117 firstPage = false; | 122 firstPage = false; |
| 118 fSecondPageFirstResourceIndex = fPageResources.count(); | 123 fSecondPageFirstResourceIndex = fPageResources.count(); |
| 119 } | 124 } |
| 120 } | 125 } |
| 121 | 126 |
| 127 fDocCatalog->insert("Dests", SkNEW_ARGS(SkPDFObjRef, (dests)))->unref(); |
| 128 |
| 122 // Build font subsetting info before proceeding. | 129 // Build font subsetting info before proceeding. |
| 123 perform_font_subsetting(fCatalog.get(), fPages, &fSubstitutes); | 130 perform_font_subsetting(fCatalog.get(), fPages, &fSubstitutes); |
| 124 | 131 |
| 125 // Figure out the size of things and inform the catalog of file offsets. | 132 // Figure out the size of things and inform the catalog of file offsets. |
| 126 off_t fileOffset = headerSize(); | 133 off_t fileOffset = headerSize(); |
| 127 fileOffset += fCatalog->setFileOffset(fDocCatalog, fileOffset); | 134 fileOffset += fCatalog->setFileOffset(fDocCatalog, fileOffset); |
| 128 fileOffset += fCatalog->setFileOffset(fPages[0], fileOffset); | 135 fileOffset += fCatalog->setFileOffset(fPages[0], fileOffset); |
| 129 fileOffset += fPages[0]->getPageSize(fCatalog.get(), | 136 fileOffset += fPages[0]->getPageSize(fCatalog.get(), |
| 130 (size_t) fileOffset); | 137 (size_t) fileOffset); |
| 131 for (int i = 0; i < fSecondPageFirstResourceIndex; i++) { | 138 for (int i = 0; i < fSecondPageFirstResourceIndex; i++) { |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 fTrailerDict->insertInt("Size", int(objCount)); | 274 fTrailerDict->insertInt("Size", int(objCount)); |
| 268 fTrailerDict->insert("Root", new SkPDFObjRef(fDocCatalog))->unref(); | 275 fTrailerDict->insert("Root", new SkPDFObjRef(fDocCatalog))->unref(); |
| 269 } | 276 } |
| 270 | 277 |
| 271 stream->writeText("trailer\n"); | 278 stream->writeText("trailer\n"); |
| 272 fTrailerDict->emitObject(stream, fCatalog.get(), false); | 279 fTrailerDict->emitObject(stream, fCatalog.get(), false); |
| 273 stream->writeText("\nstartxref\n"); | 280 stream->writeText("\nstartxref\n"); |
| 274 stream->writeBigDecAsText(fXRefFileOffset); | 281 stream->writeBigDecAsText(fXRefFileOffset); |
| 275 stream->writeText("\n%%EOF"); | 282 stream->writeText("\n%%EOF"); |
| 276 } | 283 } |
| OLD | NEW |