|
| 1 | +// Copyright (c) 2017 The Chromium Embedded Framework Authors. All rights |
| 2 | +// reserved. Use of this source code is governed by a BSD-style license that |
| 3 | +// can be found in the LICENSE file. |
| 4 | + |
| 5 | +package org.cef.misc; |
| 6 | + |
| 7 | +/** |
| 8 | + * PDF print settings for browser.printToPDF() |
| 9 | + */ |
| 10 | +public class CefPdfPrintSettings { |
| 11 | + |
| 12 | + public enum MarginType { |
| 13 | + // Default margins. |
| 14 | + DEFAULT, |
| 15 | + |
| 16 | + // No margins |
| 17 | + NONE, |
| 18 | + |
| 19 | + // Minimum margins. |
| 20 | + MINIMUM, |
| 21 | + |
| 22 | + // Custom margins using the values from CefPdfPrintSettings |
| 23 | + CUSTOM |
| 24 | + } |
| 25 | + |
| 26 | + /** |
| 27 | + * Set to true to print headers and footers or false to not print |
| 28 | + * headers and footers. |
| 29 | + */ |
| 30 | + public boolean header_footer_enabled; |
| 31 | + |
| 32 | + /** |
| 33 | + * Page title to display in the header. Only used if header_footer_enabled |
| 34 | + * is set to true. |
| 35 | + */ |
| 36 | + public String header_footer_title; |
| 37 | + |
| 38 | + /** |
| 39 | + * URL to display in the footer. Only used if header_footer_enabled is set |
| 40 | + * to true. |
| 41 | + */ |
| 42 | + public String header_footer_url; |
| 43 | + |
| 44 | + /** |
| 45 | + * Set to true for landscape mode or false for portrait mode. |
| 46 | + */ |
| 47 | + public boolean landscape; |
| 48 | + |
| 49 | + /** |
| 50 | + * Set to true to print background graphics or false to not print |
| 51 | + * background graphics. |
| 52 | + */ |
| 53 | + public boolean backgrounds_enabled; |
| 54 | + |
| 55 | + /** |
| 56 | + * Output page size in microns (1 millimeter = 1000 microns). If either of these |
| 57 | + * values is less than or equal to zero then the default paper size will be |
| 58 | + * used as returned by the print_handler. A4 is 210 × 297 mm which would |
| 59 | + * be 210000 x 297000 microns. US Letter is 215.9 × 279.4 mm which would |
| 60 | + * be 215900 x 279400 microns. |
| 61 | + */ |
| 62 | + public int page_width; |
| 63 | + public int page_height; |
| 64 | + |
| 65 | + /** |
| 66 | + * Set to true to print the selection only or false to print all. |
| 67 | + */ |
| 68 | + public boolean selection_only; |
| 69 | + |
| 70 | + /** |
| 71 | + * The percentage to scale the PDF by before printing (e.g. 50 is 50%). |
| 72 | + * If this value is less than or equal to zero the default value of 100 |
| 73 | + * will be used. |
| 74 | + */ |
| 75 | + public int scale_factor; |
| 76 | + |
| 77 | + /** |
| 78 | + * Margins in millimeters. Only used if |margin_type| is set to |
| 79 | + * PDF_PRINT_MARGIN_CUSTOM. |
| 80 | + */ |
| 81 | + public double margin_top; |
| 82 | + public double margin_right; |
| 83 | + public double margin_bottom; |
| 84 | + public double margin_left; |
| 85 | + |
| 86 | + /** |
| 87 | + * Margin type. |
| 88 | + */ |
| 89 | + public MarginType margin_type; |
| 90 | + |
| 91 | + public CefPdfPrintSettings() {} |
| 92 | + |
| 93 | + @Override |
| 94 | + public CefPdfPrintSettings clone() { |
| 95 | + CefPdfPrintSettings tmp = new CefPdfPrintSettings(); |
| 96 | + tmp.header_footer_enabled = this.header_footer_enabled; |
| 97 | + tmp.header_footer_title = this.header_footer_title; |
| 98 | + tmp.header_footer_url = this.header_footer_url; |
| 99 | + tmp.landscape = this.landscape; |
| 100 | + tmp.backgrounds_enabled = this.backgrounds_enabled; |
| 101 | + tmp.page_width = this.page_width; |
| 102 | + tmp.page_height = this.page_height; |
| 103 | + tmp.selection_only = this.selection_only; |
| 104 | + tmp.scale_factor = this.scale_factor; |
| 105 | + tmp.margin_top = this.margin_top; |
| 106 | + tmp.margin_right = this.margin_right; |
| 107 | + tmp.margin_bottom = this.margin_bottom; |
| 108 | + tmp.margin_left = this.margin_left; |
| 109 | + tmp.margin_type = this.margin_type; |
| 110 | + return tmp; |
| 111 | + } |
| 112 | +} |
0 commit comments