| 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 2443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2454 } | 2454 } |
| 2455 | 2455 |
| 2456 int PDFiumEngine::GetCopiesToPrint() { | 2456 int PDFiumEngine::GetCopiesToPrint() { |
| 2457 return FPDF_VIEWERREF_GetNumCopies(doc_); | 2457 return FPDF_VIEWERREF_GetNumCopies(doc_); |
| 2458 } | 2458 } |
| 2459 | 2459 |
| 2460 int PDFiumEngine::GetDuplexType() { | 2460 int PDFiumEngine::GetDuplexType() { |
| 2461 return static_cast<int>(FPDF_VIEWERREF_GetDuplex(doc_)); | 2461 return static_cast<int>(FPDF_VIEWERREF_GetDuplex(doc_)); |
| 2462 } | 2462 } |
| 2463 | 2463 |
| 2464 bool PDFiumEngine::GetPageSizeAndUniformity(pp::Size* size) { |
| 2465 if (pages_.empty()) |
| 2466 return false; |
| 2467 |
| 2468 pp::Size page_size = GetPageSize(0); |
| 2469 for (size_t i = 1; i < pages_.size(); ++i) { |
| 2470 if (page_size != GetPageSize(i)) |
| 2471 return false; |
| 2472 } |
| 2473 |
| 2474 // Convert |page_size| back to points. |
| 2475 size->set_width( |
| 2476 ConvertUnit(page_size.width(), kPixelsPerInch, kPointsPerInch)); |
| 2477 size->set_height( |
| 2478 ConvertUnit(page_size.height(), kPixelsPerInch, kPointsPerInch)); |
| 2479 return true; |
| 2480 } |
| 2481 |
| 2464 void PDFiumEngine::AppendBlankPages(int num_pages) { | 2482 void PDFiumEngine::AppendBlankPages(int num_pages) { |
| 2465 DCHECK(num_pages != 0); | 2483 DCHECK(num_pages != 0); |
| 2466 | 2484 |
| 2467 if (!doc_) | 2485 if (!doc_) |
| 2468 return; | 2486 return; |
| 2469 | 2487 |
| 2470 selection_.clear(); | 2488 selection_.clear(); |
| 2471 pending_pages_.clear(); | 2489 pending_pages_.clear(); |
| 2472 | 2490 |
| 2473 // Delete all pages except the first one. | 2491 // Delete all pages except the first one. |
| (...skipping 1524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3998 double* height) { | 4016 double* height) { |
| 3999 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); | 4017 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); |
| 4000 if (!doc) | 4018 if (!doc) |
| 4001 return false; | 4019 return false; |
| 4002 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; | 4020 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; |
| 4003 FPDF_CloseDocument(doc); | 4021 FPDF_CloseDocument(doc); |
| 4004 return success; | 4022 return success; |
| 4005 } | 4023 } |
| 4006 | 4024 |
| 4007 } // namespace chrome_pdf | 4025 } // namespace chrome_pdf |
| OLD | NEW |