| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "pdf/pdfium/pdfium_engine.h" | 5 #include "pdf/pdfium/pdfium_engine.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include "base/i18n/icu_encoding_detection.h" | 9 #include "base/i18n/icu_encoding_detection.h" |
| 10 #include "base/i18n/icu_string_conversions.h" | 10 #include "base/i18n/icu_string_conversions.h" |
| (...skipping 3895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3906 | 3906 |
| 3907 // A temporary hack. PDFs generated by Cairo (used by Chrome OS to generate | 3907 // A temporary hack. PDFs generated by Cairo (used by Chrome OS to generate |
| 3908 // a PDF output from a webpage) result in very large metafiles and the | 3908 // a PDF output from a webpage) result in very large metafiles and the |
| 3909 // rendering using FPDF_RenderPage is incorrect. In this case, render as a | 3909 // rendering using FPDF_RenderPage is incorrect. In this case, render as a |
| 3910 // bitmap. Note that this code does not kick in for PDFs printed from Chrome | 3910 // bitmap. Note that this code does not kick in for PDFs printed from Chrome |
| 3911 // because in that case we create a temp PDF first before printing and this | 3911 // because in that case we create a temp PDF first before printing and this |
| 3912 // temp PDF does not have a creator string that starts with "cairo". | 3912 // temp PDF does not have a creator string that starts with "cairo". |
| 3913 base::string16 creator; | 3913 base::string16 creator; |
| 3914 size_t buffer_bytes = FPDF_GetMetaText(doc, "Creator", NULL, 0); | 3914 size_t buffer_bytes = FPDF_GetMetaText(doc, "Creator", NULL, 0); |
| 3915 if (buffer_bytes > 1) { | 3915 if (buffer_bytes > 1) { |
| 3916 FPDF_GetMetaText( | 3916 FPDF_GetMetaText(doc, "Creator", |
| 3917 doc, "Creator", WriteInto(&creator, buffer_bytes + 1), buffer_bytes); | 3917 base::WriteInto(&creator, buffer_bytes + 1), buffer_bytes); |
| 3918 } | 3918 } |
| 3919 bool use_bitmap = false; | 3919 bool use_bitmap = false; |
| 3920 if (base::StartsWith(creator, L"cairo", base::CompareCase::INSENSITIVE_ASCII)) | 3920 if (base::StartsWith(creator, L"cairo", base::CompareCase::INSENSITIVE_ASCII)) |
| 3921 use_bitmap = true; | 3921 use_bitmap = true; |
| 3922 | 3922 |
| 3923 // Another temporary hack. Some PDFs seems to render very slowly if | 3923 // Another temporary hack. Some PDFs seems to render very slowly if |
| 3924 // FPDF_RenderPage is directly used on a printer DC. I suspect it is | 3924 // FPDF_RenderPage is directly used on a printer DC. I suspect it is |
| 3925 // because of the code to talk Postscript directly to the printer if | 3925 // because of the code to talk Postscript directly to the printer if |
| 3926 // the printer supports this. Need to discuss this with PDFium. For now, | 3926 // the printer supports this. Need to discuss this with PDFium. For now, |
| 3927 // render to a bitmap and then blit the bitmap to the DC if we have been | 3927 // render to a bitmap and then blit the bitmap to the DC if we have been |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4031 double* height) { | 4031 double* height) { |
| 4032 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); | 4032 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); |
| 4033 if (!doc) | 4033 if (!doc) |
| 4034 return false; | 4034 return false; |
| 4035 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; | 4035 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; |
| 4036 FPDF_CloseDocument(doc); | 4036 FPDF_CloseDocument(doc); |
| 4037 return success; | 4037 return success; |
| 4038 } | 4038 } |
| 4039 | 4039 |
| 4040 } // namespace chrome_pdf | 4040 } // namespace chrome_pdf |
| OLD | NEW |