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

Unified Diff: printing/pdf_metafile_cg_mac.cc

Issue 8585017: PrintPreview: Honor the print media page size and margin values. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed review comments Created 8 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: printing/pdf_metafile_cg_mac.cc
diff --git a/printing/pdf_metafile_cg_mac.cc b/printing/pdf_metafile_cg_mac.cc
index 78c1110a8eb13f82b04034c21b6915ff4d156195..bf2f68dd5942d66da747c64170451110aa1d8721 100644
--- a/printing/pdf_metafile_cg_mac.cc
+++ b/printing/pdf_metafile_cg_mac.cc
@@ -202,20 +202,16 @@ bool PdfMetafileCg::RenderPage(unsigned int page_number,
}
}
// Some PDFs have a non-zero origin. Need to take that into account.
- float x_offset = rect.origin.x - (source_rect.origin.x * scaling_factor);
- float y_offset = rect.origin.y - (source_rect.origin.y * scaling_factor);
+ float x_offset = -1 * source_rect.origin.x * scaling_factor;
+ float y_offset = -1 * source_rect.origin.y * scaling_factor;
- if (center_vertically) {
+ if (center_horizontally) {
x_offset += (rect.size.width -
(source_rect.size.width * scaling_factor))/2;
}
- if (center_horizontally) {
+ if (center_vertically) {
y_offset += (rect.size.height -
(source_rect.size.height * scaling_factor))/2;
- } else {
- // Since 0 y begins at the bottom, we need to adjust so the output appears
- // nearer the top if we are not centering horizontally.
- y_offset += rect.size.height - (source_rect.size.height * scaling_factor);
}
CGContextSaveGState(context);
CGContextTranslateCTM(context, x_offset, y_offset);

Powered by Google App Engine
This is Rietveld 408576698