CefPrintSettings
Header: cef_print_settings.h
Category: Core APIs
Overview
Foundational interfaces: process bootstrap, browser lifecycle, frames, DOM, requests, and data objects.
CefPrintSettings
Source File: include/cef_print_settings.h
Process / Thread Context: Threading not specified in header. Used from CefPrintHandler callbacks; standard CEF integration is on the browser process UI thread.
Purpose: USER-CALLED library interface representing print job settings (orientation, page ranges, color model, copies, duplex mode, DPI, device, printable area). Created via the static Create() factory and passed to CefPrintHandler callbacks.
Methods
static CefRefPtr<CefPrintSettings> Create()
Return Value: New CefPrintSettings. (Any thread.)
Threading Constraint: Threading constraint not specified in source.
bool IsValid()
Return Value: True if object is valid; do not call other methods if false.
Threading Constraint: Threading constraint not specified in source.
bool IsReadOnly()
Return Value: True if read-only (some APIs expose read-only objects).
Threading Constraint: Threading constraint not specified in source.
void SetOrientation(bool landscape)
Return Value: Sets page orientation.
Threading Constraint: Threading constraint not specified in source.
bool IsLandscape()
Return Value: True if landscape orientation.
Threading Constraint: Threading constraint not specified in source.
void SetPrinterPrintableArea(const CefSize& physical_size_device_units, const CefRect& printable_area_device_units, bool landscape_needs_flip)
void SetPageRanges(const PageRangeList& ranges)
Return Value: Sets page ranges to print.
Threading Constraint: Threading constraint not specified in source.
size_t GetPageRangesCount()
Return Value: Number of page ranges.
Threading Constraint: Threading constraint not specified in source.
void GetPageRanges(PageRangeList& ranges)
Return Value: Retrieves page ranges (count via GetPageRangesCount).
Threading Constraint: Threading constraint not specified in source.
Usage Example
// CefPrintHandler::OnPrintSettings:
void OnPrintSettings(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefPrintSettings> settings,
bool getDefaults) override {
if (!settings->IsValid() || settings->IsReadOnly()) return;
settings->SetOrientation(true); // landscape
settings->SetDPI(300);
settings->SetCopies(1);
settings->SetColorModel(COLOR_MODEL_COLOR);
settings->SetDuplexMode(DUPLEX_MODE_LONG_EDGE);
CefPrintSettings::PageRangeList ranges = {CefRange(0, 4)}; // pages 1-5
settings->SetPageRanges(ranges);
settings->SetSelectionOnly(false);
settings->SetCollate(true);
}
// Construct a fresh settings object (e.g., to pass in CefBrowserHost::Print()):
CefRefPtr<CefPrintSettings> ps = CefPrintSettings::Create();
ps->SetOrientation(false);
// ... populate ...