| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <fstream> | 6 #include <fstream> |
| 7 #include <iostream> | 7 #include <iostream> |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 std::string pdf_data; | 361 std::string pdf_data; |
| 362 | 362 |
| 363 ASSERT_TRUE(base::ReadFileToString(pdf_file_save_path_, &pdf_data)); | 363 ASSERT_TRUE(base::ReadFileToString(pdf_file_save_path_, &pdf_data)); |
| 364 ASSERT_TRUE(pdf_doc_info_func_(pdf_data.data(), | 364 ASSERT_TRUE(pdf_doc_info_func_(pdf_data.data(), |
| 365 pdf_data.size(), | 365 pdf_data.size(), |
| 366 &num_pages, | 366 &num_pages, |
| 367 &max_width_in_points)); | 367 &max_width_in_points)); |
| 368 | 368 |
| 369 ASSERT_GT(num_pages, 0); | 369 ASSERT_GT(num_pages, 0); |
| 370 double max_width_in_pixels = | 370 double max_width_in_pixels = |
| 371 ConvertPointsToPixelDouble(max_width_in_points); | 371 ConvertUnitDouble(max_width_in_points, kPointsPerInch, kDpi); |
| 372 | 372 |
| 373 for (int i = 0; i < num_pages; ++i) { | 373 for (int i = 0; i < num_pages; ++i) { |
| 374 double width_in_points, height_in_points; | 374 double width_in_points, height_in_points; |
| 375 ASSERT_TRUE(pdf_page_size_func_(pdf_data.data(), | 375 ASSERT_TRUE(pdf_page_size_func_(pdf_data.data(), |
| 376 pdf_data.size(), | 376 pdf_data.size(), |
| 377 i, | 377 i, |
| 378 &width_in_points, | 378 &width_in_points, |
| 379 &height_in_points)); | 379 &height_in_points)); |
| 380 | 380 |
| 381 double width_in_pixels = ConvertPointsToPixelDouble(width_in_points); | 381 double width_in_pixels = ConvertUnitDouble( |
| 382 double height_in_pixels = ConvertPointsToPixelDouble(height_in_points); | 382 width_in_points, kPointsPerInch, kDpi); |
| 383 double height_in_pixels = ConvertUnitDouble( |
| 384 height_in_points, kPointsPerInch, kDpi); |
| 383 | 385 |
| 384 // The image will be rotated if |width_in_pixels| is greater than | 386 // The image will be rotated if |width_in_pixels| is greater than |
| 385 // |height_in_pixels|. This is because the page will be rotated to fit | 387 // |height_in_pixels|. This is because the page will be rotated to fit |
| 386 // within a piece of paper. Therefore, |width_in_pixels| and | 388 // within a piece of paper. Therefore, |width_in_pixels| and |
| 387 // |height_in_pixels| have to be swapped or else they won't reflect the | 389 // |height_in_pixels| have to be swapped or else they won't reflect the |
| 388 // dimensions of the rotated page. | 390 // dimensions of the rotated page. |
| 389 if (width_in_pixels > height_in_pixels) | 391 if (width_in_pixels > height_in_pixels) |
| 390 std::swap(width_in_pixels, height_in_pixels); | 392 std::swap(width_in_pixels, height_in_pixels); |
| 391 | 393 |
| 392 total_height_in_pixels += height_in_pixels; | 394 total_height_in_pixels += height_in_pixels; |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 692 // waiting for this message and start waiting for the image data. | 694 // waiting for this message and start waiting for the image data. |
| 693 std::cout << "#EOF\n"; | 695 std::cout << "#EOF\n"; |
| 694 std::cout.flush(); | 696 std::cout.flush(); |
| 695 | 697 |
| 696 SendPng(); | 698 SendPng(); |
| 697 Reset(); | 699 Reset(); |
| 698 } | 700 } |
| 699 } | 701 } |
| 700 | 702 |
| 701 } // namespace printing | 703 } // namespace printing |
| OLD | NEW |