selenium.driver.print
Page printing options and the W3C /print request body model.
Orientation
enum Orientation: string;
Page orientation for printed output.
Portrait
Portrait
Taller than wide, the W3C default.
Landscape
Landscape
Wider than tall.
PrintOptions
struct PrintOptions;
Options for printing the current page to a PDF document.
orientation
Orientation orientation;
Page orientation, defaulting to portrait.
background
bool background;
Whether to print background graphics, defaulting to false.
shrinkToFit
bool shrinkToFit;
Whether to shrink content to fit the page, defaulting to true.
pageRanges
string[] pageRanges;
Page ranges to print.
pageWidth
@property double pageWidth() const;
Paper width in centimeters, defaulting to 21.59 (US Letter).
pageWidth
@property double pageWidth(double val);
Sets the paper width.
Parameters:
| Name | Description |
|---|---|
double val |
The width in centimeters, must be at least 2.54/72 (1 point). |
Throws: InvalidArgumentException if val is less than 2.54/72.
pageHeight
@property double pageHeight() const;
Paper height in centimeters, defaulting to 27.94 (US Letter).
pageHeight
@property double pageHeight(double val);
Sets the paper height.
Parameters:
| Name | Description |
|---|---|
double val |
The height in centimeters, must be at least 2.54/72 (1 point). |
Throws: InvalidArgumentException if val is less than 2.54/72.
marginTop
@property double marginTop() const;
Top page margin in centimeters, defaulting to 1.0.
marginTop
@property double marginTop(double val);
Sets the top page margin.
Parameters:
| Name | Description |
|---|---|
double val |
The margin in centimeters, must not be negative. |
Throws: InvalidArgumentException if val is negative.
marginBottom
@property double marginBottom() const;
Bottom page margin in centimeters, defaulting to 1.0.
marginBottom
@property double marginBottom(double val);
Sets the bottom page margin. See marginTop for validation.
marginLeft
@property double marginLeft() const;
Left page margin in centimeters, defaulting to 1.0.
marginLeft
@property double marginLeft(double val);
Sets the left page margin. See marginTop for validation.
marginRight
@property double marginRight() const;
Right page margin in centimeters, defaulting to 1.0.
marginRight
@property double marginRight(double val);
Sets the right page margin. See marginTop for validation.
scale
@property double scale() const;
Scale factor clamped to the range 0.1 through 2.0, defaulting to 1.0.
scale
@property double scale(double val);
Sets the print scale.
Parameters:
| Name | Description |
|---|---|
double val |
The scale factor, clamped to the range 0.1 through 2.0. |
Throws: InvalidArgumentException if val is outside 0.1 through 2.0.
toJSON
JSONValue toJSON() const;
Serializes the options into the W3C /print request body.
pageRanges is omitted when empty so the server prints every page.