共用方式為


CoreWebView2PrintSettings.PageRanges Property

Definition

Page range to print. Defaults to empty string, which means print all pages.

public string PageRanges { get; set; }
member this.PageRanges : string with get, set
Public Property PageRanges As String

Property Value

Remarks

The PageRanges property is a list of page ranges specifying one or more pages that should be printed separated by commas. Any whitespace between page ranges is ignored. A valid page range is either a single integer identifying the page to print, or a range in the form [start page]-[last page] where start page and last page are integers identifying the first and last inclusive pages respectively to print. Every page identifier is an integer greater than 0 unless wildcards are used (see below examples). The first page is 1.

In a page range of the form [start page]-[last page] the start page number must be larger than 0 and less than or equal to the document's total page count. If the start page is not present, then 1 is used as the start page. The last page must be larger than the start page. If the last page is not present, then the document total page count is used as the last page.

Repeating a page does not print it multiple times. To print multiple times, use the Copies property.

The pages are always printed in ascending order, even if specified in non-ascending order.

If page range is not valid or if a page is greater than document total page count, ArgumentException is thrown.

The following examples assume a document with 20 total pages.

| Example | Result | Notes | | --- | --- | --- | | "2" | Page 2 | | | "1-4, 9, 3-6, 10, 11" | Pages 1-6, 9-11 | | | "1-4, -6" | Pages 1-6 | The "-6" is interpreted as "1-6". | | "2-" | Pages 2-20 | The "2-" is interpreted as "pages 2 to the end of the document". | | "4-2, 11, -6" | Invalid | "4-2" is an invalid range. | | "-" | Pages 1-20 | The "-" is interpreted as "page 1 to the end of the document". | | "1-4dsf, 11" | Invalid | | | "2-2" | Page 2 | |

Applies to