chromiumly 4.1.6 → 4.2.2
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.
- package/README.md +50 -0
- package/dist/chromium/converters/html.converter.d.ts +2 -1
- package/dist/chromium/converters/html.converter.js +7 -2
- package/dist/chromium/converters/html.converter.js.map +1 -1
- package/dist/chromium/converters/markdown.converter.d.ts +2 -1
- package/dist/chromium/converters/markdown.converter.js +7 -2
- package/dist/chromium/converters/markdown.converter.js.map +1 -1
- package/dist/chromium/converters/url.converter.d.ts +2 -1
- package/dist/chromium/converters/url.converter.js +7 -2
- package/dist/chromium/converters/url.converter.js.map +1 -1
- package/dist/chromium/interfaces/common.types.d.ts +1 -0
- package/dist/chromium/interfaces/converter.types.d.ts +3 -0
- package/dist/chromium/interfaces/screenshot.types.d.ts +3 -0
- package/dist/chromium/screenshots/html.screenshot.d.ts +2 -1
- package/dist/chromium/screenshots/html.screenshot.js +7 -2
- package/dist/chromium/screenshots/html.screenshot.js.map +1 -1
- package/dist/chromium/screenshots/markdown.screenshot.d.ts +2 -1
- package/dist/chromium/screenshots/markdown.screenshot.js +7 -2
- package/dist/chromium/screenshots/markdown.screenshot.js.map +1 -1
- package/dist/chromium/screenshots/url.screenshot.d.ts +2 -1
- package/dist/chromium/screenshots/url.screenshot.js +7 -2
- package/dist/chromium/screenshots/url.screenshot.js.map +1 -1
- package/dist/chromium/utils/converter.utils.d.ts +10 -0
- package/dist/chromium/utils/converter.utils.js +44 -0
- package/dist/chromium/utils/converter.utils.js.map +1 -1
- package/dist/chromium/utils/screenshot.utils.d.ts +10 -0
- package/dist/chromium/utils/screenshot.utils.js +44 -0
- package/dist/chromium/utils/screenshot.utils.js.map +1 -1
- package/dist/gotenberg.js +5 -2
- package/dist/gotenberg.js.map +1 -1
- package/dist/libre-office/interfaces/libre-office.types.d.ts +3 -0
- package/dist/libre-office/libre-office.d.ts +1 -1
- package/dist/libre-office/libre-office.js +5 -2
- package/dist/libre-office/libre-office.js.map +1 -1
- package/dist/libre-office/utils/libre-office.utils.d.ts +9 -0
- package/dist/libre-office/utils/libre-office.utils.js +36 -0
- package/dist/libre-office/utils/libre-office.utils.js.map +1 -1
- package/dist/main.config.d.ts +5 -1
- package/dist/main.config.js +5 -1
- package/dist/main.config.js.map +1 -1
- package/dist/pdf-engines/interfaces/pdf-engines.types.d.ts +4 -0
- package/dist/pdf-engines/pdf-engines.d.ts +25 -0
- package/dist/pdf-engines/pdf-engines.js +33 -0
- package/dist/pdf-engines/pdf-engines.js.map +1 -1
- package/dist/pdf-engines/utils/pdf-engines.utils.d.ts +9 -0
- package/dist/pdf-engines/utils/pdf-engines.utils.js +26 -0
- package/dist/pdf-engines/utils/pdf-engines.utils.js.map +1 -1
- package/package.json +14 -9
package/README.md
CHANGED
|
@@ -35,6 +35,9 @@ a variety of document formats to PDF files.
|
|
|
35
35
|
- [Metadata Management](#metadata-management)
|
|
36
36
|
- [File Generation](#file-generation)
|
|
37
37
|
- [PDF Splitting](#pdf-splitting)
|
|
38
|
+
- [PDF Flattening](#pdf-flattening)
|
|
39
|
+
- [PDF Encryption](#pdf-encryption)
|
|
40
|
+
- [Embedding Files](#embedding-files)
|
|
38
41
|
4. [Usage Example](#snippet)
|
|
39
42
|
|
|
40
43
|
## Getting Started
|
|
@@ -278,6 +281,7 @@ type ConversionOptions = {
|
|
|
278
281
|
emulatedMediaType?: EmulatedMediaType; // Specify the emulated media type for conversion
|
|
279
282
|
waitDelay?: string; // Duration (e.g., '5s') to wait when loading an HTML document before conversion
|
|
280
283
|
waitForExpression?: string; // JavaScript expression to wait before converting an HTML document into PDF
|
|
284
|
+
waitForSelector?: string; // CSS selector to wait for before converting an HTML document into PDF until it matches a node
|
|
281
285
|
extraHttpHeaders?: Record<string, string>; // Include additional HTTP headers in the request
|
|
282
286
|
failOnHttpStatusCodes?: number[]; // List of HTTP status codes triggering a 409 Conflict response (default [499, 599])
|
|
283
287
|
failOnConsoleExceptions?: boolean; // Return a 409 Conflict response if there are exceptions in the Chromium console (default false)
|
|
@@ -286,6 +290,9 @@ type ConversionOptions = {
|
|
|
286
290
|
cookies?: Cookie[]; // Cookies to be written.
|
|
287
291
|
downloadFrom?: DownloadFrom; //Download a file from a URL. It must return a Content-Disposition header with a filename parameter.
|
|
288
292
|
split?: SplitOptions; // Split the PDF file into multiple files.
|
|
293
|
+
userPassword?: string; // Password for opening the resulting PDF(s).
|
|
294
|
+
ownerPassword?: string; // Password for full access on the resulting PDF(s).
|
|
295
|
+
embeds?: PathLikeOrReadStream[]; // Files to embed in the generated PDF.
|
|
289
296
|
};
|
|
290
297
|
```
|
|
291
298
|
|
|
@@ -314,6 +321,7 @@ type ScreenshotOptions = {
|
|
|
314
321
|
emulatedMediaType?: EmulatedMediaType;
|
|
315
322
|
waitDelay?: string; // Duration (e.g, '5s') to wait when loading an HTML document before convertion.
|
|
316
323
|
waitForExpression?: string; // JavaScript's expression to wait before converting an HTML document into PDF until it returns true.
|
|
324
|
+
waitForSelector?: string; // CSS selector to wait for before converting an HTML document into PDF until it matches a node.
|
|
317
325
|
extraHttpHeaders?: Record<string, string>;
|
|
318
326
|
failOnHttpStatusCodes?: number[]; // Return a 409 Conflict response if the HTTP status code is in the list (default [499,599])
|
|
319
327
|
failOnConsoleExceptions?: boolean; // Return a 409 Conflict response if there are exceptions in the Chromium console (default false)
|
|
@@ -321,6 +329,9 @@ type ScreenshotOptions = {
|
|
|
321
329
|
optimizeForSpeed?: boolean; // Define whether to optimize image encoding for speed, not for resulting size.
|
|
322
330
|
cookies?: Cookie[]; // Cookies to be written.
|
|
323
331
|
downloadFrom?: DownloadFrom; // Download the file from a specific URL. It must return a Content-Disposition header with a filename parameter.
|
|
332
|
+
userPassword?: string; // Password for opening the resulting PDF(s).
|
|
333
|
+
ownerPassword?: string; // Password for full access on the resulting PDF(s).
|
|
334
|
+
embeds?: PathLikeOrReadStream[]; // Files to embed in the generated PDF.
|
|
324
335
|
};
|
|
325
336
|
```
|
|
326
337
|
|
|
@@ -353,6 +364,9 @@ Similarly to Chromium's route `convert` method, this method takes the following
|
|
|
353
364
|
- `quality`: specifies the quality of the JPG export. The value ranges from 1 to 100, with higher values producing higher-quality images and larger file sizes.
|
|
354
365
|
- `maxImageResolution`: specifies if all images will be reduced to the specified DPI value. Possible values are: `75`, `150`, `300`, `600`, and `1200`.
|
|
355
366
|
- `flatten`: a boolean that, when set to true, flattens the split PDF files, making form fields and annotations uneditable.
|
|
367
|
+
- `userPassword`: password for opening the resulting PDF(s).
|
|
368
|
+
- `ownerPassword`: password for full access on the resulting PDF(s).
|
|
369
|
+
- `embeds`: files to embed in the generated PDF (repeatable). This feature enables the creation of PDFs compatible with standards like [ZUGFeRD / Factur-X](https://fnfe-mpe.org/factur-x/), which require embedding XML invoices and other files within the PDF.
|
|
356
370
|
|
|
357
371
|
### PDF Engines
|
|
358
372
|
|
|
@@ -483,6 +497,42 @@ const buffer = await PDFEngines.flatten({
|
|
|
483
497
|
});
|
|
484
498
|
```
|
|
485
499
|
|
|
500
|
+
### PDF Encryption
|
|
501
|
+
|
|
502
|
+
Each [Chromium](#chromium) and [LibreOffice](#libreoffice) route supports PDF encryption through the `userPassword` and `ownerPassword` parameters. The `userPassword` is required to open the PDF, while the `ownerPassword` provides full access permissions.
|
|
503
|
+
|
|
504
|
+
```typescript
|
|
505
|
+
import { UrlConverter } from "chromiumly";
|
|
506
|
+
|
|
507
|
+
const buffer = await UrlConverter.convert({
|
|
508
|
+
url: "https://www.example.com/",
|
|
509
|
+
userPassword: "my_user_password",
|
|
510
|
+
ownerPassword: "my_owner_password",
|
|
511
|
+
});
|
|
512
|
+
```
|
|
513
|
+
|
|
514
|
+
### Embedding Files
|
|
515
|
+
|
|
516
|
+
Each [Chromium](#chromium) and [LibreOffice](#libreoffice) route supports embedding files into the generated PDF through the `embeds` parameter. This feature enables the creation of PDFs compatible with standards like [ZUGFeRD / Factur-X](https://fnfe-mpe.org/factur-x/), which require embedding XML invoices and other files within the PDF.
|
|
517
|
+
|
|
518
|
+
You can embed multiple files by passing an array of file paths, buffers, or read streams:
|
|
519
|
+
|
|
520
|
+
```typescript
|
|
521
|
+
import { HtmlConverter } from "chromiumly";
|
|
522
|
+
|
|
523
|
+
const htmlConverter = new HtmlConverter();
|
|
524
|
+
const buffer = await htmlConverter.convert({
|
|
525
|
+
html: "path/to/index.html",
|
|
526
|
+
embeds: [
|
|
527
|
+
"path/to/invoice.xml",
|
|
528
|
+
"path/to/logo.png",
|
|
529
|
+
Buffer.from("additional data"),
|
|
530
|
+
],
|
|
531
|
+
});
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
All embedded files will be attached to the generated PDF and can be extracted using PDF readers that support file attachments.
|
|
535
|
+
|
|
486
536
|
## Snippet
|
|
487
537
|
|
|
488
538
|
The following is a short snippet of how to use the library.
|
|
@@ -25,6 +25,7 @@ export declare class HtmlConverter extends Converter {
|
|
|
25
25
|
* @param {EmulatedMediaType} [options.emulatedMediaType] - Emulated media type for the conversion.
|
|
26
26
|
* @param {string} [options.waitDelay] - Delay before the conversion process starts.
|
|
27
27
|
* @param {string} [options.waitForExpression] - JavaScript expression to wait for before completing the conversion.
|
|
28
|
+
* @param {string} [options.waitForSelector] - CSS selector to wait for before completing the conversion.
|
|
28
29
|
* @param {string} [options.userAgent] - User agent string to use during the conversion.
|
|
29
30
|
* @param {Record<string, string>} [options.extraHttpHeaders] - Additional HTTP headers for the conversion.
|
|
30
31
|
* @param {number[]} [options.failOnHttpStatusCodes] - Whether to fail on HTTP status code.
|
|
@@ -39,5 +40,5 @@ export declare class HtmlConverter extends Converter {
|
|
|
39
40
|
* @param {Split} [options.split] - Split the PDF into multiple files.
|
|
40
41
|
* @returns {Promise<Buffer>} A Promise resolving to the converted PDF content as a buffer
|
|
41
42
|
*/
|
|
42
|
-
convert({ html, assets, header, footer, properties, pdfFormat, pdfUA, emulatedMediaType, waitDelay, waitForExpression, userAgent, extraHttpHeaders, failOnHttpStatusCodes, failOnConsoleExceptions, failOnResourceHttpStatusCodes, failOnResourceLoadingFailed, skipNetworkIdleEvent, generateDocumentOutline, metadata, cookies, downloadFrom, split }: HtmlConversionOptions): Promise<Buffer>;
|
|
43
|
+
convert({ html, assets, header, footer, properties, pdfFormat, pdfUA, emulatedMediaType, waitDelay, waitForExpression, waitForSelector, userAgent, extraHttpHeaders, failOnHttpStatusCodes, failOnConsoleExceptions, failOnResourceHttpStatusCodes, failOnResourceLoadingFailed, skipNetworkIdleEvent, generateDocumentOutline, metadata, cookies, downloadFrom, split, userPassword, ownerPassword, embeds }: HtmlConversionOptions): Promise<Buffer>;
|
|
43
44
|
}
|
|
@@ -32,6 +32,7 @@ class HtmlConverter extends converter_1.Converter {
|
|
|
32
32
|
* @param {EmulatedMediaType} [options.emulatedMediaType] - Emulated media type for the conversion.
|
|
33
33
|
* @param {string} [options.waitDelay] - Delay before the conversion process starts.
|
|
34
34
|
* @param {string} [options.waitForExpression] - JavaScript expression to wait for before completing the conversion.
|
|
35
|
+
* @param {string} [options.waitForSelector] - CSS selector to wait for before completing the conversion.
|
|
35
36
|
* @param {string} [options.userAgent] - User agent string to use during the conversion.
|
|
36
37
|
* @param {Record<string, string>} [options.extraHttpHeaders] - Additional HTTP headers for the conversion.
|
|
37
38
|
* @param {number[]} [options.failOnHttpStatusCodes] - Whether to fail on HTTP status code.
|
|
@@ -46,7 +47,7 @@ class HtmlConverter extends converter_1.Converter {
|
|
|
46
47
|
* @param {Split} [options.split] - Split the PDF into multiple files.
|
|
47
48
|
* @returns {Promise<Buffer>} A Promise resolving to the converted PDF content as a buffer
|
|
48
49
|
*/
|
|
49
|
-
async convert({ html, assets, header, footer, properties, pdfFormat, pdfUA, emulatedMediaType, waitDelay, waitForExpression, userAgent, extraHttpHeaders, failOnHttpStatusCodes, failOnConsoleExceptions, failOnResourceHttpStatusCodes, failOnResourceLoadingFailed, skipNetworkIdleEvent, generateDocumentOutline, metadata, cookies, downloadFrom, split }) {
|
|
50
|
+
async convert({ html, assets, header, footer, properties, pdfFormat, pdfUA, emulatedMediaType, waitDelay, waitForExpression, waitForSelector, userAgent, extraHttpHeaders, failOnHttpStatusCodes, failOnConsoleExceptions, failOnResourceHttpStatusCodes, failOnResourceLoadingFailed, skipNetworkIdleEvent, generateDocumentOutline, metadata, cookies, downloadFrom, split, userPassword, ownerPassword, embeds }) {
|
|
50
51
|
const data = new FormData();
|
|
51
52
|
await common_1.GotenbergUtils.addFile(data, html, 'index.html');
|
|
52
53
|
if (assets?.length) {
|
|
@@ -61,6 +62,7 @@ class HtmlConverter extends converter_1.Converter {
|
|
|
61
62
|
emulatedMediaType,
|
|
62
63
|
waitDelay,
|
|
63
64
|
waitForExpression,
|
|
65
|
+
waitForSelector,
|
|
64
66
|
userAgent,
|
|
65
67
|
extraHttpHeaders,
|
|
66
68
|
failOnHttpStatusCodes,
|
|
@@ -72,7 +74,10 @@ class HtmlConverter extends converter_1.Converter {
|
|
|
72
74
|
metadata,
|
|
73
75
|
cookies,
|
|
74
76
|
downloadFrom,
|
|
75
|
-
split
|
|
77
|
+
split,
|
|
78
|
+
userPassword,
|
|
79
|
+
ownerPassword,
|
|
80
|
+
embeds
|
|
76
81
|
});
|
|
77
82
|
return common_1.GotenbergUtils.fetch(this.endpoint, data, main_config_1.Chromiumly.getGotenbergApiBasicAuthUsername(), main_config_1.Chromiumly.getGotenbergApiBasicAuthPassword(), main_config_1.Chromiumly.getCustomHttpHeaders());
|
|
78
83
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html.converter.js","sourceRoot":"","sources":["../../../src/chromium/converters/html.converter.ts"],"names":[],"mappings":";;;AAAA,yCAA8C;AAE9C,8DAA0D;AAC1D,2CAAwC;AACxC,mDAA8D;AAE9D;;;;;GAKG;AACH,MAAa,aAAc,SAAQ,qBAAS;IACxC;;;OAGG;IACH;QACI,KAAK,CAAC,2BAAa,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IAED
|
|
1
|
+
{"version":3,"file":"html.converter.js","sourceRoot":"","sources":["../../../src/chromium/converters/html.converter.ts"],"names":[],"mappings":";;;AAAA,yCAA8C;AAE9C,8DAA0D;AAC1D,2CAAwC;AACxC,mDAA8D;AAE9D;;;;;GAKG;AACH,MAAa,aAAc,SAAQ,qBAAS;IACxC;;;OAGG;IACH;QACI,KAAK,CAAC,2BAAa,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,KAAK,CAAC,OAAO,CAAC,EACV,IAAI,EACJ,MAAM,EACN,MAAM,EACN,MAAM,EACN,UAAU,EACV,SAAS,EACT,KAAK,EACL,iBAAiB,EACjB,SAAS,EACT,iBAAiB,EACjB,eAAe,EACf,SAAS,EACT,gBAAgB,EAChB,qBAAqB,EACrB,uBAAuB,EACvB,6BAA6B,EAC7B,2BAA2B,EAC3B,oBAAoB,EACpB,uBAAuB,EACvB,QAAQ,EACR,OAAO,EACP,YAAY,EACZ,KAAK,EACL,YAAY,EACZ,aAAa,EACb,MAAM,EACc;QACpB,MAAM,IAAI,GAAG,IAAI,QAAQ,EAAE,CAAC;QAE5B,MAAM,uBAAc,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC;QAEvD,IAAI,MAAM,EAAE,MAAM,EAAE,CAAC;YACjB,MAAM,OAAO,CAAC,GAAG,CACb,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,CAC1B,uBAAc,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAC3C,CACJ,CAAC;QACN,CAAC;QAED,MAAM,gCAAc,CAAC,SAAS,CAAC,IAAI,EAAE;YACjC,MAAM;YACN,MAAM;YACN,UAAU;YACV,SAAS;YACT,KAAK;YACL,iBAAiB;YACjB,SAAS;YACT,iBAAiB;YACjB,eAAe;YACf,SAAS;YACT,gBAAgB;YAChB,qBAAqB;YACrB,uBAAuB;YACvB,6BAA6B;YAC7B,2BAA2B;YAC3B,oBAAoB;YACpB,uBAAuB;YACvB,QAAQ;YACR,OAAO;YACP,YAAY;YACZ,KAAK;YACL,YAAY;YACZ,aAAa;YACb,MAAM;SACT,CAAC,CAAC;QAEH,OAAO,uBAAc,CAAC,KAAK,CACvB,IAAI,CAAC,QAAQ,EACb,IAAI,EACJ,wBAAU,CAAC,gCAAgC,EAAE,EAC7C,wBAAU,CAAC,gCAAgC,EAAE,EAC7C,wBAAU,CAAC,oBAAoB,EAAE,CACpC,CAAC;IACN,CAAC;CACJ;AAhHD,sCAgHC"}
|
|
@@ -26,6 +26,7 @@ export declare class MarkdownConverter extends Converter {
|
|
|
26
26
|
* @param {EmulatedMediaType} [options.emulatedMediaType] - Emulated media type for the conversion.
|
|
27
27
|
* @param {string} [options.waitDelay] - Delay before the conversion process starts.
|
|
28
28
|
* @param {string} [options.waitForExpression] - JavaScript expression to wait for before completing the conversion.
|
|
29
|
+
* @param {string} [options.waitForSelector] - CSS selector to wait for before completing the conversion.
|
|
29
30
|
* @param {string} [options.userAgent] - User agent string to use during the conversion.
|
|
30
31
|
* @param {Record<string, string>} [options.extraHttpHeaders] - Additional HTTP headers for the conversion.
|
|
31
32
|
* @param {number []} [options.failOnHttpStatusCodes] - Whether to fail on HTTP status code.
|
|
@@ -40,5 +41,5 @@ export declare class MarkdownConverter extends Converter {
|
|
|
40
41
|
* @param {Split} [options.split] - Split the PDF into multiple files.
|
|
41
42
|
* @returns {Promise<Buffer>} A Promise resolving to the converted PDF content as a buffer
|
|
42
43
|
*/
|
|
43
|
-
convert({ html, markdown, header, footer, properties, pdfFormat, pdfUA, emulatedMediaType, waitDelay, waitForExpression, userAgent, extraHttpHeaders, failOnHttpStatusCodes, failOnConsoleExceptions, failOnResourceHttpStatusCodes, failOnResourceLoadingFailed, skipNetworkIdleEvent, generateDocumentOutline, metadata, cookies, downloadFrom, split }: MarkdownConversionOptions): Promise<Buffer>;
|
|
44
|
+
convert({ html, markdown, header, footer, properties, pdfFormat, pdfUA, emulatedMediaType, waitDelay, waitForExpression, waitForSelector, userAgent, extraHttpHeaders, failOnHttpStatusCodes, failOnConsoleExceptions, failOnResourceHttpStatusCodes, failOnResourceLoadingFailed, skipNetworkIdleEvent, generateDocumentOutline, metadata, cookies, downloadFrom, split, userPassword, ownerPassword, embeds }: MarkdownConversionOptions): Promise<Buffer>;
|
|
44
45
|
}
|
|
@@ -33,6 +33,7 @@ class MarkdownConverter extends converter_1.Converter {
|
|
|
33
33
|
* @param {EmulatedMediaType} [options.emulatedMediaType] - Emulated media type for the conversion.
|
|
34
34
|
* @param {string} [options.waitDelay] - Delay before the conversion process starts.
|
|
35
35
|
* @param {string} [options.waitForExpression] - JavaScript expression to wait for before completing the conversion.
|
|
36
|
+
* @param {string} [options.waitForSelector] - CSS selector to wait for before completing the conversion.
|
|
36
37
|
* @param {string} [options.userAgent] - User agent string to use during the conversion.
|
|
37
38
|
* @param {Record<string, string>} [options.extraHttpHeaders] - Additional HTTP headers for the conversion.
|
|
38
39
|
* @param {number []} [options.failOnHttpStatusCodes] - Whether to fail on HTTP status code.
|
|
@@ -47,7 +48,7 @@ class MarkdownConverter extends converter_1.Converter {
|
|
|
47
48
|
* @param {Split} [options.split] - Split the PDF into multiple files.
|
|
48
49
|
* @returns {Promise<Buffer>} A Promise resolving to the converted PDF content as a buffer
|
|
49
50
|
*/
|
|
50
|
-
async convert({ html, markdown, header, footer, properties, pdfFormat, pdfUA, emulatedMediaType, waitDelay, waitForExpression, userAgent, extraHttpHeaders, failOnHttpStatusCodes, failOnConsoleExceptions, failOnResourceHttpStatusCodes, failOnResourceLoadingFailed, skipNetworkIdleEvent, generateDocumentOutline, metadata, cookies, downloadFrom, split }) {
|
|
51
|
+
async convert({ html, markdown, header, footer, properties, pdfFormat, pdfUA, emulatedMediaType, waitDelay, waitForExpression, waitForSelector, userAgent, extraHttpHeaders, failOnHttpStatusCodes, failOnConsoleExceptions, failOnResourceHttpStatusCodes, failOnResourceLoadingFailed, skipNetworkIdleEvent, generateDocumentOutline, metadata, cookies, downloadFrom, split, userPassword, ownerPassword, embeds }) {
|
|
51
52
|
const data = new FormData();
|
|
52
53
|
await common_1.GotenbergUtils.addFile(data, html, 'index.html');
|
|
53
54
|
await common_1.GotenbergUtils.addFile(data, markdown, 'file.md');
|
|
@@ -60,6 +61,7 @@ class MarkdownConverter extends converter_1.Converter {
|
|
|
60
61
|
emulatedMediaType,
|
|
61
62
|
waitDelay,
|
|
62
63
|
waitForExpression,
|
|
64
|
+
waitForSelector,
|
|
63
65
|
userAgent,
|
|
64
66
|
extraHttpHeaders,
|
|
65
67
|
failOnHttpStatusCodes,
|
|
@@ -71,7 +73,10 @@ class MarkdownConverter extends converter_1.Converter {
|
|
|
71
73
|
split,
|
|
72
74
|
failOnResourceHttpStatusCodes,
|
|
73
75
|
failOnResourceLoadingFailed,
|
|
74
|
-
generateDocumentOutline
|
|
76
|
+
generateDocumentOutline,
|
|
77
|
+
userPassword,
|
|
78
|
+
ownerPassword,
|
|
79
|
+
embeds
|
|
75
80
|
});
|
|
76
81
|
return common_1.GotenbergUtils.fetch(this.endpoint, data, main_config_1.Chromiumly.getGotenbergApiBasicAuthUsername(), main_config_1.Chromiumly.getGotenbergApiBasicAuthPassword(), main_config_1.Chromiumly.getCustomHttpHeaders());
|
|
77
82
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.converter.js","sourceRoot":"","sources":["../../../src/chromium/converters/markdown.converter.ts"],"names":[],"mappings":";;;AAAA,yCAA8C;AAE9C,8DAA0D;AAC1D,2CAAwC;AACxC,mDAA8D;AAE9D;;;;;GAKG;AACH,MAAa,iBAAkB,SAAQ,qBAAS;IAC5C;;;OAGG;IACH;QACI,KAAK,CAAC,2BAAa,CAAC,QAAQ,CAAC,CAAC;IAClC,CAAC;IAED
|
|
1
|
+
{"version":3,"file":"markdown.converter.js","sourceRoot":"","sources":["../../../src/chromium/converters/markdown.converter.ts"],"names":[],"mappings":";;;AAAA,yCAA8C;AAE9C,8DAA0D;AAC1D,2CAAwC;AACxC,mDAA8D;AAE9D;;;;;GAKG;AACH,MAAa,iBAAkB,SAAQ,qBAAS;IAC5C;;;OAGG;IACH;QACI,KAAK,CAAC,2BAAa,CAAC,QAAQ,CAAC,CAAC;IAClC,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,KAAK,CAAC,OAAO,CAAC,EACV,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,MAAM,EACN,UAAU,EACV,SAAS,EACT,KAAK,EACL,iBAAiB,EACjB,SAAS,EACT,iBAAiB,EACjB,eAAe,EACf,SAAS,EACT,gBAAgB,EAChB,qBAAqB,EACrB,uBAAuB,EACvB,6BAA6B,EAC7B,2BAA2B,EAC3B,oBAAoB,EACpB,uBAAuB,EACvB,QAAQ,EACR,OAAO,EACP,YAAY,EACZ,KAAK,EACL,YAAY,EACZ,aAAa,EACb,MAAM,EACkB;QACxB,MAAM,IAAI,GAAG,IAAI,QAAQ,EAAE,CAAC;QAE5B,MAAM,uBAAc,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC;QAEvD,MAAM,uBAAc,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;QAExD,MAAM,gCAAc,CAAC,SAAS,CAAC,IAAI,EAAE;YACjC,MAAM;YACN,MAAM;YACN,UAAU;YACV,SAAS;YACT,KAAK;YACL,iBAAiB;YACjB,SAAS;YACT,iBAAiB;YACjB,eAAe;YACf,SAAS;YACT,gBAAgB;YAChB,qBAAqB;YACrB,uBAAuB;YACvB,oBAAoB;YACpB,QAAQ;YACR,OAAO;YACP,YAAY;YACZ,KAAK;YACL,6BAA6B;YAC7B,2BAA2B;YAC3B,uBAAuB;YACvB,YAAY;YACZ,aAAa;YACb,MAAM;SACT,CAAC,CAAC;QAEH,OAAO,uBAAc,CAAC,KAAK,CACvB,IAAI,CAAC,QAAQ,EACb,IAAI,EACJ,wBAAU,CAAC,gCAAgC,EAAE,EAC7C,wBAAU,CAAC,gCAAgC,EAAE,EAC7C,wBAAU,CAAC,oBAAoB,EAAE,CACpC,CAAC;IACN,CAAC;CACJ;AA3GD,8CA2GC"}
|
|
@@ -25,6 +25,7 @@ export declare class UrlConverter extends Converter {
|
|
|
25
25
|
* @param {EmulatedMediaType} [options.emulatedMediaType] - Emulated media type for the conversion.
|
|
26
26
|
* @param {string} [options.waitDelay] - Delay before the conversion process starts.
|
|
27
27
|
* @param {string} [options.waitForExpression] - JavaScript expression to wait for before completing the conversion.
|
|
28
|
+
* @param {string} [options.waitForSelector] - CSS selector to wait for before completing the conversion.
|
|
28
29
|
* @param {string} [options.userAgent] - User agent string to use during the conversion.
|
|
29
30
|
* @param {Record<string, string>} [options.extraHttpHeaders] - Additional HTTP headers for the conversion.
|
|
30
31
|
* @param {number[]} [options.failOnHttpStatusCodes] - Whether to fail on HTTP status code.
|
|
@@ -39,5 +40,5 @@ export declare class UrlConverter extends Converter {
|
|
|
39
40
|
* @param {Split} [options.split] - Split the PDF into multiple files.
|
|
40
41
|
* @returns {Promise<Buffer>} A Promise resolving to the converted PDF content as a buffer
|
|
41
42
|
*/
|
|
42
|
-
convert({ url, header, footer, properties, pdfFormat, pdfUA, emulatedMediaType, waitDelay, waitForExpression, userAgent, extraHttpHeaders, failOnHttpStatusCodes, failOnResourceHttpStatusCodes, failOnResourceLoadingFailed, failOnConsoleExceptions, skipNetworkIdleEvent, metadata, cookies, downloadFrom, generateDocumentOutline, split }: UrlConversionOptions): Promise<Buffer>;
|
|
43
|
+
convert({ url, header, footer, properties, pdfFormat, pdfUA, emulatedMediaType, waitDelay, waitForExpression, waitForSelector, userAgent, extraHttpHeaders, failOnHttpStatusCodes, failOnResourceHttpStatusCodes, failOnResourceLoadingFailed, failOnConsoleExceptions, skipNetworkIdleEvent, metadata, cookies, downloadFrom, generateDocumentOutline, split, userPassword, ownerPassword, embeds }: UrlConversionOptions): Promise<Buffer>;
|
|
43
44
|
}
|
|
@@ -33,6 +33,7 @@ class UrlConverter extends converter_1.Converter {
|
|
|
33
33
|
* @param {EmulatedMediaType} [options.emulatedMediaType] - Emulated media type for the conversion.
|
|
34
34
|
* @param {string} [options.waitDelay] - Delay before the conversion process starts.
|
|
35
35
|
* @param {string} [options.waitForExpression] - JavaScript expression to wait for before completing the conversion.
|
|
36
|
+
* @param {string} [options.waitForSelector] - CSS selector to wait for before completing the conversion.
|
|
36
37
|
* @param {string} [options.userAgent] - User agent string to use during the conversion.
|
|
37
38
|
* @param {Record<string, string>} [options.extraHttpHeaders] - Additional HTTP headers for the conversion.
|
|
38
39
|
* @param {number[]} [options.failOnHttpStatusCodes] - Whether to fail on HTTP status code.
|
|
@@ -47,7 +48,7 @@ class UrlConverter extends converter_1.Converter {
|
|
|
47
48
|
* @param {Split} [options.split] - Split the PDF into multiple files.
|
|
48
49
|
* @returns {Promise<Buffer>} A Promise resolving to the converted PDF content as a buffer
|
|
49
50
|
*/
|
|
50
|
-
async convert({ url, header, footer, properties, pdfFormat, pdfUA, emulatedMediaType, waitDelay, waitForExpression, userAgent, extraHttpHeaders, failOnHttpStatusCodes, failOnResourceHttpStatusCodes, failOnResourceLoadingFailed, failOnConsoleExceptions, skipNetworkIdleEvent, metadata, cookies, downloadFrom, generateDocumentOutline, split }) {
|
|
51
|
+
async convert({ url, header, footer, properties, pdfFormat, pdfUA, emulatedMediaType, waitDelay, waitForExpression, waitForSelector, userAgent, extraHttpHeaders, failOnHttpStatusCodes, failOnResourceHttpStatusCodes, failOnResourceLoadingFailed, failOnConsoleExceptions, skipNetworkIdleEvent, metadata, cookies, downloadFrom, generateDocumentOutline, split, userPassword, ownerPassword, embeds }) {
|
|
51
52
|
const _url = new url_1.URL(url);
|
|
52
53
|
const data = new FormData();
|
|
53
54
|
data.append('url', _url.href);
|
|
@@ -60,6 +61,7 @@ class UrlConverter extends converter_1.Converter {
|
|
|
60
61
|
emulatedMediaType,
|
|
61
62
|
waitDelay,
|
|
62
63
|
waitForExpression,
|
|
64
|
+
waitForSelector,
|
|
63
65
|
userAgent,
|
|
64
66
|
extraHttpHeaders,
|
|
65
67
|
failOnHttpStatusCodes,
|
|
@@ -71,7 +73,10 @@ class UrlConverter extends converter_1.Converter {
|
|
|
71
73
|
failOnResourceHttpStatusCodes,
|
|
72
74
|
failOnResourceLoadingFailed,
|
|
73
75
|
generateDocumentOutline,
|
|
74
|
-
split
|
|
76
|
+
split,
|
|
77
|
+
userPassword,
|
|
78
|
+
ownerPassword,
|
|
79
|
+
embeds
|
|
75
80
|
});
|
|
76
81
|
return common_1.GotenbergUtils.fetch(this.endpoint, data, main_config_1.Chromiumly.getGotenbergApiBasicAuthUsername(), main_config_1.Chromiumly.getGotenbergApiBasicAuthPassword(), main_config_1.Chromiumly.getCustomHttpHeaders());
|
|
77
82
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.converter.js","sourceRoot":"","sources":["../../../src/chromium/converters/url.converter.ts"],"names":[],"mappings":";;;AAAA,6BAA0B;AAE1B,yCAA8C;AAE9C,8DAA0D;AAC1D,2CAAwC;AACxC,mDAA8D;AAE9D;;;;;GAKG;AACH,MAAa,YAAa,SAAQ,qBAAS;IACvC;;;OAGG;IACH;QACI,KAAK,CAAC,2BAAa,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;IAED
|
|
1
|
+
{"version":3,"file":"url.converter.js","sourceRoot":"","sources":["../../../src/chromium/converters/url.converter.ts"],"names":[],"mappings":";;;AAAA,6BAA0B;AAE1B,yCAA8C;AAE9C,8DAA0D;AAC1D,2CAAwC;AACxC,mDAA8D;AAE9D;;;;;GAKG;AACH,MAAa,YAAa,SAAQ,qBAAS;IACvC;;;OAGG;IACH;QACI,KAAK,CAAC,2BAAa,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,KAAK,CAAC,OAAO,CAAC,EACV,GAAG,EACH,MAAM,EACN,MAAM,EACN,UAAU,EACV,SAAS,EACT,KAAK,EACL,iBAAiB,EACjB,SAAS,EACT,iBAAiB,EACjB,eAAe,EACf,SAAS,EACT,gBAAgB,EAChB,qBAAqB,EACrB,6BAA6B,EAC7B,2BAA2B,EAC3B,uBAAuB,EACvB,oBAAoB,EACpB,QAAQ,EACR,OAAO,EACP,YAAY,EACZ,uBAAuB,EACvB,KAAK,EACL,YAAY,EACZ,aAAa,EACb,MAAM,EACa;QACnB,MAAM,IAAI,GAAG,IAAI,SAAG,CAAC,GAAG,CAAC,CAAC;QAC1B,MAAM,IAAI,GAAG,IAAI,QAAQ,EAAE,CAAC;QAE5B,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QAE9B,MAAM,gCAAc,CAAC,SAAS,CAAC,IAAI,EAAE;YACjC,MAAM;YACN,MAAM;YACN,UAAU;YACV,SAAS;YACT,KAAK;YACL,iBAAiB;YACjB,SAAS;YACT,iBAAiB;YACjB,eAAe;YACf,SAAS;YACT,gBAAgB;YAChB,qBAAqB;YACrB,uBAAuB;YACvB,oBAAoB;YACpB,QAAQ;YACR,OAAO;YACP,YAAY;YACZ,6BAA6B;YAC7B,2BAA2B;YAC3B,uBAAuB;YACvB,KAAK;YACL,YAAY;YACZ,aAAa;YACb,MAAM;SACT,CAAC,CAAC;QAEH,OAAO,uBAAc,CAAC,KAAK,CACvB,IAAI,CAAC,QAAQ,EACb,IAAI,EACJ,wBAAU,CAAC,gCAAgC,EAAE,EAC7C,wBAAU,CAAC,gCAAgC,EAAE,EAC7C,wBAAU,CAAC,oBAAoB,EAAE,CACpC,CAAC;IACN,CAAC;CACJ;AAxGD,oCAwGC"}
|
|
@@ -16,6 +16,7 @@ export type ChromiumOptions = {
|
|
|
16
16
|
emulatedMediaType?: EmulatedMediaType;
|
|
17
17
|
waitDelay?: string;
|
|
18
18
|
waitForExpression?: string;
|
|
19
|
+
waitForSelector?: string;
|
|
19
20
|
extraHttpHeaders?: Record<string, string>;
|
|
20
21
|
failOnHttpStatusCodes?: number[];
|
|
21
22
|
failOnConsoleExceptions?: boolean;
|
|
@@ -41,6 +41,9 @@ export type ConversionOptions = ChromiumOptions & {
|
|
|
41
41
|
metadata?: Metadata;
|
|
42
42
|
cookies?: Cookie[];
|
|
43
43
|
split?: Split;
|
|
44
|
+
userPassword?: string;
|
|
45
|
+
ownerPassword?: string;
|
|
46
|
+
embeds?: PathLikeOrReadStream[];
|
|
44
47
|
};
|
|
45
48
|
export type HtmlConversionOptions = ConversionOptions & {
|
|
46
49
|
html: PathLikeOrReadStream;
|
|
@@ -11,6 +11,9 @@ export type ImageProperties = {
|
|
|
11
11
|
export type ScreenshotOptions = Omit<ChromiumOptions, 'assets' | 'header' | 'footer'> & {
|
|
12
12
|
properties?: ImageProperties;
|
|
13
13
|
optimizeForSpeed?: boolean;
|
|
14
|
+
userPassword?: string;
|
|
15
|
+
ownerPassword?: string;
|
|
16
|
+
embeds?: PathLikeOrReadStream[];
|
|
14
17
|
};
|
|
15
18
|
export type HtmlScreenshotOptions = ScreenshotOptions & {
|
|
16
19
|
html: PathLikeOrReadStream;
|
|
@@ -21,6 +21,7 @@ export declare class HtmlScreenshot extends Screenshot {
|
|
|
21
21
|
* @param {EmulatedMediaType} [options.emulatedMediaType] - Emulated media type for the screenshot.
|
|
22
22
|
* @param {string} [options.waitDelay] - Delay before the screenshot process starts.
|
|
23
23
|
* @param {string} [options.waitForExpression] - JavaScript expression to wait for before completing the screenshot.
|
|
24
|
+
* @param {string} [options.waitForSelector] - CSS selector to wait for before completing the screenshot.
|
|
24
25
|
* @param {Record<string, string>} [options.extraHttpHeaders] - Additional HTTP headers for the screenshot.
|
|
25
26
|
* @param {boolean} [options.failOnConsoleExceptions] - Whether to fail on console exceptions during screenshot.
|
|
26
27
|
* @param {number []} [options.failOnHttpStatusCodes] - Whether to fail on HTTP status code.
|
|
@@ -32,5 +33,5 @@ export declare class HtmlScreenshot extends Screenshot {
|
|
|
32
33
|
* @param {boolean} [options.generateDocumentOutline] - Whether to generate document outline.
|
|
33
34
|
* @returns {Promise<Buffer>} A Promise resolving to the image buffer.
|
|
34
35
|
*/
|
|
35
|
-
capture({ html, properties, emulatedMediaType, waitDelay, waitForExpression, extraHttpHeaders, failOnConsoleExceptions, failOnHttpStatusCodes, failOnResourceHttpStatusCodes, failOnResourceLoadingFailed, skipNetworkIdleEvent, optimizeForSpeed, downloadFrom, generateDocumentOutline }: HtmlScreenshotOptions): Promise<Buffer>;
|
|
36
|
+
capture({ html, properties, emulatedMediaType, waitDelay, waitForExpression, waitForSelector, extraHttpHeaders, failOnConsoleExceptions, failOnHttpStatusCodes, failOnResourceHttpStatusCodes, failOnResourceLoadingFailed, skipNetworkIdleEvent, optimizeForSpeed, downloadFrom, generateDocumentOutline, userPassword, ownerPassword, embeds }: HtmlScreenshotOptions): Promise<Buffer>;
|
|
36
37
|
}
|
|
@@ -28,6 +28,7 @@ class HtmlScreenshot extends screenshot_1.Screenshot {
|
|
|
28
28
|
* @param {EmulatedMediaType} [options.emulatedMediaType] - Emulated media type for the screenshot.
|
|
29
29
|
* @param {string} [options.waitDelay] - Delay before the screenshot process starts.
|
|
30
30
|
* @param {string} [options.waitForExpression] - JavaScript expression to wait for before completing the screenshot.
|
|
31
|
+
* @param {string} [options.waitForSelector] - CSS selector to wait for before completing the screenshot.
|
|
31
32
|
* @param {Record<string, string>} [options.extraHttpHeaders] - Additional HTTP headers for the screenshot.
|
|
32
33
|
* @param {boolean} [options.failOnConsoleExceptions] - Whether to fail on console exceptions during screenshot.
|
|
33
34
|
* @param {number []} [options.failOnHttpStatusCodes] - Whether to fail on HTTP status code.
|
|
@@ -39,7 +40,7 @@ class HtmlScreenshot extends screenshot_1.Screenshot {
|
|
|
39
40
|
* @param {boolean} [options.generateDocumentOutline] - Whether to generate document outline.
|
|
40
41
|
* @returns {Promise<Buffer>} A Promise resolving to the image buffer.
|
|
41
42
|
*/
|
|
42
|
-
async capture({ html, properties, emulatedMediaType, waitDelay, waitForExpression, extraHttpHeaders, failOnConsoleExceptions, failOnHttpStatusCodes, failOnResourceHttpStatusCodes, failOnResourceLoadingFailed, skipNetworkIdleEvent, optimizeForSpeed, downloadFrom, generateDocumentOutline }) {
|
|
43
|
+
async capture({ html, properties, emulatedMediaType, waitDelay, waitForExpression, waitForSelector, extraHttpHeaders, failOnConsoleExceptions, failOnHttpStatusCodes, failOnResourceHttpStatusCodes, failOnResourceLoadingFailed, skipNetworkIdleEvent, optimizeForSpeed, downloadFrom, generateDocumentOutline, userPassword, ownerPassword, embeds }) {
|
|
43
44
|
const data = new FormData();
|
|
44
45
|
await common_1.GotenbergUtils.addFile(data, html, 'index.html');
|
|
45
46
|
await screenshot_utils_1.ScreenshotUtils.customize(data, {
|
|
@@ -47,6 +48,7 @@ class HtmlScreenshot extends screenshot_1.Screenshot {
|
|
|
47
48
|
emulatedMediaType,
|
|
48
49
|
waitDelay,
|
|
49
50
|
waitForExpression,
|
|
51
|
+
waitForSelector,
|
|
50
52
|
extraHttpHeaders,
|
|
51
53
|
failOnHttpStatusCodes,
|
|
52
54
|
failOnConsoleExceptions,
|
|
@@ -55,7 +57,10 @@ class HtmlScreenshot extends screenshot_1.Screenshot {
|
|
|
55
57
|
skipNetworkIdleEvent,
|
|
56
58
|
optimizeForSpeed,
|
|
57
59
|
downloadFrom,
|
|
58
|
-
generateDocumentOutline
|
|
60
|
+
generateDocumentOutline,
|
|
61
|
+
userPassword,
|
|
62
|
+
ownerPassword,
|
|
63
|
+
embeds
|
|
59
64
|
});
|
|
60
65
|
return common_1.GotenbergUtils.fetch(this.endpoint, data, main_config_1.Chromiumly.getGotenbergApiBasicAuthUsername(), main_config_1.Chromiumly.getGotenbergApiBasicAuthPassword(), main_config_1.Chromiumly.getCustomHttpHeaders());
|
|
61
66
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html.screenshot.js","sourceRoot":"","sources":["../../../src/chromium/screenshots/html.screenshot.ts"],"names":[],"mappings":";;;AAAA,yCAA8C;AAC9C,mDAA8D;AAC9D,gEAA4D;AAC5D,6CAA0C;AAG1C;;;;;GAKG;AACH,MAAa,cAAe,SAAQ,uBAAU;IAC1C;;;OAGG;IACH;QACI,KAAK,CAAC,2BAAa,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IAED
|
|
1
|
+
{"version":3,"file":"html.screenshot.js","sourceRoot":"","sources":["../../../src/chromium/screenshots/html.screenshot.ts"],"names":[],"mappings":";;;AAAA,yCAA8C;AAC9C,mDAA8D;AAC9D,gEAA4D;AAC5D,6CAA0C;AAG1C;;;;;GAKG;AACH,MAAa,cAAe,SAAQ,uBAAU;IAC1C;;;OAGG;IACH;QACI,KAAK,CAAC,2BAAa,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,KAAK,CAAC,OAAO,CAAC,EACV,IAAI,EACJ,UAAU,EACV,iBAAiB,EACjB,SAAS,EACT,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,uBAAuB,EACvB,qBAAqB,EACrB,6BAA6B,EAC7B,2BAA2B,EAC3B,oBAAoB,EACpB,gBAAgB,EAChB,YAAY,EACZ,uBAAuB,EACvB,YAAY,EACZ,aAAa,EACb,MAAM,EACc;QACpB,MAAM,IAAI,GAAG,IAAI,QAAQ,EAAE,CAAC;QAE5B,MAAM,uBAAc,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC;QAEvD,MAAM,kCAAe,CAAC,SAAS,CAAC,IAAI,EAAE;YAClC,UAAU;YACV,iBAAiB;YACjB,SAAS;YACT,iBAAiB;YACjB,eAAe;YACf,gBAAgB;YAChB,qBAAqB;YACrB,uBAAuB;YACvB,6BAA6B;YAC7B,2BAA2B;YAC3B,oBAAoB;YACpB,gBAAgB;YAChB,YAAY;YACZ,uBAAuB;YACvB,YAAY;YACZ,aAAa;YACb,MAAM;SACT,CAAC,CAAC;QAEH,OAAO,uBAAc,CAAC,KAAK,CACvB,IAAI,CAAC,QAAQ,EACb,IAAI,EACJ,wBAAU,CAAC,gCAAgC,EAAE,EAC7C,wBAAU,CAAC,gCAAgC,EAAE,EAC7C,wBAAU,CAAC,oBAAoB,EAAE,CACpC,CAAC;IACN,CAAC;CACJ;AAlFD,wCAkFC"}
|
|
@@ -22,6 +22,7 @@ export declare class MarkdownScreenshot extends Screenshot {
|
|
|
22
22
|
* @param {EmulatedMediaType} [options.emulatedMediaType] - Emulated media type for the screenshot.
|
|
23
23
|
* @param {string} [options.waitDelay] - Delay before the screenshot process starts.
|
|
24
24
|
* @param {string} [options.waitForExpression] - JavaScript expression to wait for before completing the screenshot.
|
|
25
|
+
* @param {string} [options.waitForSelector] - CSS selector to wait for before completing the screenshot.
|
|
25
26
|
* @param {Record<string, string>} [options.extraHttpHeaders] - Additional HTTP headers for the screenshot.
|
|
26
27
|
* @param {number []} [options.failOnHttpStatusCodes] - Whether to fail on HTTP status code.
|
|
27
28
|
* @param {boolean} [options.failOnConsoleExceptions] - Whether to fail on console exceptions during screenshot.
|
|
@@ -33,5 +34,5 @@ export declare class MarkdownScreenshot extends Screenshot {
|
|
|
33
34
|
* @param {boolean} [options.generateDocumentOutline] - Whether to generate document outline.
|
|
34
35
|
* @returns {Promise<Buffer>} A Promise resolving to the image buffer.
|
|
35
36
|
*/
|
|
36
|
-
capture({ html, markdown, properties, emulatedMediaType, waitDelay, waitForExpression, extraHttpHeaders, failOnHttpStatusCodes, failOnConsoleExceptions, skipNetworkIdleEvent, optimizeForSpeed, downloadFrom, failOnResourceHttpStatusCodes, failOnResourceLoadingFailed, generateDocumentOutline }: MarkdownScreenshotOptions): Promise<Buffer>;
|
|
37
|
+
capture({ html, markdown, properties, emulatedMediaType, waitDelay, waitForExpression, waitForSelector, extraHttpHeaders, failOnHttpStatusCodes, failOnConsoleExceptions, skipNetworkIdleEvent, optimizeForSpeed, downloadFrom, failOnResourceHttpStatusCodes, failOnResourceLoadingFailed, generateDocumentOutline, userPassword, ownerPassword, embeds }: MarkdownScreenshotOptions): Promise<Buffer>;
|
|
37
38
|
}
|
|
@@ -29,6 +29,7 @@ class MarkdownScreenshot extends screenshot_1.Screenshot {
|
|
|
29
29
|
* @param {EmulatedMediaType} [options.emulatedMediaType] - Emulated media type for the screenshot.
|
|
30
30
|
* @param {string} [options.waitDelay] - Delay before the screenshot process starts.
|
|
31
31
|
* @param {string} [options.waitForExpression] - JavaScript expression to wait for before completing the screenshot.
|
|
32
|
+
* @param {string} [options.waitForSelector] - CSS selector to wait for before completing the screenshot.
|
|
32
33
|
* @param {Record<string, string>} [options.extraHttpHeaders] - Additional HTTP headers for the screenshot.
|
|
33
34
|
* @param {number []} [options.failOnHttpStatusCodes] - Whether to fail on HTTP status code.
|
|
34
35
|
* @param {boolean} [options.failOnConsoleExceptions] - Whether to fail on console exceptions during screenshot.
|
|
@@ -40,7 +41,7 @@ class MarkdownScreenshot extends screenshot_1.Screenshot {
|
|
|
40
41
|
* @param {boolean} [options.generateDocumentOutline] - Whether to generate document outline.
|
|
41
42
|
* @returns {Promise<Buffer>} A Promise resolving to the image buffer.
|
|
42
43
|
*/
|
|
43
|
-
async capture({ html, markdown, properties, emulatedMediaType, waitDelay, waitForExpression, extraHttpHeaders, failOnHttpStatusCodes, failOnConsoleExceptions, skipNetworkIdleEvent, optimizeForSpeed, downloadFrom, failOnResourceHttpStatusCodes, failOnResourceLoadingFailed, generateDocumentOutline }) {
|
|
44
|
+
async capture({ html, markdown, properties, emulatedMediaType, waitDelay, waitForExpression, waitForSelector, extraHttpHeaders, failOnHttpStatusCodes, failOnConsoleExceptions, skipNetworkIdleEvent, optimizeForSpeed, downloadFrom, failOnResourceHttpStatusCodes, failOnResourceLoadingFailed, generateDocumentOutline, userPassword, ownerPassword, embeds }) {
|
|
44
45
|
const data = new FormData();
|
|
45
46
|
await common_1.GotenbergUtils.addFile(data, html, 'index.html');
|
|
46
47
|
await common_1.GotenbergUtils.addFile(data, markdown, 'file.md');
|
|
@@ -49,6 +50,7 @@ class MarkdownScreenshot extends screenshot_1.Screenshot {
|
|
|
49
50
|
emulatedMediaType,
|
|
50
51
|
waitDelay,
|
|
51
52
|
waitForExpression,
|
|
53
|
+
waitForSelector,
|
|
52
54
|
extraHttpHeaders,
|
|
53
55
|
failOnHttpStatusCodes,
|
|
54
56
|
failOnConsoleExceptions,
|
|
@@ -57,7 +59,10 @@ class MarkdownScreenshot extends screenshot_1.Screenshot {
|
|
|
57
59
|
skipNetworkIdleEvent,
|
|
58
60
|
optimizeForSpeed,
|
|
59
61
|
downloadFrom,
|
|
60
|
-
generateDocumentOutline
|
|
62
|
+
generateDocumentOutline,
|
|
63
|
+
userPassword,
|
|
64
|
+
ownerPassword,
|
|
65
|
+
embeds
|
|
61
66
|
});
|
|
62
67
|
return common_1.GotenbergUtils.fetch(this.endpoint, data, main_config_1.Chromiumly.getGotenbergApiBasicAuthUsername(), main_config_1.Chromiumly.getGotenbergApiBasicAuthPassword(), main_config_1.Chromiumly.getCustomHttpHeaders());
|
|
63
68
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.screenshot.js","sourceRoot":"","sources":["../../../src/chromium/screenshots/markdown.screenshot.ts"],"names":[],"mappings":";;;AAAA,yCAA8C;AAE9C,gEAA4D;AAC5D,6CAA0C;AAC1C,mDAA8D;AAE9D;;;;;GAKG;AACH,MAAa,kBAAmB,SAAQ,uBAAU;IAC9C;;;OAGG;IACH;QACI,KAAK,CAAC,2BAAa,CAAC,QAAQ,CAAC,CAAC;IAClC,CAAC;IAED
|
|
1
|
+
{"version":3,"file":"markdown.screenshot.js","sourceRoot":"","sources":["../../../src/chromium/screenshots/markdown.screenshot.ts"],"names":[],"mappings":";;;AAAA,yCAA8C;AAE9C,gEAA4D;AAC5D,6CAA0C;AAC1C,mDAA8D;AAE9D;;;;;GAKG;AACH,MAAa,kBAAmB,SAAQ,uBAAU;IAC9C;;;OAGG;IACH;QACI,KAAK,CAAC,2BAAa,CAAC,QAAQ,CAAC,CAAC;IAClC,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,KAAK,CAAC,OAAO,CAAC,EACV,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,iBAAiB,EACjB,SAAS,EACT,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,qBAAqB,EACrB,uBAAuB,EACvB,oBAAoB,EACpB,gBAAgB,EAChB,YAAY,EACZ,6BAA6B,EAC7B,2BAA2B,EAC3B,uBAAuB,EACvB,YAAY,EACZ,aAAa,EACb,MAAM,EACkB;QACxB,MAAM,IAAI,GAAG,IAAI,QAAQ,EAAE,CAAC;QAE5B,MAAM,uBAAc,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC;QAEvD,MAAM,uBAAc,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;QAExD,MAAM,kCAAe,CAAC,SAAS,CAAC,IAAI,EAAE;YAClC,UAAU;YACV,iBAAiB;YACjB,SAAS;YACT,iBAAiB;YACjB,eAAe;YACf,gBAAgB;YAChB,qBAAqB;YACrB,uBAAuB;YACvB,6BAA6B;YAC7B,2BAA2B;YAC3B,oBAAoB;YACpB,gBAAgB;YAChB,YAAY;YACZ,uBAAuB;YACvB,YAAY;YACZ,aAAa;YACb,MAAM;SACT,CAAC,CAAC;QAEH,OAAO,uBAAc,CAAC,KAAK,CACvB,IAAI,CAAC,QAAQ,EACb,IAAI,EACJ,wBAAU,CAAC,gCAAgC,EAAE,EAC7C,wBAAU,CAAC,gCAAgC,EAAE,EAC7C,wBAAU,CAAC,oBAAoB,EAAE,CACpC,CAAC;IACN,CAAC;CACJ;AAtFD,gDAsFC"}
|
|
@@ -21,6 +21,7 @@ export declare class UrlScreenshot extends Screenshot {
|
|
|
21
21
|
* @param {EmulatedMediaType} [options.emulatedMediaType] - Emulated media type for the screenshot.
|
|
22
22
|
* @param {string} [options.waitDelay] - Delay before the screenshot process starts.
|
|
23
23
|
* @param {string} [options.waitForExpression] - JavaScript expression to wait for before completing the screenshot.
|
|
24
|
+
* @param {string} [options.waitForSelector] - CSS selector to wait for before completing the screenshot.
|
|
24
25
|
* @param {Record<string, string>} [options.extraHttpHeaders] - Additional HTTP headers for the screenshot.
|
|
25
26
|
* @param {number []} [options.failOnHttpStatusCodes] - Whether to fail on HTTP status code.
|
|
26
27
|
* @param {boolean} [options.failOnConsoleExceptions] - Whether to fail on console exceptions during screenshot.
|
|
@@ -32,5 +33,5 @@ export declare class UrlScreenshot extends Screenshot {
|
|
|
32
33
|
* @param {boolean} [options.generateDocumentOutline] - Whether to generate document outline.
|
|
33
34
|
* @returns {Promise<Buffer>} A Promise resolving to the image buffer.
|
|
34
35
|
*/
|
|
35
|
-
capture({ url, properties, emulatedMediaType, waitDelay, waitForExpression, extraHttpHeaders, failOnHttpStatusCodes, failOnConsoleExceptions, failOnResourceHttpStatusCodes, failOnResourceLoadingFailed, skipNetworkIdleEvent, optimizeForSpeed, cookies, generateDocumentOutline }: UrlScreenshotOptions): Promise<Buffer>;
|
|
36
|
+
capture({ url, properties, emulatedMediaType, waitDelay, waitForExpression, waitForSelector, extraHttpHeaders, failOnHttpStatusCodes, failOnConsoleExceptions, failOnResourceHttpStatusCodes, failOnResourceLoadingFailed, skipNetworkIdleEvent, optimizeForSpeed, cookies, generateDocumentOutline, userPassword, ownerPassword, embeds }: UrlScreenshotOptions): Promise<Buffer>;
|
|
36
37
|
}
|
|
@@ -29,6 +29,7 @@ class UrlScreenshot extends screenshot_1.Screenshot {
|
|
|
29
29
|
* @param {EmulatedMediaType} [options.emulatedMediaType] - Emulated media type for the screenshot.
|
|
30
30
|
* @param {string} [options.waitDelay] - Delay before the screenshot process starts.
|
|
31
31
|
* @param {string} [options.waitForExpression] - JavaScript expression to wait for before completing the screenshot.
|
|
32
|
+
* @param {string} [options.waitForSelector] - CSS selector to wait for before completing the screenshot.
|
|
32
33
|
* @param {Record<string, string>} [options.extraHttpHeaders] - Additional HTTP headers for the screenshot.
|
|
33
34
|
* @param {number []} [options.failOnHttpStatusCodes] - Whether to fail on HTTP status code.
|
|
34
35
|
* @param {boolean} [options.failOnConsoleExceptions] - Whether to fail on console exceptions during screenshot.
|
|
@@ -40,7 +41,7 @@ class UrlScreenshot extends screenshot_1.Screenshot {
|
|
|
40
41
|
* @param {boolean} [options.generateDocumentOutline] - Whether to generate document outline.
|
|
41
42
|
* @returns {Promise<Buffer>} A Promise resolving to the image buffer.
|
|
42
43
|
*/
|
|
43
|
-
async capture({ url, properties, emulatedMediaType, waitDelay, waitForExpression, extraHttpHeaders, failOnHttpStatusCodes, failOnConsoleExceptions, failOnResourceHttpStatusCodes, failOnResourceLoadingFailed, skipNetworkIdleEvent, optimizeForSpeed, cookies, generateDocumentOutline }) {
|
|
44
|
+
async capture({ url, properties, emulatedMediaType, waitDelay, waitForExpression, waitForSelector, extraHttpHeaders, failOnHttpStatusCodes, failOnConsoleExceptions, failOnResourceHttpStatusCodes, failOnResourceLoadingFailed, skipNetworkIdleEvent, optimizeForSpeed, cookies, generateDocumentOutline, userPassword, ownerPassword, embeds }) {
|
|
44
45
|
const _url = new url_1.URL(url);
|
|
45
46
|
const data = new FormData();
|
|
46
47
|
data.append('url', _url.href);
|
|
@@ -49,6 +50,7 @@ class UrlScreenshot extends screenshot_1.Screenshot {
|
|
|
49
50
|
emulatedMediaType,
|
|
50
51
|
waitDelay,
|
|
51
52
|
waitForExpression,
|
|
53
|
+
waitForSelector,
|
|
52
54
|
extraHttpHeaders,
|
|
53
55
|
failOnHttpStatusCodes,
|
|
54
56
|
failOnConsoleExceptions,
|
|
@@ -57,7 +59,10 @@ class UrlScreenshot extends screenshot_1.Screenshot {
|
|
|
57
59
|
skipNetworkIdleEvent,
|
|
58
60
|
optimizeForSpeed,
|
|
59
61
|
cookies,
|
|
60
|
-
generateDocumentOutline
|
|
62
|
+
generateDocumentOutline,
|
|
63
|
+
userPassword,
|
|
64
|
+
ownerPassword,
|
|
65
|
+
embeds
|
|
61
66
|
});
|
|
62
67
|
return common_1.GotenbergUtils.fetch(this.endpoint, data, main_config_1.Chromiumly.getGotenbergApiBasicAuthUsername(), main_config_1.Chromiumly.getGotenbergApiBasicAuthPassword(), main_config_1.Chromiumly.getCustomHttpHeaders());
|
|
63
68
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.screenshot.js","sourceRoot":"","sources":["../../../src/chromium/screenshots/url.screenshot.ts"],"names":[],"mappings":";;;AAAA,6BAA0B;AAE1B,yCAA8C;AAE9C,gEAA4D;AAC5D,6CAA0C;AAC1C,mDAA8D;AAE9D;;;;;GAKG;AACH,MAAa,aAAc,SAAQ,uBAAU;IACzC;;;OAGG;IACH;QACI,KAAK,CAAC,2BAAa,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;IAED
|
|
1
|
+
{"version":3,"file":"url.screenshot.js","sourceRoot":"","sources":["../../../src/chromium/screenshots/url.screenshot.ts"],"names":[],"mappings":";;;AAAA,6BAA0B;AAE1B,yCAA8C;AAE9C,gEAA4D;AAC5D,6CAA0C;AAC1C,mDAA8D;AAE9D;;;;;GAKG;AACH,MAAa,aAAc,SAAQ,uBAAU;IACzC;;;OAGG;IACH;QACI,KAAK,CAAC,2BAAa,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,KAAK,CAAC,OAAO,CAAC,EACV,GAAG,EACH,UAAU,EACV,iBAAiB,EACjB,SAAS,EACT,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,qBAAqB,EACrB,uBAAuB,EACvB,6BAA6B,EAC7B,2BAA2B,EAC3B,oBAAoB,EACpB,gBAAgB,EAChB,OAAO,EACP,uBAAuB,EACvB,YAAY,EACZ,aAAa,EACb,MAAM,EACa;QACnB,MAAM,IAAI,GAAG,IAAI,SAAG,CAAC,GAAG,CAAC,CAAC;QAC1B,MAAM,IAAI,GAAG,IAAI,QAAQ,EAAE,CAAC;QAE5B,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QAE9B,MAAM,kCAAe,CAAC,SAAS,CAAC,IAAI,EAAE;YAClC,UAAU;YACV,iBAAiB;YACjB,SAAS;YACT,iBAAiB;YACjB,eAAe;YACf,gBAAgB;YAChB,qBAAqB;YACrB,uBAAuB;YACvB,6BAA6B;YAC7B,2BAA2B;YAC3B,oBAAoB;YACpB,gBAAgB;YAChB,OAAO;YACP,uBAAuB;YACvB,YAAY;YACZ,aAAa;YACb,MAAM;SACT,CAAC,CAAC;QAEH,OAAO,uBAAc,CAAC,KAAK,CACvB,IAAI,CAAC,QAAQ,EACb,IAAI,EACJ,wBAAU,CAAC,gCAAgC,EAAE,EAC7C,wBAAU,CAAC,gCAAgC,EAAE,EAC7C,wBAAU,CAAC,oBAAoB,EAAE,CACpC,CAAC;IACN,CAAC;CACJ;AAnFD,sCAmFC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ConversionOptions, PageProperties } from '../interfaces/converter.types';
|
|
2
|
+
import { PathLikeOrReadStream } from '../../common';
|
|
2
3
|
/**
|
|
3
4
|
* Utility class for handling common tasks related to conversion.
|
|
4
5
|
*/
|
|
@@ -10,6 +11,15 @@ export declare class ConverterUtils {
|
|
|
10
11
|
* @param {PageProperties} pageProperties - The page properties to be added to the FormData.
|
|
11
12
|
*/
|
|
12
13
|
static addPageProperties(data: FormData, pageProperties: PageProperties): void;
|
|
14
|
+
/**
|
|
15
|
+
* Adds files to the FormData object with a custom field name.
|
|
16
|
+
*
|
|
17
|
+
* @param {PathLikeOrReadStream[]} files - An array of files to be added to the FormData.
|
|
18
|
+
* @param {FormData} data - The FormData object to which files will be added.
|
|
19
|
+
* @param {string} fieldName - The field name to use when appending files (e.g., 'files', 'embeds').
|
|
20
|
+
* @returns {Promise<void>} A Promise that resolves once the files have been added.
|
|
21
|
+
*/
|
|
22
|
+
static addFilesWithFieldName(files: PathLikeOrReadStream[], data: FormData, fieldName: string): Promise<void>;
|
|
13
23
|
/**
|
|
14
24
|
* Customizes the FormData object based on the provided conversion options.
|
|
15
25
|
*
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.ConverterUtils = void 0;
|
|
7
|
+
const fs_1 = require("fs");
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const consumers_1 = require("node:stream/consumers");
|
|
4
10
|
const common_1 = require("../../common");
|
|
5
11
|
/**
|
|
6
12
|
* Utility class for handling common tasks related to conversion.
|
|
@@ -56,6 +62,32 @@ class ConverterUtils {
|
|
|
56
62
|
data.append('nativePageRanges', `${pageProperties.nativePageRanges.from}-${pageProperties.nativePageRanges.to}`);
|
|
57
63
|
}
|
|
58
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* Adds files to the FormData object with a custom field name.
|
|
67
|
+
*
|
|
68
|
+
* @param {PathLikeOrReadStream[]} files - An array of files to be added to the FormData.
|
|
69
|
+
* @param {FormData} data - The FormData object to which files will be added.
|
|
70
|
+
* @param {string} fieldName - The field name to use when appending files (e.g., 'files', 'embeds').
|
|
71
|
+
* @returns {Promise<void>} A Promise that resolves once the files have been added.
|
|
72
|
+
*/
|
|
73
|
+
static async addFilesWithFieldName(files, data, fieldName) {
|
|
74
|
+
await Promise.all(files.map(async (file, index) => {
|
|
75
|
+
const filename = path_1.default.basename(typeof file === 'string' ? file : `file${index + 1}`);
|
|
76
|
+
if (Buffer.isBuffer(file)) {
|
|
77
|
+
data.append(fieldName, new Blob([file]), filename);
|
|
78
|
+
}
|
|
79
|
+
else if (file instanceof fs_1.ReadStream) {
|
|
80
|
+
const content = await (0, consumers_1.blob)(file);
|
|
81
|
+
data.append(fieldName, content, filename);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
await fs_1.promises.access(file, fs_1.constants.R_OK);
|
|
85
|
+
const _filename = path_1.default.basename(file.toString());
|
|
86
|
+
const content = await (0, fs_1.openAsBlob)(file);
|
|
87
|
+
data.append(fieldName, content, _filename);
|
|
88
|
+
}
|
|
89
|
+
}));
|
|
90
|
+
}
|
|
59
91
|
/**
|
|
60
92
|
* Customizes the FormData object based on the provided conversion options.
|
|
61
93
|
*
|
|
@@ -90,6 +122,9 @@ class ConverterUtils {
|
|
|
90
122
|
if (options.waitForExpression) {
|
|
91
123
|
data.append('waitForExpression', options.waitForExpression);
|
|
92
124
|
}
|
|
125
|
+
if (options.waitForSelector) {
|
|
126
|
+
data.append('waitForSelector', options.waitForSelector);
|
|
127
|
+
}
|
|
93
128
|
if (options.userAgent) {
|
|
94
129
|
data.append('userAgent', options.userAgent);
|
|
95
130
|
}
|
|
@@ -131,6 +166,15 @@ class ConverterUtils {
|
|
|
131
166
|
data.append('splitUnify', String(options.split.unify));
|
|
132
167
|
}
|
|
133
168
|
}
|
|
169
|
+
if (options.userPassword) {
|
|
170
|
+
data.append('userPassword', options.userPassword);
|
|
171
|
+
}
|
|
172
|
+
if (options.ownerPassword) {
|
|
173
|
+
data.append('ownerPassword', options.ownerPassword);
|
|
174
|
+
}
|
|
175
|
+
if (options.embeds && options.embeds.length > 0) {
|
|
176
|
+
await ConverterUtils.addFilesWithFieldName(options.embeds, data, 'embeds');
|
|
177
|
+
}
|
|
134
178
|
}
|
|
135
179
|
}
|
|
136
180
|
exports.ConverterUtils = ConverterUtils;
|