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 3184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3195 | 3195 |
3196 // Start by assuming that we will draw exactly to the bounds rect | 3196 // Start by assuming that we will draw exactly to the bounds rect |
3197 // specified. | 3197 // specified. |
3198 *dest = settings.bounds; | 3198 *dest = settings.bounds; |
3199 | 3199 |
3200 int rotate = 0; // normal orientation. | 3200 int rotate = 0; // normal orientation. |
3201 | 3201 |
3202 // Auto-rotate landscape pages to print correctly. | 3202 // Auto-rotate landscape pages to print correctly. |
3203 if (settings.autorotate && | 3203 if (settings.autorotate && |
3204 (dest->width() > dest->height()) != (page_width > page_height)) { | 3204 (dest->width() > dest->height()) != (page_width > page_height)) { |
3205 rotate = 1; // 90 degrees clockwise. | 3205 rotate = 3; // 90 degrees counter-clockwise. |
3206 std::swap(page_width, page_height); | 3206 std::swap(page_width, page_height); |
3207 } | 3207 } |
3208 | 3208 |
3209 // See if we need to scale the output | 3209 // See if we need to scale the output |
3210 bool scale_to_bounds = false; | 3210 bool scale_to_bounds = false; |
3211 if (settings.fit_to_bounds && | 3211 if (settings.fit_to_bounds && |
3212 ((page_width > dest->width()) || (page_height > dest->height()))) { | 3212 ((page_width > dest->width()) || (page_height > dest->height()))) { |
3213 scale_to_bounds = true; | 3213 scale_to_bounds = true; |
3214 } else if (settings.stretch_to_bounds && | 3214 } else if (settings.stretch_to_bounds && |
3215 ((page_width < dest->width()) || (page_height < dest->height()))) { | 3215 ((page_width < dest->width()) || (page_height < dest->height()))) { |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3394 if (page_width > *max_page_width) { | 3394 if (page_width > *max_page_width) { |
3395 *max_page_width = page_width; | 3395 *max_page_width = page_width; |
3396 } | 3396 } |
3397 } | 3397 } |
3398 } | 3398 } |
3399 FPDF_CloseDocument(doc); | 3399 FPDF_CloseDocument(doc); |
3400 return true; | 3400 return true; |
3401 } | 3401 } |
3402 | 3402 |
3403 } // namespace chrome_pdf | 3403 } // namespace chrome_pdf |
OLD | NEW |