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

Side by Side Diff: src/pdf/SkPDFDocument.cpp

Issue 12466008: PDF: add support for named destinations (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « src/pdf/SkPDFDevice.cpp ('k') | src/pdf/SkPDFPage.h » ('j') | 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 /* 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
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
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 }
OLDNEW
« no previous file with comments | « src/pdf/SkPDFDevice.cpp ('k') | src/pdf/SkPDFPage.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698