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/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 3382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3393 | 3393 |
3394 // A temporary hack. PDFs generated by Cairo (used by Chrome OS to generate | 3394 // A temporary hack. PDFs generated by Cairo (used by Chrome OS to generate |
3395 // a PDF output from a webpage) result in very large metafiles and the | 3395 // a PDF output from a webpage) result in very large metafiles and the |
3396 // rendering using FPDF_RenderPage is incorrect. In this case, render as a | 3396 // rendering using FPDF_RenderPage is incorrect. In this case, render as a |
3397 // bitmap. Note that this code does not kick in for PDFs printed from Chrome | 3397 // bitmap. Note that this code does not kick in for PDFs printed from Chrome |
3398 // because in that case we create a temp PDF first before printing and this | 3398 // because in that case we create a temp PDF first before printing and this |
3399 // temp PDF does not have a creator string that starts with "cairo". | 3399 // temp PDF does not have a creator string that starts with "cairo". |
3400 base::string16 creator; | 3400 base::string16 creator; |
3401 size_t buffer_bytes = FPDF_GetMetaText(doc, "Creator", NULL, 0); | 3401 size_t buffer_bytes = FPDF_GetMetaText(doc, "Creator", NULL, 0); |
3402 if (buffer_bytes > 1) { | 3402 if (buffer_bytes > 1) { |
3403 FPDF_GetMetaText(doc, "Creator", WriteInto(&creator, buffer_bytes), | 3403 FPDF_GetMetaText( |
3404 buffer_bytes); | 3404 doc, "Creator", WriteInto(&creator, buffer_bytes), buffer_bytes + 1); |
gene
2014/09/25 18:18:56
Are you sure, you are adding +1 in the GetMetaText
Deepak
2014/09/26 03:02:38
Thanks gene for review,After close examination I f
| |
3405 } | 3405 } |
3406 bool use_bitmap = false; | 3406 bool use_bitmap = false; |
3407 if (StartsWith(creator, L"cairo", false)) | 3407 if (StartsWith(creator, L"cairo", false)) |
3408 use_bitmap = true; | 3408 use_bitmap = true; |
3409 | 3409 |
3410 // Another temporary hack. Some PDFs seems to render very slowly if | 3410 // Another temporary hack. Some PDFs seems to render very slowly if |
3411 // FPDF_RenderPage is directly used on a printer DC. I suspect it is | 3411 // FPDF_RenderPage is directly used on a printer DC. I suspect it is |
3412 // because of the code to talk Postscript directly to the printer if | 3412 // because of the code to talk Postscript directly to the printer if |
3413 // the printer supports this. Need to discuss this with PDFium. For now, | 3413 // the printer supports this. Need to discuss this with PDFium. For now, |
3414 // render to a bitmap and then blit the bitmap to the DC if we have been | 3414 // 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... | |
3518 double* height) { | 3518 double* height) { |
3519 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); | 3519 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); |
3520 if (!doc) | 3520 if (!doc) |
3521 return false; | 3521 return false; |
3522 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; | 3522 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; |
3523 FPDF_CloseDocument(doc); | 3523 FPDF_CloseDocument(doc); |
3524 return success; | 3524 return success; |
3525 } | 3525 } |
3526 | 3526 |
3527 } // namespace chrome_pdf | 3527 } // namespace chrome_pdf |
OLD | NEW |