| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkCanvas.h" | 8 #include "SkCanvas.h" |
| 9 #include "SkDevice.h" | 9 #include "SkDevice.h" |
| 10 #include "SkForceLinking.h" | 10 #include "SkForceLinking.h" |
| (...skipping 1887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1898 // e.g. SkBitmap getPage(int page); | 1898 // e.g. SkBitmap getPage(int page); |
| 1899 // int formsCount(); | 1899 // int formsCount(); |
| 1900 // SkForm getForm(int formID); // SkForm(SkRect, .. other data) | 1900 // SkForm getForm(int formID); // SkForm(SkRect, .. other data) |
| 1901 // TODO (edisonn): Add intend when loading pdf, for example: for viewing, parsin
g all content, ... | 1901 // TODO (edisonn): Add intend when loading pdf, for example: for viewing, parsin
g all content, ... |
| 1902 // if we load the first page, and we zoom to fit to screen horizontally, then lo
ad only those | 1902 // if we load the first page, and we zoom to fit to screen horizontally, then lo
ad only those |
| 1903 // resources needed, so the preview is fast. | 1903 // resources needed, so the preview is fast. |
| 1904 // TODO (edisonn): hide parser/tokenizer behind and interface and a query langua
ge, and resolve | 1904 // TODO (edisonn): hide parser/tokenizer behind and interface and a query langua
ge, and resolve |
| 1905 // references automatically. | 1905 // references automatically. |
| 1906 | 1906 |
| 1907 bool SkPdfViewer::load(const SkString inputFileName, SkPicture* out) { | 1907 bool SkPdfViewer::load(const SkString inputFileName, SkPicture* out) { |
| 1908 std::cout << "Init: " << inputFileName.c_str() << std::endl; | 1908 std::cout << "PDF Loaded: " << inputFileName.c_str() << std::endl; |
| 1909 | 1909 |
| 1910 SkNativeParsedPDF* doc = new SkNativeParsedPDF(inputFileName.c_str()); | 1910 SkNativeParsedPDF* doc = new SkNativeParsedPDF(inputFileName.c_str()); |
| 1911 if (!doc->pages()) | 1911 if (!doc->pages()) |
| 1912 { | 1912 { |
| 1913 std::cout << "ERROR: Empty Document" << inputFileName.c_str() << std::en
dl; | 1913 std::cout << "ERROR: Empty PDF Document" << inputFileName.c_str() << std
::endl; |
| 1914 return false; | 1914 return false; |
| 1915 } else { | 1915 } else { |
| 1916 | 1916 |
| 1917 for (int pn = 0; pn < doc->pages(); ++pn) { | 1917 for (int pn = 0; pn < doc->pages(); ++pn) { |
| 1918 // TODO(edisonn): implement inheritance properties as per PDF spec | 1918 // TODO(edisonn): implement inheritance properties as per PDF spec |
| 1919 //SkRect rect = page->MediaBox(); | 1919 //SkRect rect = page->MediaBox(); |
| 1920 SkRect rect = doc->MediaBox(pn); | 1920 SkRect rect = doc->MediaBox(pn); |
| 1921 | 1921 |
| 1922 #ifdef PDF_TRACE | 1922 #ifdef PDF_TRACE |
| 1923 printf("Page Width: %f, Page Height: %f\n", SkScalarToDouble(rect.wi
dth()), SkScalarToDouble(rect.height())); | 1923 printf("Page Width: %f, Page Height: %f\n", SkScalarToDouble(rect.wi
dth()), SkScalarToDouble(rect.height())); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1948 out[out.size() - 2] = 'n'; | 1948 out[out.size() - 2] = 'n'; |
| 1949 out[out.size() - 1] = 'g'; | 1949 out[out.size() - 1] = 'g'; |
| 1950 } | 1950 } |
| 1951 SkImageEncoder::EncodeFile(out.c_str(), bitmap, SkImageEncoder::kPNG
_Type, 100); | 1951 SkImageEncoder::EncodeFile(out.c_str(), bitmap, SkImageEncoder::kPNG
_Type, 100); |
| 1952 } | 1952 } |
| 1953 return true; | 1953 return true; |
| 1954 } | 1954 } |
| 1955 | 1955 |
| 1956 return true; | 1956 return true; |
| 1957 } | 1957 } |
| OLD | NEW |