Add PDF printing support (issue #1478).

This commit is contained in:
Alexei Bykov
2015-03-24 18:40:08 +03:00
committed by Marshall Greenblatt
parent b6e5310bce
commit 85f83680d7
42 changed files with 1039 additions and 24 deletions

View File

@@ -2194,6 +2194,92 @@ typedef enum {
JSON_WRITER_PRETTY_PRINT = 1 << 2,
} cef_json_writer_options_t;
///
// Margin type for PDF printing.
///
typedef enum {
///
// Default margins.
///
PDF_PRINT_MARGIN_DEFAULT,
///
// No margins.
///
PDF_PRINT_MARGIN_NONE,
///
// Minimum margins.
///
PDF_PRINT_MARGIN_MINIMUM,
///
// Custom margins using the |margin_*| values from cef_pdf_print_settings_t.
///
PDF_PRINT_MARGIN_CUSTOM,
} cef_pdf_print_margin_type_t;
///
// Structure representing PDF print settings.
///
typedef struct _cef_pdf_print_settings_t {
///
// Page title to display in the header. Only used if |header_footer_enabled|
// is set to true (1).
///
cef_string_t header_footer_title;
///
// URL to display in the footer. Only used if |header_footer_enabled| is set
// to true (1).
///
cef_string_t header_footer_url;
///
// Output page size in microns. If either of these values is less than or
// equal to zero then the default paper size (A4) will be used.
///
int page_width;
int page_height;
///
// Margins in millimeters. Only used if |margin_type| is set to
// PDF_PRINT_MARGIN_CUSTOM.
///
double margin_top;
double margin_right;
double margin_bottom;
double margin_left;
///
// Margin type.
///
cef_pdf_print_margin_type_t margin_type;
///
// Set to true (1) to print headers and footers or false (0) to not print
// headers and footers.
///
int header_footer_enabled;
///
// Set to true (1) to print the selection only or false (0) to print all.
///
int selection_only;
///
// Set to true (1) for landscape mode or false (0) for portrait mode.
///
int landscape;
///
// Set to true (1) to print background graphics or false (0) to not print
// background graphics.
///
int backgrounds_enabled;
} cef_pdf_print_settings_t;
#ifdef __cplusplus
}
#endif

View File

@@ -822,7 +822,7 @@ class CefPageRange : public CefStructBase<CefPageRangeTraits> {
CefPageRange(const cef_page_range_t& r) // NOLINT(runtime/explicit)
: parent(r) {}
CefPageRange(const CefPageRange& r) // NOLINT(runtime/explicit)
: parent(r) {}
: parent(r) {}
CefPageRange(int from, int to) : parent() {
Set(from, to);
}
@@ -862,4 +862,44 @@ struct CefCursorInfoTraits {
///
typedef CefStructBase<CefCursorInfoTraits> CefCursorInfo;
struct CefPdfPrintSettingsTraits {
typedef cef_pdf_print_settings_t struct_type;
static inline void init(struct_type* s) {}
static inline void clear(struct_type* s) {
cef_string_clear(&s->header_footer_title);
cef_string_clear(&s->header_footer_url);
}
static inline void set(const struct_type* src, struct_type* target,
bool copy) {
cef_string_set(src->header_footer_title.str,
src->header_footer_title.length, &target->header_footer_title, copy);
cef_string_set(src->header_footer_url.str, src->header_footer_url.length,
&target->header_footer_url, copy);
target->page_width = src->page_width;
target->page_height = src->page_height;
target->margin_top = src->margin_top;
target->margin_right = src->margin_right;
target->margin_bottom = src->margin_bottom;
target->margin_left = src->margin_left;
target->margin_type = src->margin_type;
target->header_footer_enabled = src->header_footer_enabled;
target->selection_only = src->selection_only;
target->landscape = src->landscape;
target->backgrounds_enabled = src->backgrounds_enabled;
}
};
///
// Class representing PDF print settings
///
typedef CefStructBase<CefPdfPrintSettingsTraits> CefPdfPrintSettings;
#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_WRAPPERS_H_