Properly set the DPI for the "Save to PDF" destination.
Currently, PrintingContext::UsePdfSettings() sets the DPI to the wrong value, and GetPdfCapabilities() does not set it at all. Then UpdatePrintSettings() papers over these problems and override the DPI with the correct value. Stop papering over the problems in UpdatePrintSettings(). Instead, just set the DPI value correctly in the first place in the two problematic functions mentioned above. Change-Id: I3733a725eda26fa408c58234736f3a25967053b1 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3646278 Reviewed-by: Alan Screen <awscreen@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org> Cr-Commit-Position: refs/heads/main@{#1003375}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
3eb9508987
commit
40e28bcba3
chrome/browser/ui/webui/print_preview
printing
@ -148,6 +148,13 @@ base::Value GetPdfCapabilities(
|
||||
}
|
||||
media.SaveTo(&description);
|
||||
|
||||
// DPI value should match PrintingContext::UsePdfSettings().
|
||||
cloud_devices::printer::DpiCapability dpi;
|
||||
dpi.AddDefaultOption(
|
||||
cloud_devices::printer::Dpi(kDefaultPdfDpi, kDefaultPdfDpi),
|
||||
/*is_default=*/true);
|
||||
dpi.SaveTo(&description);
|
||||
|
||||
return std::move(description).ToValue();
|
||||
}
|
||||
|
||||
|
@ -43,6 +43,13 @@ const char kPdfPrinterCapability[] =
|
||||
}
|
||||
]
|
||||
},
|
||||
"dpi": {
|
||||
"option": [ {
|
||||
"horizontal_dpi": 300,
|
||||
"is_default": true,
|
||||
"vertical_dpi": 300
|
||||
} ]
|
||||
},
|
||||
"media_size":{
|
||||
"option":[
|
||||
{
|
||||
|
@ -101,8 +101,9 @@ void PrintingContext::UsePdfSettings() {
|
||||
pdf_settings.Set(kSettingCollate, true);
|
||||
pdf_settings.Set(kSettingCopies, 1);
|
||||
pdf_settings.Set(kSettingColor, static_cast<int>(mojom::ColorModel::kColor));
|
||||
pdf_settings.Set(kSettingDpiHorizontal, kPointsPerInch);
|
||||
pdf_settings.Set(kSettingDpiVertical, kPointsPerInch);
|
||||
// DPI value should match GetPdfCapabilities().
|
||||
pdf_settings.Set(kSettingDpiHorizontal, kDefaultPdfDpi);
|
||||
pdf_settings.Set(kSettingDpiVertical, kDefaultPdfDpi);
|
||||
pdf_settings.Set(kSettingDuplexMode,
|
||||
static_cast<int>(printing::mojom::DuplexMode::kSimplex));
|
||||
pdf_settings.Set(kSettingLandscape, false);
|
||||
@ -152,7 +153,8 @@ mojom::ResultCode PrintingContext::UpdatePrintSettings(
|
||||
if (!open_in_external_preview &&
|
||||
(printer_type == mojom::PrinterType::kPdf ||
|
||||
printer_type == mojom::PrinterType::kExtension)) {
|
||||
settings_->set_dpi(kDefaultPdfDpi);
|
||||
if (printer_type == mojom::PrinterType::kExtension)
|
||||
settings_->set_dpi(kDefaultPdfDpi);
|
||||
gfx::Size paper_size(GetPdfPaperSizeDeviceUnits());
|
||||
if (!settings_->requested_media().size_microns.IsEmpty()) {
|
||||
float device_microns_per_device_unit =
|
||||
|
Reference in New Issue
Block a user