/
PdfOptions.cs
109 lines (93 loc) · 4 KB
/
PdfOptions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
using System;
using System.Collections.Generic;
using PuppeteerSharp.Media;
namespace PuppeteerSharp
{
/// <summary>
/// Options to be used in <see cref="IPage.PdfAsync(string, PdfOptions)"/>, <see cref="IPage.PdfStreamAsync(PdfOptions)"/> and <see cref="IPage.PdfDataAsync(PdfOptions)"/>.
/// </summary>
public record PdfOptions
{
/// <summary>
/// Initializes a new instance of the <see cref="PuppeteerSharp.PdfOptions"/> class.
/// </summary>
public PdfOptions()
{
}
/// <summary>
/// Scale of the webpage rendering. Defaults to <c>1</c>. Scale amount must be between 0.1 and 2.
/// </summary>
public decimal Scale { get; set; } = 1;
/// <summary>
/// Display header and footer. Defaults to <c>false</c>.
/// </summary>
public bool DisplayHeaderFooter { get; set; }
/// <summary>
/// HTML template for the print header. Should be valid HTML markup with following classes used to inject printing values into them:
/// <c>date</c> - formatted print date
/// <c>title</c> - document title
/// <c>url</c> - document location
/// <c>pageNumber</c> - current page number
/// <c>totalPages</c> - total pages in the document.
/// </summary>
public string HeaderTemplate { get; set; } = string.Empty;
/// <summary>
/// HTML template for the print footer. Should be valid HTML markup with following classes used to inject printing values into them:
/// <c>date</c> - formatted print date
/// <c>title</c> - document title
/// <c>url</c> - document location
/// <c>pageNumber</c> - current page number
/// <c>totalPages</c> - total pages in the document.
/// </summary>
public string FooterTemplate { get; set; } = string.Empty;
/// <summary>
/// Print background graphics. Defaults to <c>false</c>.
/// </summary>
public bool PrintBackground { get; set; }
/// <summary>
/// Paper orientation.. Defaults to <c>false</c>.
/// </summary>
public bool Landscape { get; set; }
/// <summary>
/// Paper ranges to print, e.g., <c>1-5, 8, 11-13</c>. Defaults to the empty string, which means print all pages.
/// </summary>
public string PageRanges { get; set; } = string.Empty;
/// <summary>
/// Paper format. If set, takes priority over <see cref="Width"/> and <see cref="Height"/>.
/// </summary>
public PaperFormat Format { get; set; }
/// <summary>
/// Paper width, accepts values labeled with units.
/// </summary>
public object Width { get; set; }
/// <summary>
/// Paper height, accepts values labeled with units.
/// </summary>
public object Height { get; set; }
/// <summary>
/// Paper margins, defaults to none.
/// </summary>
public MarginOptions MarginOptions { get; set; } = new();
/// <summary>
/// Give any CSS <c>@page</c> size declared in the page priority over what is declared in <c>width</c> and <c>height</c> or <c>format</c> options.
/// Defaults to <c>false</c>, which will scale the content to fit the paper size.
/// </summary>
public bool PreferCSSPageSize { get; set; }
/// <summary>
/// Hides default white background and allows generating pdfs with transparency.
/// </summary>
public bool OmitBackground { get; set; }
/// <summary>
/// Generate tagged (accessible) PDF.
/// </summary>
public bool Tagged { get; set; }
/// <summary>
/// Generate document outline.
/// </summary>
/// <remarks>
/// If this is enabled the PDF will also be tagged (accessible)
/// Currently only works in old Headless (headless = true).
/// </remarks>
public bool Outline { get; set; } = false;
}
}