Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(563)

Side by Side Diff: printing/pdf_metafile_cg_mac.cc

Issue 8072007: PrintPreview: [MAC] Always set the crop box rectangle as print source rectangle. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "printing/pdf_metafile_cg_mac.h" 5 #include "printing/pdf_metafile_cg_mac.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/mac/mac_util.h" 9 #include "base/mac/mac_util.h"
10 #include "base/mac/scoped_cftyperef.h" 10 #include "base/mac/scoped_cftyperef.h"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 bool shrink_to_fit, 173 bool shrink_to_fit,
174 bool stretch_to_fit, 174 bool stretch_to_fit,
175 bool center_horizontally, 175 bool center_horizontally,
176 bool center_vertically) const { 176 bool center_vertically) const {
177 CGPDFDocumentRef pdf_doc = GetPDFDocument(); 177 CGPDFDocumentRef pdf_doc = GetPDFDocument();
178 if (!pdf_doc) { 178 if (!pdf_doc) {
179 LOG(ERROR) << "Unable to create PDF document from data"; 179 LOG(ERROR) << "Unable to create PDF document from data";
180 return false; 180 return false;
181 } 181 }
182 CGPDFPageRef pdf_page = CGPDFDocumentGetPage(pdf_doc, page_number); 182 CGPDFPageRef pdf_page = CGPDFDocumentGetPage(pdf_doc, page_number);
183 CGRect source_rect = CGPDFPageGetBoxRect(pdf_page, kCGPDFMediaBox); 183 CGRect source_rect = CGPDFPageGetBoxRect(pdf_page, kCGPDFCropBox);
184 float scaling_factor = 1.0; 184 float scaling_factor = 1.0;
185 // See if we need to scale the output. 185 // See if we need to scale the output.
186 bool scaling_needed = 186 bool scaling_needed =
187 (shrink_to_fit && ((source_rect.size.width > rect.size.width) || 187 (shrink_to_fit && ((source_rect.size.width > rect.size.width) ||
188 (source_rect.size.height > rect.size.height))) || 188 (source_rect.size.height > rect.size.height))) ||
189 (stretch_to_fit && (source_rect.size.width < rect.size.width) && 189 (stretch_to_fit && (source_rect.size.width < rect.size.width) &&
190 (source_rect.size.height < rect.size.height)); 190 (source_rect.size.height < rect.size.height));
191 if (scaling_needed) { 191 if (scaling_needed) {
192 float x_scaling_factor = rect.size.width / source_rect.size.width; 192 float x_scaling_factor = rect.size.width / source_rect.size.width;
193 float y_scaling_factor = rect.size.height / source_rect.size.height; 193 float y_scaling_factor = rect.size.height / source_rect.size.height;
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 291
292 if (!pdf_doc_.get()) { 292 if (!pdf_doc_.get()) {
293 ScopedCFTypeRef<CGDataProviderRef> pdf_data_provider( 293 ScopedCFTypeRef<CGDataProviderRef> pdf_data_provider(
294 CGDataProviderCreateWithCFData(pdf_data_)); 294 CGDataProviderCreateWithCFData(pdf_data_));
295 pdf_doc_.reset(CGPDFDocumentCreateWithProvider(pdf_data_provider)); 295 pdf_doc_.reset(CGPDFDocumentCreateWithProvider(pdf_data_provider));
296 } 296 }
297 return pdf_doc_.get(); 297 return pdf_doc_.get();
298 } 298 }
299 299
300 } // namespace printing 300 } // namespace printing
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698