chromiumly 2.4.0 → 2.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/README.md +57 -40
  2. package/dist/chromium/converters/converter.d.ts +13 -0
  3. package/dist/chromium/converters/converter.js +10 -0
  4. package/dist/chromium/converters/converter.js.map +1 -1
  5. package/dist/chromium/converters/html.converter.d.ts +32 -6
  6. package/dist/chromium/converters/html.converter.js +30 -9
  7. package/dist/chromium/converters/html.converter.js.map +1 -1
  8. package/dist/chromium/converters/markdown.converter.d.ts +34 -7
  9. package/dist/chromium/converters/markdown.converter.js +32 -16
  10. package/dist/chromium/converters/markdown.converter.js.map +1 -1
  11. package/dist/chromium/converters/url.converter.d.ts +31 -5
  12. package/dist/chromium/converters/url.converter.js +29 -1
  13. package/dist/chromium/converters/url.converter.js.map +1 -1
  14. package/dist/chromium/index.js.map +1 -1
  15. package/dist/chromium/interfaces/converter.types.d.ts +3 -6
  16. package/dist/chromium/utils/converter.utils.d.ts +27 -1
  17. package/dist/chromium/utils/converter.utils.js +48 -21
  18. package/dist/chromium/utils/converter.utils.js.map +1 -1
  19. package/dist/common/constants.js.map +1 -1
  20. package/dist/common/gotenberg.utils.d.ts +18 -0
  21. package/dist/common/gotenberg.utils.js +18 -0
  22. package/dist/common/gotenberg.utils.js.map +1 -1
  23. package/dist/common/index.d.ts +1 -0
  24. package/dist/common/index.js.map +1 -1
  25. package/dist/common/types.d.ts +3 -0
  26. package/dist/common/types.js +3 -0
  27. package/dist/common/types.js.map +1 -0
  28. package/dist/gotenberg.d.ts +8 -0
  29. package/dist/gotenberg.js +8 -0
  30. package/dist/gotenberg.js.map +1 -1
  31. package/dist/libre-office/index.js.map +1 -1
  32. package/dist/libre-office/utils/constants.js +76 -76
  33. package/dist/libre-office/utils/constants.js.map +1 -1
  34. package/dist/libre-office/utils/libre-office.utils.d.ts +19 -4
  35. package/dist/libre-office/utils/libre-office.utils.js +39 -7
  36. package/dist/libre-office/utils/libre-office.utils.js.map +1 -1
  37. package/dist/main.config.d.ts +43 -0
  38. package/dist/main.config.js +43 -0
  39. package/dist/main.config.js.map +1 -1
  40. package/dist/main.js.map +1 -1
  41. package/dist/pdf-engines/index.js.map +1 -1
  42. package/dist/pdf-engines/pdf.engine.d.ts +31 -5
  43. package/dist/pdf-engines/pdf.engine.js +31 -3
  44. package/dist/pdf-engines/pdf.engine.js.map +1 -1
  45. package/dist/pdf-engines/utils/engine.utils.d.ts +12 -3
  46. package/dist/pdf-engines/utils/engine.utils.js +27 -8
  47. package/dist/pdf-engines/utils/engine.utils.js.map +1 -1
  48. package/package.json +8 -7
  49. package/src/chromium/converters/converter.ts +18 -5
  50. package/src/chromium/converters/html.converter.ts +82 -61
  51. package/src/chromium/converters/markdown.converter.ts +86 -69
  52. package/src/chromium/converters/tests/html.converter.test.ts +119 -135
  53. package/src/chromium/converters/tests/markdown.converter.test.ts +131 -150
  54. package/src/chromium/converters/tests/url.converter.test.ts +114 -123
  55. package/src/chromium/converters/url.converter.ts +84 -60
  56. package/src/chromium/index.ts +3 -3
  57. package/src/chromium/interfaces/converter.types.ts +27 -27
  58. package/src/chromium/utils/converter.utils.ts +165 -139
  59. package/src/chromium/utils/tests/converter.utils.test.ts +312 -311
  60. package/src/common/constants.ts +3 -3
  61. package/src/common/gotenberg.utils.ts +36 -17
  62. package/src/common/index.ts +3 -2
  63. package/src/common/tests/gotenberg.utils.test.ts +54 -54
  64. package/src/common/types.ts +3 -0
  65. package/src/gotenberg.ts +13 -4
  66. package/src/libre-office/index.ts +2 -2
  67. package/src/libre-office/interfaces/libre-office.types.ts +2 -2
  68. package/src/libre-office/utils/constants.ts +76 -76
  69. package/src/libre-office/utils/libre-office.utils.ts +72 -37
  70. package/src/libre-office/utils/tests/libre-office.utils.test.ts +100 -68
  71. package/src/main.config.ts +68 -22
  72. package/src/main.ts +3 -3
  73. package/src/pdf-engines/index.ts +1 -1
  74. package/src/pdf-engines/pdf.engine.ts +77 -49
  75. package/src/pdf-engines/tests/pdf.engine.test.ts +94 -94
  76. package/src/pdf-engines/utils/engine.utils.ts +30 -12
  77. package/src/pdf-engines/utils/tests/engine.utils.test.ts +60 -48
@@ -1,69 +1,93 @@
1
- import { PathLike } from "fs";
2
-
3
- import { URL } from "url";
4
-
1
+ import {URL} from "url";
5
2
  import FormData from "form-data";
6
-
7
- import { GotenbergUtils, PdfFormat } from "../../common";
3
+ import {GotenbergUtils, PdfFormat, PathLikeOrReadStream} from "../../common";
8
4
  import {
9
- EmulatedMediaType,
10
- PageProperties,
5
+ EmulatedMediaType,
6
+ PageProperties,
11
7
  } from "../interfaces/converter.types";
12
- import { ConverterUtils } from "../utils/converter.utils";
13
- import { Converter } from "./converter";
14
- import { ChromiumRoute } from "../../main.config";
8
+ import {ConverterUtils} from "../utils/converter.utils";
9
+ import {Converter} from "./converter";
10
+ import {ChromiumRoute} from "../../main.config";
15
11
 
12
+ /**
13
+ * Class representing a URL converter that extends the base Converter class.
14
+ * This class is used to convert content from a URL to PDF using Gotenberg service.
15
+ *
16
+ * @extends Converter
17
+ */
16
18
  export class UrlConverter extends Converter {
17
- constructor() {
18
- super(ChromiumRoute.URL);
19
- }
19
+ /**
20
+ * Creates an instance of UrlConverter.
21
+ * Initializes the converter with the URL conversion route.
22
+ */
23
+ constructor() {
24
+ super(ChromiumRoute.URL);
25
+ }
20
26
 
21
- async convert({
22
- url,
23
- header,
24
- footer,
25
- properties,
26
- pdfFormat,
27
- pdfUA,
28
- emulatedMediaType,
29
- waitDelay,
30
- waitForExpression,
31
- userAgent,
32
- extraHttpHeaders,
33
- failOnConsoleExceptions,
34
- }: {
35
- url: string;
36
- header?: PathLike;
37
- footer?: PathLike;
38
- properties?: PageProperties;
39
- pdfFormat?: PdfFormat;
40
- pdfUA?: boolean;
41
- emulatedMediaType?: EmulatedMediaType;
42
- waitDelay?: string;
43
- waitForExpression?: string;
44
- userAgent?: string;
45
- extraHttpHeaders?: Record<string, string>;
46
- failOnConsoleExceptions?: boolean;
47
- }): Promise<Buffer> {
48
- const _url = new URL(url);
49
- const data = new FormData();
27
+ /**
28
+ * Converts content from a URL to PDF.
29
+ *
30
+ * @param {Object} options - Conversion options.
31
+ * @param {string} options.url - The URL of the content to be converted to PDF.
32
+ * @param {PathLikeOrReadStream} [options.header] - PathLike or ReadStream of the header HTML content.
33
+ * @param {PathLikeOrReadStream} [options.footer] - PathLike or ReadStream of the footer HTML content.
34
+ * @param {PageProperties} [options.properties] - Page properties for the conversion.
35
+ * @param {PdfFormat} [options.pdfFormat] - PDF format options.
36
+ * @param {boolean} [options.pdfUA] - Indicates whether to generate PDF/UA compliant output.
37
+ * @param {EmulatedMediaType} [options.emulatedMediaType] - Emulated media type for the conversion.
38
+ * @param {string} [options.waitDelay] - Delay before the conversion process starts.
39
+ * @param {string} [options.waitForExpression] - JavaScript expression to wait for before completing the conversion.
40
+ * @param {string} [options.userAgent] - User agent string to use during the conversion.
41
+ * @param {Record<string, string>} [options.extraHttpHeaders] - Additional HTTP headers for the conversion.
42
+ * @param {boolean} [options.failOnConsoleExceptions] - Whether to fail on console exceptions during conversion.
43
+ * @returns {Promise<Buffer>} A Promise resolving to the converted PDF content as a Buffer.
44
+ */
45
+ async convert({
46
+ url,
47
+ header,
48
+ footer,
49
+ properties,
50
+ pdfFormat,
51
+ pdfUA,
52
+ emulatedMediaType,
53
+ waitDelay,
54
+ waitForExpression,
55
+ userAgent,
56
+ extraHttpHeaders,
57
+ failOnConsoleExceptions,
58
+ }: {
59
+ url: string;
60
+ header?: PathLikeOrReadStream;
61
+ footer?: PathLikeOrReadStream;
62
+ properties?: PageProperties;
63
+ pdfFormat?: PdfFormat;
64
+ pdfUA?: boolean;
65
+ emulatedMediaType?: EmulatedMediaType;
66
+ waitDelay?: string;
67
+ waitForExpression?: string;
68
+ userAgent?: string;
69
+ extraHttpHeaders?: Record<string, string>;
70
+ failOnConsoleExceptions?: boolean;
71
+ }): Promise<Buffer> {
72
+ const _url = new URL(url);
73
+ const data = new FormData();
50
74
 
51
- data.append("url", _url.href);
75
+ data.append("url", _url.href);
52
76
 
53
- ConverterUtils.customize(data, {
54
- header,
55
- footer,
56
- properties,
57
- pdfFormat,
58
- pdfUA,
59
- emulatedMediaType,
60
- waitDelay,
61
- waitForExpression,
62
- userAgent,
63
- extraHttpHeaders,
64
- failOnConsoleExceptions,
65
- });
77
+ await ConverterUtils.customize(data, {
78
+ header,
79
+ footer,
80
+ properties,
81
+ pdfFormat,
82
+ pdfUA,
83
+ emulatedMediaType,
84
+ waitDelay,
85
+ waitForExpression,
86
+ userAgent,
87
+ extraHttpHeaders,
88
+ failOnConsoleExceptions,
89
+ });
66
90
 
67
- return GotenbergUtils.fetch(this.endpoint, data);
68
- }
69
- }
91
+ return GotenbergUtils.fetch(this.endpoint, data);
92
+ }
93
+ }
@@ -1,3 +1,3 @@
1
- export { HtmlConverter } from "./converters/html.converter";
2
- export { MarkdownConverter } from "./converters/markdown.converter";
3
- export { UrlConverter } from "./converters/url.converter";
1
+ export {HtmlConverter} from "./converters/html.converter";
2
+ export {MarkdownConverter} from "./converters/markdown.converter";
3
+ export {UrlConverter} from "./converters/url.converter";
@@ -1,41 +1,41 @@
1
- import { PathLike } from "fs";
2
- import { PdfFormat } from "../../common";
1
+ import {PathLikeOrReadStream, PdfFormat} from "../../common";
3
2
 
4
3
  type PageSize = {
5
- width: number; // Paper width, in inches (default 8.5)
6
- height: number; //Paper height, in inches (default 11)
4
+ width: number; // Paper width, in inches (default 8.5)
5
+ height: number; //Paper height, in inches (default 11)
7
6
  };
8
7
 
9
8
  type PageMargins = {
10
- top: number; // Top margin, in inches (default 0.39)
11
- bottom: number; // Bottom margin, in inches (default 0.39)
12
- left: number; // Left margin, in inches (default 0.39)
13
- right: number; // Right margin, in inches (default 0.39)
9
+ top: number; // Top margin, in inches (default 0.39)
10
+ bottom: number; // Bottom margin, in inches (default 0.39)
11
+ left: number; // Left margin, in inches (default 0.39)
12
+ right: number; // Right margin, in inches (default 0.39)
14
13
  };
15
14
 
16
15
  export type PageProperties = {
17
- size?: PageSize;
18
- margins?: PageMargins;
19
- preferCssPageSize?: boolean; // Define whether to prefer page size as defined by CSS (default false)
20
- printBackground?: boolean; // Print the background graphics (default false)
21
- omitBackground?: boolean; // Hide the default white background and allow generating PDFs with transparency (default false)
22
- landscape?: boolean; // Set the paper orientation to landscape (default false)
23
- scale?: number; // The scale of the page rendering (default 1.0)
24
- nativePageRanges?: { from: number; to: number }; // Page ranges to print
16
+ size?: PageSize;
17
+ margins?: PageMargins;
18
+ preferCssPageSize?: boolean; // Define whether to prefer page size as defined by CSS (default false)
19
+ printBackground?: boolean; // Print the background graphics (default false)
20
+ omitBackground?: boolean; // Hide the default white background and allow generating PDFs with transparency (default false)
21
+ landscape?: boolean; // Set the paper orientation to landscape (default false)
22
+ scale?: number; // The scale of the page rendering (default 1.0)
23
+ nativePageRanges?: { from: number; to: number }; // Page ranges to print
25
24
  };
26
25
 
27
26
  export type EmulatedMediaType = "screen" | "print";
28
27
 
28
+
29
29
  export type ConversionOptions = {
30
- header?: PathLike | Buffer;
31
- footer?: PathLike | Buffer;
32
- properties?: PageProperties;
33
- pdfFormat?: PdfFormat;
34
- pdfUA?: boolean; // Enable PDF for Universal Access for optimal accessibility (default false)
35
- emulatedMediaType?: EmulatedMediaType;
36
- waitDelay?: string; // Duration (e.g, '5s') to wait when loading an HTML document before converting it into PDF
37
- waitForExpression?: string; // JavaScript expression to wait before converting an HTML document into PDF until it returns true.
38
- userAgent?: string;
39
- extraHttpHeaders?: Record<string, string>;
40
- failOnConsoleExceptions?: boolean; // Return a 409 Conflict response if there are exceptions in the Chromium console (default false)
30
+ header?: PathLikeOrReadStream;
31
+ footer?: PathLikeOrReadStream;
32
+ properties?: PageProperties;
33
+ pdfFormat?: PdfFormat;
34
+ pdfUA?: boolean; // Enable PDF for Universal Access for optimal accessibility (default false)
35
+ emulatedMediaType?: EmulatedMediaType;
36
+ waitDelay?: string; // Duration (e.g, '5s') to wait when loading an HTML document before converting it into PDF
37
+ waitForExpression?: string; // JavaScript's expression to wait before converting an HTML document into PDF until it returns true.
38
+ userAgent?: string;
39
+ extraHttpHeaders?: Record<string, string>;
40
+ failOnConsoleExceptions?: boolean; // Return a 409 Conflict response if there are exceptions in the Chromium console (default false)
41
41
  };
@@ -1,147 +1,173 @@
1
- import { constants, createReadStream, promises } from "fs";
1
+ import {constants, createReadStream, promises} from "fs";
2
2
  import FormData from "form-data";
3
3
 
4
- import { GotenbergUtils } from "../../common/gotenberg.utils";
5
4
  import {
6
- ConversionOptions,
7
- PageProperties,
5
+ ConversionOptions,
6
+ PageProperties,
8
7
  } from "../interfaces/converter.types";
8
+ import {GotenbergUtils, PathLikeOrReadStream} from "../../common";
9
+ import {ReadStream} from "fs";
9
10
 
11
+ /**
12
+ * Utility class for handling common tasks related to conversion.
13
+ */
10
14
  export class ConverterUtils {
11
- public static injectPageProperties(
12
- data: FormData,
13
- pageProperties: PageProperties
14
- ): void {
15
- if (pageProperties.size) {
16
- GotenbergUtils.assert(
17
- pageProperties.size.width >= 1.0 && pageProperties.size.height >= 1.5,
18
- "size is smaller than the minimum printing requirements (i.e. 1.0 x 1.5 in)"
19
- );
20
-
21
- data.append("paperWidth", pageProperties.size.width);
22
- data.append("paperHeight", pageProperties.size.height);
15
+ /**
16
+ * Adds page properties to the FormData object based on the provided PageProperties.
17
+ *
18
+ * @param {FormData} data - The FormData object to which page properties will be added.
19
+ * @param {PageProperties} pageProperties - The page properties to be added to the FormData.
20
+ */
21
+ public static addPageProperties(
22
+ data: FormData,
23
+ pageProperties: PageProperties
24
+ ): void {
25
+ if (pageProperties.size) {
26
+ GotenbergUtils.assert(
27
+ pageProperties.size.width >= 1.0 && pageProperties.size.height >= 1.5,
28
+ "size is smaller than the minimum printing requirements (i.e. 1.0 x 1.5 in)"
29
+ );
30
+
31
+ data.append("paperWidth", pageProperties.size.width);
32
+ data.append("paperHeight", pageProperties.size.height);
33
+ }
34
+
35
+ if (pageProperties.margins) {
36
+ GotenbergUtils.assert(
37
+ pageProperties.margins.top >= 0 &&
38
+ pageProperties.margins.bottom >= 0 &&
39
+ pageProperties.margins.left >= 0 &&
40
+ pageProperties.margins.left >= 0,
41
+ "negative margins are not allowed"
42
+ );
43
+
44
+ data.append("marginTop", pageProperties.margins.top);
45
+ data.append("marginBottom", pageProperties.margins.bottom);
46
+ data.append("marginLeft", pageProperties.margins.left);
47
+ data.append("marginRight", pageProperties.margins.right);
48
+ }
49
+
50
+ if (pageProperties.preferCssPageSize) {
51
+ data.append(
52
+ "preferCssPageSize",
53
+ String(pageProperties.preferCssPageSize)
54
+ );
55
+ }
56
+
57
+ if (pageProperties.printBackground) {
58
+ data.append("printBackground", String(pageProperties.printBackground));
59
+ }
60
+
61
+ if (pageProperties.omitBackground) {
62
+ data.append("omitBackground", String(pageProperties.omitBackground));
63
+ }
64
+
65
+ if (pageProperties.landscape) {
66
+ data.append("landscape", String(pageProperties.landscape));
67
+ }
68
+
69
+ if (pageProperties.scale) {
70
+ GotenbergUtils.assert(
71
+ pageProperties.scale >= 0.1 && pageProperties.scale <= 2.0,
72
+ "scale is outside of [0.1 - 2] range"
73
+ );
74
+
75
+ data.append("scale", pageProperties.scale);
76
+ }
77
+
78
+ if (pageProperties.nativePageRanges) {
79
+ GotenbergUtils.assert(
80
+ pageProperties.nativePageRanges.from > 0 &&
81
+ pageProperties.nativePageRanges.to > 0 &&
82
+ pageProperties.nativePageRanges.to >=
83
+ pageProperties.nativePageRanges.from,
84
+ "page ranges syntax error"
85
+ );
86
+
87
+ data.append(
88
+ "nativePageRanges",
89
+ `${pageProperties.nativePageRanges.from}-${pageProperties.nativePageRanges.to}`
90
+ );
91
+ }
92
+ }
93
+
94
+ /**
95
+ * Adds a file to the FormData object.
96
+ *
97
+ * @param {FormData} data - The FormData object to which the file will be added.
98
+ * @param {PathLikeOrReadStream} file - The file to be added (either a PathLike or a ReadStream).
99
+ * @param {string} name - The name to be used for the file in the FormData.
100
+ * @returns {Promise<void>} A Promise that resolves once the file has been added.
101
+ */
102
+ public static async addFile(data: FormData, file: PathLikeOrReadStream, name: string) {
103
+ if (Buffer.isBuffer(file)) {
104
+ data.append("files", file, name);
105
+ } else if (file instanceof ReadStream) {
106
+ data.append("files", file, name);
107
+ } else {
108
+ await promises.access(file, constants.R_OK);
109
+ data.append("files", createReadStream(file), name);
110
+ }
111
+ }
112
+
113
+ /**
114
+ * Customizes the FormData object based on the provided conversion options.
115
+ *
116
+ * @param {FormData} data - The FormData object to be customized.
117
+ * @param {ConversionOptions} options - The conversion options to apply to the FormData.
118
+ * @returns {Promise<void>} A Promise that resolves once the customization is complete.
119
+ */
120
+ public static async customize(
121
+ data: FormData,
122
+ options: ConversionOptions
123
+ ): Promise<void> {
124
+ if (options.pdfFormat) {
125
+ data.append("pdfa", options.pdfFormat);
126
+ }
127
+
128
+ if (options.pdfUA) {
129
+ data.append("pdfua", String(options.pdfUA));
130
+ }
131
+
132
+ if (options.header) {
133
+ const {header} = options;
134
+ await ConverterUtils.addFile(data, header, "header.html")
135
+ }
136
+
137
+ if (options.footer) {
138
+ const {footer} = options;
139
+ await ConverterUtils.addFile(data, footer, "footer.html")
140
+ }
141
+
142
+ if (options.emulatedMediaType) {
143
+ data.append("emulatedMediaType", options.emulatedMediaType);
144
+ }
145
+
146
+ if (options.properties) {
147
+ ConverterUtils.addPageProperties(data, options.properties);
148
+ }
149
+
150
+ if (options.waitDelay) {
151
+ data.append("waitDelay", options.waitDelay);
152
+ }
153
+
154
+ if (options.waitForExpression) {
155
+ data.append("waitForExpression", options.waitForExpression);
156
+ }
157
+
158
+ if (options.userAgent) {
159
+ data.append("userAgent", options.userAgent);
160
+ }
161
+
162
+ if (options.extraHttpHeaders) {
163
+ data.append("extraHttpHeaders", JSON.stringify(options.extraHttpHeaders));
164
+ }
165
+
166
+ if (options.failOnConsoleExceptions) {
167
+ data.append(
168
+ "failOnConsoleExceptions",
169
+ String(options.failOnConsoleExceptions)
170
+ );
171
+ }
23
172
  }
24
-
25
- if (pageProperties.margins) {
26
- GotenbergUtils.assert(
27
- pageProperties.margins.top >= 0 &&
28
- pageProperties.margins.bottom >= 0 &&
29
- pageProperties.margins.left >= 0 &&
30
- pageProperties.margins.left >= 0,
31
- "negative margins are not allowed"
32
- );
33
-
34
- data.append("marginTop", pageProperties.margins.top);
35
- data.append("marginBottom", pageProperties.margins.bottom);
36
- data.append("marginLeft", pageProperties.margins.left);
37
- data.append("marginRight", pageProperties.margins.right);
38
- }
39
-
40
- if (pageProperties.preferCssPageSize) {
41
- data.append(
42
- "preferCssPageSize",
43
- String(pageProperties.preferCssPageSize)
44
- );
45
- }
46
-
47
- if (pageProperties.printBackground) {
48
- data.append("printBackground", String(pageProperties.printBackground));
49
- }
50
-
51
- if (pageProperties.omitBackground) {
52
- data.append("omitBackground", String(pageProperties.omitBackground));
53
- }
54
-
55
- if (pageProperties.landscape) {
56
- data.append("landscape", String(pageProperties.landscape));
57
- }
58
-
59
- if (pageProperties.scale) {
60
- GotenbergUtils.assert(
61
- pageProperties.scale >= 0.1 && pageProperties.scale <= 2.0,
62
- "scale is outside of [0.1 - 2] range"
63
- );
64
-
65
- data.append("scale", pageProperties.scale);
66
- }
67
-
68
- if (pageProperties.nativePageRanges) {
69
- GotenbergUtils.assert(
70
- pageProperties.nativePageRanges.from > 0 &&
71
- pageProperties.nativePageRanges.to > 0 &&
72
- pageProperties.nativePageRanges.to >=
73
- pageProperties.nativePageRanges.from,
74
- "page ranges syntax error"
75
- );
76
-
77
- data.append(
78
- "nativePageRanges",
79
- `${pageProperties.nativePageRanges.from}-${pageProperties.nativePageRanges.to}`
80
- );
81
- }
82
- }
83
-
84
- public static async customize(
85
- data: FormData,
86
- options: ConversionOptions
87
- ): Promise<void> {
88
- if (options.pdfFormat) {
89
- data.append("pdfa", options.pdfFormat);
90
- }
91
-
92
- if (options.pdfUA) {
93
- data.append("pdfua", String(options.pdfUA));
94
- }
95
-
96
- if (options.header) {
97
- const { header } = options;
98
- if (Buffer.isBuffer(header)) {
99
- data.append("files", header, "header.html");
100
- } else {
101
- await promises.access(options.header, constants.R_OK);
102
- data.append("files", createReadStream(options.header), "header.html");
103
- }
104
- }
105
-
106
- if (options.footer) {
107
- const { footer } = options;
108
- if (Buffer.isBuffer(footer)) {
109
- data.append("files", footer, "footer.html");
110
- } else {
111
- await promises.access(options.footer, constants.R_OK);
112
- data.append("files", createReadStream(options.footer), "footer.html");
113
- }
114
- }
115
-
116
- if (options.emulatedMediaType) {
117
- data.append("emulatedMediaType", options.emulatedMediaType);
118
- }
119
-
120
- if (options.properties) {
121
- ConverterUtils.injectPageProperties(data, options.properties);
122
- }
123
-
124
- if (options.waitDelay) {
125
- data.append("waitDelay", options.waitDelay);
126
- }
127
-
128
- if (options.waitForExpression) {
129
- data.append("waitForExpression", options.waitForExpression);
130
- }
131
-
132
- if (options.userAgent) {
133
- data.append("userAgent", options.userAgent);
134
- }
135
-
136
- if (options.extraHttpHeaders) {
137
- data.append("extraHttpHeaders", JSON.stringify(options.extraHttpHeaders));
138
- }
139
-
140
- if (options.failOnConsoleExceptions) {
141
- data.append(
142
- "failOnConsoleExceptions",
143
- String(options.failOnConsoleExceptions)
144
- );
145
- }
146
- }
147
173
  }