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

Side by Side Diff: components/printing/renderer/print_web_view_helper.cc

Issue 2524143003: Print Preview: Add option to rasterize PDFs and add JPEG compression. (Closed)
Patch Set: Created 4 years 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "components/printing/renderer/print_web_view_helper.h" 5 #include "components/printing/renderer/print_web_view_helper.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 page_params->printable_area.set_size( 278 page_params->printable_area.set_size(
279 gfx::Size(page_params->printable_area.height(), 279 gfx::Size(page_params->printable_area.height(),
280 page_params->printable_area.width())); 280 page_params->printable_area.width()));
281 } 281 }
282 282
283 void ComputeWebKitPrintParamsInDesiredDpi( 283 void ComputeWebKitPrintParamsInDesiredDpi(
284 const PrintMsg_Print_Params& print_params, 284 const PrintMsg_Print_Params& print_params,
285 blink::WebPrintParams* webkit_print_params) { 285 blink::WebPrintParams* webkit_print_params) {
286 int dpi = GetDPI(&print_params); 286 int dpi = GetDPI(&print_params);
287 webkit_print_params->printerDPI = dpi; 287 webkit_print_params->printerDPI = dpi;
288 webkit_print_params->rasterizePDF = print_params.rasterize_pdf;
288 webkit_print_params->printScalingOption = print_params.print_scaling_option; 289 webkit_print_params->printScalingOption = print_params.print_scaling_option;
289 290
290 webkit_print_params->printContentArea.width = ConvertUnit( 291 webkit_print_params->printContentArea.width = ConvertUnit(
291 print_params.content_size.width(), dpi, print_params.desired_dpi); 292 print_params.content_size.width(), dpi, print_params.desired_dpi);
292 webkit_print_params->printContentArea.height = ConvertUnit( 293 webkit_print_params->printContentArea.height = ConvertUnit(
293 print_params.content_size.height(), dpi, print_params.desired_dpi); 294 print_params.content_size.height(), dpi, print_params.desired_dpi);
294 295
295 webkit_print_params->printableArea.x = ConvertUnit( 296 webkit_print_params->printableArea.x = ConvertUnit(
296 print_params.printable_area.x(), dpi, print_params.desired_dpi); 297 print_params.printable_area.x(), dpi, print_params.desired_dpi);
297 webkit_print_params->printableArea.y = ConvertUnit( 298 webkit_print_params->printableArea.y = ConvertUnit(
(...skipping 1388 matching lines...) Expand 10 before | Expand all | Expand 10 after
1686 } else { 1687 } else {
1687 source_is_html = !PrintingNodeOrPdfFrame(frame, node); 1688 source_is_html = !PrintingNodeOrPdfFrame(frame, node);
1688 } 1689 }
1689 1690
1690 if (print_for_preview_ || !source_is_html) { 1691 if (print_for_preview_ || !source_is_html) {
1691 modified_job_settings.MergeDictionary(job_settings); 1692 modified_job_settings.MergeDictionary(job_settings);
1692 modified_job_settings.SetBoolean(kSettingHeaderFooterEnabled, false); 1693 modified_job_settings.SetBoolean(kSettingHeaderFooterEnabled, false);
1693 modified_job_settings.SetInteger(kSettingMarginsType, NO_MARGINS); 1694 modified_job_settings.SetInteger(kSettingMarginsType, NO_MARGINS);
1694 job_settings = &modified_job_settings; 1695 job_settings = &modified_job_settings;
1695 } 1696 }
1697 bool raster = false;
1698 job_settings->GetBoolean(kSettingRasterizePdf, &raster);
1696 1699
1697 // Send the cookie so that UpdatePrintSettings can reuse PrinterQuery when 1700 // Send the cookie so that UpdatePrintSettings can reuse PrinterQuery when
1698 // possible. 1701 // possible.
1699 int cookie = 1702 int cookie =
1700 print_pages_params_ ? print_pages_params_->params.document_cookie : 0; 1703 print_pages_params_ ? print_pages_params_->params.document_cookie : 0;
1701 PrintMsg_PrintPages_Params settings; 1704 PrintMsg_PrintPages_Params settings;
1702 bool canceled = false; 1705 bool canceled = false;
1703 Send(new PrintHostMsg_UpdatePrintSettings(routing_id(), cookie, *job_settings, 1706 Send(new PrintHostMsg_UpdatePrintSettings(routing_id(), cookie, *job_settings,
1704 &settings, &canceled)); 1707 &settings, &canceled));
1705 if (canceled) { 1708 if (canceled) {
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
2317 blink::WebConsoleMessage::LevelWarning, message)); 2320 blink::WebConsoleMessage::LevelWarning, message));
2318 return false; 2321 return false;
2319 } 2322 }
2320 2323
2321 void PrintWebViewHelper::ScriptingThrottler::Reset() { 2324 void PrintWebViewHelper::ScriptingThrottler::Reset() {
2322 // Reset counter on successful print. 2325 // Reset counter on successful print.
2323 count_ = 0; 2326 count_ = 0;
2324 } 2327 }
2325 2328
2326 } // namespace printing 2329 } // namespace printing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698