From c2b4638063e34456360cc4baec4cf914df41720c Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Thu, 16 Mar 2017 17:47:40 -0400 Subject: [PATCH] Add PDF print scale factor setting (issue #2106) --- include/internal/cef_types.h | 7 +++++++ include/internal/cef_types_wrappers.h | 2 ++ libcef/browser/printing/print_view_manager.cc | 3 ++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/internal/cef_types.h b/include/internal/cef_types.h index 47c6eb5ee..b275079db 100644 --- a/include/internal/cef_types.h +++ b/include/internal/cef_types.h @@ -2396,6 +2396,13 @@ typedef struct _cef_pdf_print_settings_t { int page_width; int page_height; + /// + // The percentage to scale the PDF by before printing (e.g. 50 is 50%). + // If this value is less than or equal to zero the default value of 100 + // will be used. + /// + int scale_factor; + /// // Margins in millimeters. Only used if |margin_type| is set to // PDF_PRINT_MARGIN_CUSTOM. diff --git a/include/internal/cef_types_wrappers.h b/include/internal/cef_types_wrappers.h index 0c125c965..da41f8d32 100644 --- a/include/internal/cef_types_wrappers.h +++ b/include/internal/cef_types_wrappers.h @@ -945,6 +945,8 @@ struct CefPdfPrintSettingsTraits { target->page_width = src->page_width; target->page_height = src->page_height; + target->scale_factor = src->scale_factor; + target->margin_top = src->margin_top; target->margin_right = src->margin_right; target->margin_bottom = src->margin_bottom; diff --git a/libcef/browser/printing/print_view_manager.cc b/libcef/browser/printing/print_view_manager.cc index 06994563f..d35665527 100644 --- a/libcef/browser/printing/print_view_manager.cc +++ b/libcef/browser/printing/print_view_manager.cc @@ -47,7 +47,8 @@ void FillInDictionaryFromPdfPrintSettings( print_settings.SetInteger(kSettingCopies, 1); print_settings.SetBoolean(kSettingCollate, false); print_settings.SetString(kSettingDeviceName, ""); - print_settings.SetInteger(kSettingScaleFactor, 100); + print_settings.SetInteger(kSettingScaleFactor, + pdf_settings.scale_factor > 0 ? pdf_settings.scale_factor : 100); print_settings.SetBoolean(kSettingGenerateDraftData, false); print_settings.SetBoolean(kSettingPreviewModifiable, false);