diff options
author | sverrir@chromium.org <sverrir@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-13 14:58:18 +0000 |
---|---|---|
committer | sverrir@chromium.org <sverrir@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-13 14:58:18 +0000 |
commit | be3b19a50ec04d881b3d11ae3c7aac4e7cab4261 (patch) | |
tree | 49e829ce8b8e532a06e7c25d136014acd2f1136e /printing/print_settings.cc | |
parent | 76450600208313cadd05b239123336acbf6620e7 (diff) | |
download | chromium_src-be3b19a50ec04d881b3d11ae3c7aac4e7cab4261.zip chromium_src-be3b19a50ec04d881b3d11ae3c7aac4e7cab4261.tar.gz chromium_src-be3b19a50ec04d881b3d11ae3c7aac4e7cab4261.tar.bz2 |
Fix print margins. This fixes multiple issues that caused incorrect offsets on printers that had a non-printable area (like most physical printers do).
Two basic problems fixed. Firstly the margins where incorrectly calculated and secondly there was missing an offset int the rendering code (PHYSICALOFFSETX/Y is 0,0 when printing).
To track this down I added code to print out all relevant margins for visual inspection (turned off by default).
Chrome now prints using correctly calculated margins and is perfectly aligned on the page!
BUG=http://crbug.com/947, http://crbug.com/1566
TEST=Printing on various printers.
Review URL: http://codereview.chromium.org/155382
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20482 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'printing/print_settings.cc')
-rw-r--r-- | printing/print_settings.cc | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/printing/print_settings.cc b/printing/print_settings.cc index b76821b..4df0483 100644 --- a/printing/print_settings.cc +++ b/printing/print_settings.cc @@ -74,18 +74,23 @@ void PrintSettings::SetPrinterPrintableArea( gfx::Size const& physical_size_pixels, gfx::Rect const& printable_area_pixels) { - int margin_printer_units = ConvertUnit(500, kHundrethsMMPerInch, dpi_); + // Hard-code text_height = 0.5cm = ~1/5 of inch. + int header_footer_text_height = ConvertUnit(500, kHundrethsMMPerInch, dpi_); // Start by setting the user configuration - // Hard-code text_height = 0.5cm = ~1/5 of inch page_setup_pixels_.Init(physical_size_pixels, printable_area_pixels, - margin_printer_units); + header_footer_text_height); - // Now apply user configured settings. + // Default margins 1.0cm = ~2/5 of an inch. + int margin_printer_units = ConvertUnit(1000, kHundrethsMMPerInch, dpi_); + + // Apply default margins (not user configurable just yet). + // Since the font height is half the margin we put the header and footers at + // the font height from the margins. PageMargins margins; - margins.header = margin_printer_units; - margins.footer = margin_printer_units; + margins.header = header_footer_text_height; + margins.footer = header_footer_text_height; margins.left = margin_printer_units; margins.top = margin_printer_units; margins.right = margin_printer_units; |