| |
The WEBVIEW_PRINT_SETTINGS structure specifies options to
use when printing a document or saving a document in PDF format.
typedef struct _WEBVIEW_PRINT_SETTINGS
{
DWORD dwSize;
DWORD dwFlags;
DOUBLE dPageWidth;
DOUBLE dPageHeight;
DOUBLE dMarginLeft;
DOUBLE dMarginTop;
DOUBLE dMarginRight;
DOUBLE dMarginBottom;
DOUBLE dScale;
INT nOrientation;
INT nColorMode;
INT nCopies;
INT nDuplex;
INT nPagesPerSide;
INT nCollation;
LPCTSTR lpszPrinter;
LPCTSTR lpszRanges;
LPCTSTR lpszHeaderText;
LPCTSTR lpszFooterText;
} WEBVIEW_PRINT_SETTINGS, *LPWEBVIEW_PRINT_SETTINGS;
Members
- dwSize
- Specifies the size of the structure in bytes. Initialize this
member to
sizeof(WEBVIEW_PRINT_SETTINGS) before passing the
structure to a method.
- dwFlags
- Specifies which optional settings are enabled. This member can
be zero, or a combination of the following flags using the bitwise
OR operator. These flags control the page dimensions, margins,
scaling, backgrounds, and headers and footers. The other members
are interpreted independently of these flags as described below.
| Name |
Description |
| WEBVIEW_PRINT_FLAG_DEFAULT |
Zero. Does not override the page dimensions, margins, or
scaling. Backgrounds and headers and footers are disabled.
Other members can still override their respective settings. |
| WEBVIEW_PRINT_FLAG_MARGINS |
Uses all four margin members. Zero specifies no margin;
negative or invalid values are converted to zero. |
| WEBVIEW_PRINT_FLAG_PAGE_SIZE |
Uses the page width and height members. Invalid dimensions
are replaced with the library default dimensions. For printer
output, custom media is selected only if at least one of the
original dimension members is non-zero. See Remarks. |
| WEBVIEW_PRINT_FLAG_SCALE |
Uses the scale member when it is finite and non-zero.
Values outside the supported range are limited to that range.
Zero or an invalid value leaves scaling unchanged. |
| WEBVIEW_PRINT_FLAG_BACKGROUND |
Includes document background colors and images. When this
flag is omitted, backgrounds are not included. |
| WEBVIEW_PRINT_FLAG_HEADERS |
Includes both a header and a footer. The header title and
footer URI members can override their text. When this flag
is omitted, neither the header nor the footer is included,
and both text members are ignored. |
- dPageWidth
- Specifies the page width in inches. This member is used only
when
WEBVIEW_PRINT_FLAG_PAGE_SIZE is specified. A
value greater than zero is passed to the runtime. Otherwise,
a default of 8.5 inches is used. When the flag is omitted,
the runtime page width is left unchanged. Printer
output uses the printer's default media unless custom media is
selected. See Remarks.
- dPageHeight
- Specifies the page height in inches. This member is used only
when
WEBVIEW_PRINT_FLAG_PAGE_SIZE is specified. A
value greater than zero is passed to the runtime. Otherwise,
a default height of 11 inches is used. When the flag is omitted,
the runtime page height is left unchanged. Printer
output uses the printer's default media unless custom media is
selected. See Remarks.
- dMarginLeft
- Specifies the left margin in inches. This member is used only
when
WEBVIEW_PRINT_FLAG_MARGINS is specified. Zero specifies
no left margin. Negative or invalid values are converted to
zero. When the flag is omitted, the runtime margin is unchanged;
its initial default is 1 centimeter, approximately 0.39 inches.
- dMarginTop
- Specifies the top margin in inches. This member is used only
when
WEBVIEW_PRINT_FLAG_MARGINS is specified. Zero specifies
no top margin. Negative or invalid values are converted to
zero. When the flag is omitted, the runtime margin is unchanged;
its initial default is 1 centimeter, approximately 0.39 inches.
- dMarginRight
- Specifies the right margin in inches. This member is used only
when
WEBVIEW_PRINT_FLAG_MARGINS is specified. Zero specifies
no right margin. Negative or invalid values are converted to
zero. When the flag is omitted, the runtime margin is unchanged;
its initial default is 1 centimeter, approximately 0.39 inches.
- dMarginBottom
- Specifies the bottom margin in inches. This member is used only
when
WEBVIEW_PRINT_FLAG_MARGINS is specified. Zero specifies
no bottom margin. Negative or invalid values are converted to
zero. When the flag is omitted, the runtime margin is unchanged;
its initial default is 1 centimeter, approximately 0.39 inches.
- dScale
- Specifies the scale factor when
WEBVIEW_PRINT_FLAG_SCALE is specified. A value of 1.0
represents 100 percent, 0.5 represents 50 percent, and 2.0
represents 200 percent. Non-zero values are limited to
the range 0.1 through 2.0, inclusive. This includes negative
values, which are converted to 0.1. Zero or a invalid value
leaves the runtime scale unchanged. The initial runtime default
is 1.0. This member is ignored when the flag is omitted.
- nOrientation
- Specifies the page orientation for printer or PDF output.
This member must be one of the following values. Any other
value is rejected.
| Name |
Description |
| WEBVIEW_PRINT_ORIENTATION_DEFAULT |
Leaves the runtime orientation unchanged. The initial
runtime default is portrait. |
| WEBVIEW_PRINT_ORIENTATION_PORTRAIT |
Uses portrait orientation, with the page taller than it is
wide. |
| WEBVIEW_PRINT_ORIENTATION_LANDSCAPE |
Uses landscape orientation, with the page wider than it is
tall. |
- nColorMode
- Specifies the color mode for printer output using one of the
following values. This member is ignored when saving directly
to PDF.
| Name |
Description |
| WEBVIEW_PRINT_MODE_DEFAULT |
Leaves the color mode unchanged. The initial setting
uses the printer's default color mode. |
| WEBVIEW_PRINT_MODE_COLOR |
Requests color printing, subject to printer support. |
| WEBVIEW_PRINT_MODE_GRAYSCALE |
Requests grayscale printing, subject to printer support. |
- nCopies
- Specifies the number of copies for printer output. Zero
leaves the runtime copy count unchanged; its initial default
is one copy. Nonzero values are limited to the range 1 through
999, inclusive. Negative values are converted to 1, and values
greater than 999 are converted to 999. This member is ignored
when saving directly to PDF.
- nDuplex
- Specifies single-sided or double-sided printer output using
one of the following values. This member is ignored when saving
directly to PDF. The requested mode is subject to printer
support.
| Name |
Description |
| WEBVIEW_PRINT_DUPLEX_DEFAULT |
Leaves the duplex setting unchanged. The initial
runtime setting uses the printer's default duplex mode. |
| WEBVIEW_PRINT_DUPLEX_SIMPLEX |
Prints on one side of each sheet. |
| WEBVIEW_PRINT_DUPLEX_LONG_EDGE |
Prints on both sides of each sheet, with pages turned
along the long edge. |
| WEBVIEW_PRINT_DUPLEX_SHORT_EDGE |
Prints on both sides of each sheet, with pages turned
along the short edge. |
- nPagesPerSide
- Specifies the number of document pages placed on each side
of a sheet for printer output. Valid non-zero values are 1, 2,
4, 6, 9, and 16. Zero leaves this setting unchanged; its initial
runtime default is 1. Any other value is rejected. When combined
with double-sided printing, this count applies separately to
each side. This member is ignored when saving directly to PDF.
- nCollation
- Specifies how multiple copies are ordered for printer output,
using one of the following values. This member is ignored when
saving directly to PDF.
| Name |
Description |
| WEBVIEW_PRINT_COLLATION_DEFAULT |
Leaves collation unchanged. The initial setting uses
the printer's default collation. |
| WEBVIEW_PRINT_COLLATION_COLLATED |
Requests complete document copies in sequence. For
example, two copies of a three-page document are ordered
1, 2, 3, 1, 2, 3. |
| WEBVIEW_PRINT_COLLATION_UNCOLLATED |
Requests copies grouped by page. For example, two copies
of a three-page document are ordered 1, 1, 2, 2, 3, 3. |
- lpszPrinter
- Points to a null-terminated string containing the name of an
installed printer. Leading whitespace is removed before the
name is passed to the runtime; trailing whitespace is retained.
If this member is NULL or an empty string, the printer selection
unchanged. By default, the WebView2 runtime
selects the operating system's default printer. This
member is ignored when saving directly to PDF.
- lpszRanges
- Points to a null-terminated string specifying the pages to
print, such as "1-3, 5, 8-10". Page numbers begin with 1.
Commas separate individual pages or inclusive ranges. An omitted
first endpoint starts at page 1, and an omitted last endpoint
continues through the final page. Repeated pages are printed
once, in ascending order. Invalid or out-of-document selections
can fail when printing is processed. If this member is NULL or
an empty string, the default setting prints all pages. This
member is ignored when saving directly to PDF.
- lpszHeaderText
- Points to a null-terminated string specifying the text
included in the header when
WEBVIEW_PRINT_FLAG_HEADERS
is specified. If this member is NULL, it leaves the page header unchanged; its default is the current document title. An empty string
suppresses the title text without disabling the rest of the
header or footer. This member is ignored when the header flag
is omitted.
- lpszFooterText
- Points to a null-terminated string specifying the text
included in the footer when
WEBVIEW_PRINT_FLAG_HEADERS
is specified. If this member is NULL, it leaves the default footer
unchanged; its default is the current document URI. An empty string
suppresses the document URI without disabling the rest of the header or
footer. This member is ignored when the header flag is omitted.
Remarks
Initialize the entire structure to zero, then set dwSize
and the members required for the operation. For example:
WEBVIEW_PRINT_SETTINGS settings = {};
settings.dwSize = sizeof(settings);
settings.dwFlags = WEBVIEW_PRINT_FLAG_BACKGROUND;
settings.nOrientation = WEBVIEW_PRINT_ORIENTATION_PORTRAIT;
Page dimensions, margins, scaling, orientation, backgrounds,
and headers and footers apply to both printer output and PDF
output. The nColorMode, nCopies,
nDuplex, nPagesPerSide, nCollation,
lpszPrinter, and lpszRanges members
apply only to printer output in this implementation. In particular,
lpszRanges does not restrict the pages saved directly
to PDF, and nColorMode does not request a grayscale PDF.
The optional numeric settings are controlled by their flags.
Specifying a value without its corresponding flag has no effect.
Enabling the margins flag applies all four margins,
including zero-valued members. Enabling the page-size flag
processes both dimensions, replacing each invalid dimension
independently. There is no flag required for orientation or the
printer-only members.
When WEBVIEW_PRINT_FLAG_PAGE_SIZE is specified, printer
output uses custom media with the specified page dimensions.Page width
and height are always normalized. For example, negative values will
cause the default height and/or width to be used. When this flag is
omitted, printer output uses the printer's default media size.
When WEBVIEW_PRINT_FLAG_HEADERS is specified, the
default header includes the printing date and time and the title; the
default footer includes the URI and page number. The lpszHeaderText
and lpszFooterText members replace only their respective text.
Each header and footer occupies approximately 0.2 inches (0.5 centimeters).
If you provide your own header and/or footer for the document, it should
only consist of plain text. Neither value supports the use of HTML
markup, entities or other formatting instructions.
All physical measurements use inches. To convert millimeters to
inches, divide by 25.4. A zero margin requests no margin but does not
guarantee borderless output from a physical printer.
Zero-valued default members generally leave the corresponding
WebView2 runtime settings unchanged. Backgrounds, headers and footers
are explicitly enabled or disabled according to the values specified
with the dwFlags member.
Printer capabilities can limit the requested output. Documents
can fallback to the printer's default for unsupported printer-specific
color, duplex, collation, or media settings. For consistent output,
it's recommended you use the documented values rather than relying
on fallback behavior for arbitrary values. A printer name that does
not identify an installed printer will not be queued for printing.
It is your application's responsibility to ensure the printer name
is valid and available.
WEBVIEW_PRINT_SETTINGS selects
WEBVIEW_PRINT_SETTINGSW when UNICODE is
defined, and WEBVIEW_PRINT_SETTINGSA otherwise. String
members contain wide-character strings in the Unicode structure and
narrow-character strings in the ANSI structure.
Requirements
Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools12.h
Unicode: Implemented as Unicode and ANSI versions
See Also
|
|