共用方式為


interface ICoreWebView2PrintSettings

Note

This reference is no longer being maintained. For the latest API reference, see WebView2 API Reference.

interface ICoreWebView2PrintSettings
  : public IUnknown

Settings used by the PrintToPdf method.

Summary

Members Descriptions
get_FooterUri The URI in the footer if ShouldPrintHeaderAndFooter is TRUE.
get_HeaderTitle The title in the header if ShouldPrintHeaderAndFooter is TRUE.
get_MarginBottom The bottom margin in inches. The default is 1 cm, or ~0.4 inches.
get_MarginLeft The left margin in inches. The default is 1 cm, or ~0.4 inches.
get_MarginRight The right margin in inches. The default is 1 cm, or ~0.4 inches.
get_MarginTop The top margin in inches. The default is 1 cm, or ~0.4 inches.
get_Orientation The orientation can be portrait or landscape.
get_PageHeight The page height in inches. The default height is 11 inches.
get_PageWidth The page width in inches. The default width is 8.5 inches.
get_ScaleFactor The scale factor is a value between 0.1 and 2.0. The default is 1.0.
get_ShouldPrintBackgrounds TRUE if background colors and images should be printed.
get_ShouldPrintHeaderAndFooter TRUE if header and footer should be printed.
get_ShouldPrintSelectionOnly TRUE if only the current end user's selection of HTML in the document should be printed.
put_FooterUri Set the FooterUri property.
put_HeaderTitle Set the HeaderTitle property.
put_MarginBottom Sets the MarginBottom property.
put_MarginLeft Sets the MarginLeft property.
put_MarginRight Set the MarginRight property.A margin cannot be less than zero.
put_MarginTop Sets the MarginTop property.
put_Orientation Sets the Orientation property.
put_PageHeight Sets the PageHeight property.
put_PageWidth Sets the PageWidth property.
put_ScaleFactor Sets the ScaleFactor property.
put_ShouldPrintBackgrounds Set the ShouldPrintBackgrounds property.
put_ShouldPrintHeaderAndFooter Set the ShouldPrintHeaderAndFooter property.
put_ShouldPrintSelectionOnly Set the ShouldPrintSelectionOnly property.

Applies to

Product Introduced
WebView2 Win32 1.0.1020.30
WebView2 Win32 Prerelease 1.0.1056

Members

get_FooterUri

The URI in the footer if ShouldPrintHeaderAndFooter is TRUE.

public HRESULT get_FooterUri(LPWSTR * footerUri)

The default value is the current URI.

The caller must free the returned string with CoTaskMemFree. See API Conventions.

get_HeaderTitle

The title in the header if ShouldPrintHeaderAndFooter is TRUE.

public HRESULT get_HeaderTitle(LPWSTR * headerTitle)

The default value is the title of the current document.

The caller must free the returned string with CoTaskMemFree. See API Conventions.

get_MarginBottom

The bottom margin in inches. The default is 1 cm, or ~0.4 inches.

public HRESULT get_MarginBottom(double * marginBottom)

get_MarginLeft

The left margin in inches. The default is 1 cm, or ~0.4 inches.

public HRESULT get_MarginLeft(double * marginLeft)

get_MarginRight

The right margin in inches. The default is 1 cm, or ~0.4 inches.

public HRESULT get_MarginRight(double * marginRight)

get_MarginTop

The top margin in inches. The default is 1 cm, or ~0.4 inches.

public HRESULT get_MarginTop(double * marginTop)

get_Orientation

The orientation can be portrait or landscape.

public HRESULT get_Orientation(COREWEBVIEW2_PRINT_ORIENTATION * orientation)

The default orientation is portrait. See COREWEBVIEW2_PRINT_ORIENTATION.

get_PageHeight

The page height in inches. The default height is 11 inches.

public HRESULT get_PageHeight(double * pageHeight)

get_PageWidth

The page width in inches. The default width is 8.5 inches.

public HRESULT get_PageWidth(double * pageWidth)

get_ScaleFactor

The scale factor is a value between 0.1 and 2.0. The default is 1.0.

public HRESULT get_ScaleFactor(double * scaleFactor)

get_ShouldPrintBackgrounds

TRUE if background colors and images should be printed.

public HRESULT get_ShouldPrintBackgrounds(BOOL * shouldPrintBackgrounds)

The default value is FALSE.

get_ShouldPrintHeaderAndFooter

TRUE if header and footer should be printed.

public HRESULT get_ShouldPrintHeaderAndFooter(BOOL * shouldPrintHeaderAndFooter)

The default value is FALSE. The header consists of the date and time of printing, and the title of the page. The footer consists of the URI and page number. The height of the header and footer is 0.5 cm, or ~0.2 inches.

get_ShouldPrintSelectionOnly

TRUE if only the current end user's selection of HTML in the document should be printed.

public HRESULT get_ShouldPrintSelectionOnly(BOOL * shouldPrintSelectionOnly)

The default value is FALSE.

put_FooterUri

Set the FooterUri property.

public HRESULT put_FooterUri(LPCWSTR footerUri)

If an empty string or null value is provided, no URI is shown in the footer.

put_HeaderTitle

Set the HeaderTitle property.

public HRESULT put_HeaderTitle(LPCWSTR headerTitle)

If an empty string or null value is provided, no title is shown in the header.

put_MarginBottom

Sets the MarginBottom property.

public HRESULT put_MarginBottom(double marginBottom)

A margin cannot be less than zero. Returns E_INVALIDARG if an invalid value is provided, and the current value is not changed.

put_MarginLeft

Sets the MarginLeft property.

public HRESULT put_MarginLeft(double marginLeft)

A margin cannot be less than zero. Returns E_INVALIDARG if an invalid value is provided, and the current value is not changed.

put_MarginRight

Set the MarginRight property.A margin cannot be less than zero.

public HRESULT put_MarginRight(double marginRight)

Returns E_INVALIDARG if an invalid value is provided, and the current value is not changed.

put_MarginTop

Sets the MarginTop property.

public HRESULT put_MarginTop(double marginTop)

A margin cannot be less than zero. Returns E_INVALIDARG if an invalid value is provided, and the current value is not changed.

put_Orientation

Sets the Orientation property.

public HRESULT put_Orientation(COREWEBVIEW2_PRINT_ORIENTATION orientation)

put_PageHeight

Sets the PageHeight property.

public HRESULT put_PageHeight(double pageHeight)

Returns E_INVALIDARG if the page height is less than or equal to zero, and the current value is not changed.

put_PageWidth

Sets the PageWidth property.

public HRESULT put_PageWidth(double pageWidth)

Returns E_INVALIDARG if the page width is less than or equal to zero, and the current value is not changed.

put_ScaleFactor

Sets the ScaleFactor property.

public HRESULT put_ScaleFactor(double scaleFactor)

Returns E_INVALIDARG if an invalid value is provided, and the current value is not changed.

put_ShouldPrintBackgrounds

Set the ShouldPrintBackgrounds property.

public HRESULT put_ShouldPrintBackgrounds(BOOL shouldPrintBackgrounds)

put_ShouldPrintHeaderAndFooter

Set the ShouldPrintHeaderAndFooter property.

public HRESULT put_ShouldPrintHeaderAndFooter(BOOL shouldPrintHeaderAndFooter)

put_ShouldPrintSelectionOnly

Set the ShouldPrintSelectionOnly property.

public HRESULT put_ShouldPrintSelectionOnly(BOOL shouldPrintSelectionOnly)