@@ -15,97 +15,116 @@ public enum MarginType {
1515 // No margins
1616 NONE ,
1717
18- // Minimum margins.
19- MINIMUM ,
20-
2118 // Custom margins using the values from CefPdfPrintSettings
2219 CUSTOM
2320 }
2421
2522 /**
26- * Set to true to print headers and footers or false to not print
27- * headers and footers.
23+ * Set to true for landscape mode or false for portrait mode.
2824 */
29- public boolean header_footer_enabled ;
25+ public boolean landscape ;
3026
3127 /**
32- * Page title to display in the header. Only used if header_footer_enabled
33- * is set to true .
28+ * Set to true to print background graphics or false to not print
29+ * background graphics .
3430 */
35- public String header_footer_title ;
31+ public boolean print_background ;
3632
3733 /**
38- * URL to display in the footer. Only used if header_footer_enabled is set
39- * to true.
34+ * The percentage to scale the PDF by before printing (e.g. .5 is 50%).
35+ * If this value is less than or equal to zero the default value of 1.0
36+ * will be used.
4037 */
41- public String header_footer_url ;
38+ public double scale ;
4239
4340 /**
44- * Set to true for landscape mode or false for portrait mode.
41+ * Output paper size in inches. If either of these values is less than or
42+ * equal to zero then the default paper size (letter, 8.5 x 11 inches) will
43+ * be used.
4544 */
46- public boolean landscape ;
45+ public double paper_width ;
46+ public double paper_height ;
4747
4848 /**
49- * Set to true to print background graphics or false to not print
50- * background graphics.
49+ * Set to true to prefer page size as defined by css. Defaults to false
50+ * in which case the content will be scaled to fit the paper size.
51+ */
52+ public boolean prefer_css_page_size ;
53+
54+ /**
55+ * Margin type.
5156 */
52- public boolean backgrounds_enabled ;
57+ public MarginType margin_type ;
5358
5459 /**
55- * Output page size in microns (1 millimeter = 1000 microns). If either of these
56- * values is less than or equal to zero then the default paper size will be
57- * used as returned by the print_handler. A4 is 210 x 297 mm which would
58- * be 210000 x 297000 microns. US Letter is 215.9 x 279.4 mm which would
59- * be 215900 x 279400 microns.
60+ * Margins in inches. Only used if margin_type is set to CUSTOM.
6061 */
61- public int page_width ;
62- public int page_height ;
62+ public double margin_top ;
63+ public double margin_right ;
64+ public double margin_bottom ;
65+ public double margin_left ;
6366
6467 /**
65- * Set to true to print the selection only or false to print all.
68+ * Paper ranges to print, one based, e.g., '1-5, 8, 11-13'. Pages are printed
69+ * in the document order, not in the order specified, and no more than once.
70+ * Defaults to empty string, which implies the entire document is printed.
71+ * The page numbers are quietly capped to actual page count of the document,
72+ * and ranges beyond the end of the document are ignored. If this results in
73+ * no pages to print, an error is reported. It is an error to specify a range
74+ * with start greater than end.
6675 */
67- public boolean selection_only ;
76+ public String page_ranges ;
6877
6978 /**
70- * The percentage to scale the PDF by before printing (e.g. 50 is 50%).
71- * If this value is less than or equal to zero the default value of 100
72- * will be used .
79+ * Set to true to print headers and footers or false to not print
80+ * headers and footers. Modify header_template and/ or footer_template to
81+ * customize the display .
7382 */
74- public int scale_factor ;
83+ public boolean display_header_footer ;
7584
7685 /**
77- * Margins in points. Only used if |margin_type| is set to
78- * PDF_PRINT_MARGIN_CUSTOM.
86+ * HTML template for the print header. Only displayed if
87+ * |display_header_footer| is true (1). Should be valid HTML markup with
88+ * the following classes used to inject printing values into them:
89+ *
90+ * - date: formatted print date
91+ * - title: document title
92+ * - url: document location
93+ * - pageNumber: current page number
94+ * - totalPages: total pages in the document
95+ *
96+ * For example, "<span class=title></span>" would generate a span containing
97+ * the title.
7998 */
80- public int margin_top ;
81- public int margin_right ;
82- public int margin_bottom ;
83- public int margin_left ;
99+ public String header_template ;
84100
85101 /**
86- * Margin type.
102+ * HTML template for the print footer. Only displayed if
103+ * |display_header_footer| is true (1). Uses the same format as
104+ * |header_template|.
87105 */
88- public MarginType margin_type ;
106+ public String footer_template ;
89107
90108 public CefPdfPrintSettings () {}
91109
92110 @ Override
93111 public CefPdfPrintSettings clone () {
94112 CefPdfPrintSettings tmp = new CefPdfPrintSettings ();
95- tmp .header_footer_enabled = this .header_footer_enabled ;
96- tmp .header_footer_title = this .header_footer_title ;
97- tmp .header_footer_url = this .header_footer_url ;
98113 tmp .landscape = this .landscape ;
99- tmp .backgrounds_enabled = this .backgrounds_enabled ;
100- tmp .page_width = this .page_width ;
101- tmp .page_height = this .page_height ;
102- tmp .selection_only = this .selection_only ;
103- tmp .scale_factor = this .scale_factor ;
114+ tmp .print_background = this .print_background ;
115+ tmp .scale = this .scale ;
116+ tmp .paper_width = this .paper_width ;
117+ tmp .paper_height = this .paper_height ;
118+ tmp .prefer_css_page_size = this .prefer_css_page_size ;
119+ tmp .margin_type = this .margin_type ;
104120 tmp .margin_top = this .margin_top ;
105- tmp .margin_right = this .margin_right ;
106121 tmp .margin_bottom = this .margin_bottom ;
122+ tmp .margin_right = this .margin_right ;
107123 tmp .margin_left = this .margin_left ;
108- tmp .margin_type = this .margin_type ;
124+ tmp .page_ranges = this .page_ranges ;
125+ tmp .display_header_footer = this .display_header_footer ;
126+ tmp .header_template = this .header_template ;
127+ tmp .footer_template = this .footer_template ;
109128 return tmp ;
110129 }
111130}
0 commit comments