chromiumly 2.2.0 → 2.3.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.
- package/README.md +1 -0
- package/dist/chromium/converters/html.converter.d.ts +8 -3
- package/dist/chromium/converters/html.converter.js +14 -18
- package/dist/chromium/converters/html.converter.js.map +1 -1
- package/dist/chromium/converters/markdown.converter.d.ts +8 -3
- package/dist/chromium/converters/markdown.converter.js +14 -18
- package/dist/chromium/converters/markdown.converter.js.map +1 -1
- package/dist/chromium/converters/url.converter.d.ts +8 -3
- package/dist/chromium/converters/url.converter.js +14 -19
- package/dist/chromium/converters/url.converter.js.map +1 -1
- package/dist/chromium/interfaces/converter.types.d.ts +17 -0
- package/dist/chromium/utils/converter.utils.d.ts +2 -1
- package/dist/chromium/utils/converter.utils.js +44 -0
- package/dist/chromium/utils/converter.utils.js.map +1 -1
- package/dist/common/gotenberg.utils.js.map +1 -1
- package/dist/gotenberg.js.map +1 -1
- package/dist/libre-office/utils/libre-office.utils.js.map +1 -1
- package/dist/pdf-engines/pdf.engine.d.ts +2 -1
- package/dist/pdf-engines/pdf.engine.js +5 -2
- package/dist/pdf-engines/pdf.engine.js.map +1 -1
- package/dist/pdf-engines/utils/engine.utils.js.map +1 -1
- package/package.json +27 -12
- package/src/chromium/converters/html.converter.ts +26 -23
- package/src/chromium/converters/markdown.converter.ts +27 -22
- package/src/chromium/converters/url.converter.ts +27 -22
- package/src/chromium/interfaces/converter.types.ts +18 -0
- package/src/chromium/utils/converter.utils.ts +63 -1
- package/src/chromium/utils/tests/converter.utils.test.ts +233 -7
- package/src/pdf-engines/pdf.engine.ts +13 -1
- package/src/pdf-engines/tests/pdf.engine.test.ts +2 -1
- package/dist/chromium/interfaces/converter.interface.d.ts +0 -10
- package/dist/chromium/interfaces/converter.interface.js +0 -3
- package/dist/chromium/interfaces/converter.interface.js.map +0 -1
- package/src/chromium/interfaces/converter.interface.ts +0 -12
package/README.md
CHANGED
|
@@ -121,6 +121,7 @@ type PageProperties = {
|
|
|
121
121
|
};
|
|
122
122
|
preferCssPageSize?: boolean; // Define whether to prefer page size as defined by CSS (default false)
|
|
123
123
|
printBackground?: boolean; // Print the background graphics (default false)
|
|
124
|
+
omitBackground?: boolean; // Hide the default white background and allow generating PDFs with transparency (default false)
|
|
124
125
|
landscape?: boolean; // Set the paper orientation to landscape (default false)
|
|
125
126
|
scale?: number; // The scale of the page rendering (default 1.0)
|
|
126
127
|
nativePageRanges?: { from: number; to: number }; // Page ranges to print
|
|
@@ -2,17 +2,22 @@
|
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import { PathLike } from "fs";
|
|
4
4
|
import { PdfFormat } from "../../common";
|
|
5
|
-
import { IConverter } from "../interfaces/converter.interface";
|
|
6
5
|
import { EmulatedMediaType, PageProperties } from "../interfaces/converter.types";
|
|
7
6
|
import { Converter } from "./converter";
|
|
8
|
-
export declare class HtmlConverter extends Converter
|
|
7
|
+
export declare class HtmlConverter extends Converter {
|
|
9
8
|
constructor();
|
|
10
|
-
convert({ html, header, footer, properties, pdfFormat, emulatedMediaType, }: {
|
|
9
|
+
convert({ html, header, footer, properties, pdfFormat, pdfUA, emulatedMediaType, waitDelay, waitForExpression, userAgent, extraHttpHeaders, failOnConsoleExceptions, }: {
|
|
11
10
|
html: PathLike;
|
|
12
11
|
header?: PathLike;
|
|
13
12
|
footer?: PathLike;
|
|
14
13
|
properties?: PageProperties;
|
|
15
14
|
pdfFormat?: PdfFormat;
|
|
15
|
+
pdfUA?: boolean;
|
|
16
16
|
emulatedMediaType?: EmulatedMediaType;
|
|
17
|
+
waitDelay?: string;
|
|
18
|
+
waitForExpression?: string;
|
|
19
|
+
userAgent?: string;
|
|
20
|
+
extraHttpHeaders?: Record<string, string>;
|
|
21
|
+
failOnConsoleExceptions?: boolean;
|
|
17
22
|
}): Promise<Buffer>;
|
|
18
23
|
}
|
|
@@ -12,28 +12,24 @@ class HtmlConverter extends converter_1.Converter {
|
|
|
12
12
|
constructor() {
|
|
13
13
|
super(main_config_1.ChromiumRoute.HTML);
|
|
14
14
|
}
|
|
15
|
-
convert({ html, header, footer, properties, pdfFormat, emulatedMediaType, }) {
|
|
15
|
+
convert({ html, header, footer, properties, pdfFormat, pdfUA, emulatedMediaType, waitDelay, waitForExpression, userAgent, extraHttpHeaders, failOnConsoleExceptions, }) {
|
|
16
16
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
17
17
|
yield fs_1.promises.access(html, fs_1.constants.R_OK);
|
|
18
18
|
const data = new form_data_1.default();
|
|
19
|
-
if (pdfFormat) {
|
|
20
|
-
data.append("pdfFormat", pdfFormat);
|
|
21
|
-
}
|
|
22
19
|
data.append("index.html", (0, fs_1.createReadStream)(html));
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
20
|
+
converter_utils_1.ConverterUtils.customize(data, {
|
|
21
|
+
header,
|
|
22
|
+
footer,
|
|
23
|
+
properties,
|
|
24
|
+
pdfFormat,
|
|
25
|
+
pdfUA,
|
|
26
|
+
emulatedMediaType,
|
|
27
|
+
waitDelay,
|
|
28
|
+
waitForExpression,
|
|
29
|
+
userAgent,
|
|
30
|
+
extraHttpHeaders,
|
|
31
|
+
failOnConsoleExceptions,
|
|
32
|
+
});
|
|
37
33
|
return common_1.GotenbergUtils.fetch(this.endpoint, data);
|
|
38
34
|
});
|
|
39
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html.converter.js","sourceRoot":"","sources":["../../../src/chromium/converters/html.converter.ts"],"names":[],"mappings":";;;;AAAA,2BAAqE;AAErE,kEAAiC;AAEjC,yCAAyD;
|
|
1
|
+
{"version":3,"file":"html.converter.js","sourceRoot":"","sources":["../../../src/chromium/converters/html.converter.ts"],"names":[],"mappings":";;;;AAAA,2BAAqE;AAErE,kEAAiC;AAEjC,yCAAyD;AAKzD,8DAA0D;AAC1D,2CAAwC;AACxC,mDAAkD;AAElD,MAAa,aAAc,SAAQ,qBAAS;IAC1C;QACE,KAAK,CAAC,2BAAa,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IAEK,OAAO,CAAC,EACZ,IAAI,EACJ,MAAM,EACN,MAAM,EACN,UAAU,EACV,SAAS,EACT,KAAK,EACL,iBAAiB,EACjB,SAAS,EACT,iBAAiB,EACjB,SAAS,EACT,gBAAgB,EAChB,uBAAuB,GAcxB;;YACC,MAAM,aAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,cAAS,CAAC,IAAI,CAAC,CAAC;YAC5C,MAAM,IAAI,GAAG,IAAI,mBAAQ,EAAE,CAAC;YAE5B,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,IAAA,qBAAgB,EAAC,IAAI,CAAC,CAAC,CAAC;YAElD,gCAAc,CAAC,SAAS,CAAC,IAAI,EAAE;gBAC7B,MAAM;gBACN,MAAM;gBACN,UAAU;gBACV,SAAS;gBACT,KAAK;gBACL,iBAAiB;gBACjB,SAAS;gBACT,iBAAiB;gBACjB,SAAS;gBACT,gBAAgB;gBAChB,uBAAuB;aACxB,CAAC,CAAC;YAEH,OAAO,uBAAc,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QACnD,CAAC;KAAA;CACF;AArDD,sCAqDC"}
|
|
@@ -2,18 +2,23 @@
|
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import { PathLike } from "fs";
|
|
4
4
|
import { PdfFormat } from "../../common";
|
|
5
|
-
import { IConverter } from "../interfaces/converter.interface";
|
|
6
5
|
import { EmulatedMediaType, PageProperties } from "../interfaces/converter.types";
|
|
7
6
|
import { Converter } from "./converter";
|
|
8
|
-
export declare class MarkdownConverter extends Converter
|
|
7
|
+
export declare class MarkdownConverter extends Converter {
|
|
9
8
|
constructor();
|
|
10
|
-
convert({ html, markdown, header, footer, properties, pdfFormat, emulatedMediaType, }: {
|
|
9
|
+
convert({ html, markdown, header, footer, properties, pdfFormat, pdfUA, emulatedMediaType, waitDelay, waitForExpression, userAgent, extraHttpHeaders, failOnConsoleExceptions, }: {
|
|
11
10
|
html: PathLike;
|
|
12
11
|
markdown: PathLike;
|
|
13
12
|
header?: PathLike;
|
|
14
13
|
footer?: PathLike;
|
|
15
14
|
properties?: PageProperties;
|
|
16
15
|
pdfFormat?: PdfFormat;
|
|
16
|
+
pdfUA?: boolean;
|
|
17
17
|
emulatedMediaType?: EmulatedMediaType;
|
|
18
|
+
waitDelay?: string;
|
|
19
|
+
waitForExpression?: string;
|
|
20
|
+
userAgent?: string;
|
|
21
|
+
extraHttpHeaders?: Record<string, string>;
|
|
22
|
+
failOnConsoleExceptions?: boolean;
|
|
18
23
|
}): Promise<Buffer>;
|
|
19
24
|
}
|
|
@@ -12,30 +12,26 @@ class MarkdownConverter extends converter_1.Converter {
|
|
|
12
12
|
constructor() {
|
|
13
13
|
super(main_config_1.ChromiumRoute.MARKDOWN);
|
|
14
14
|
}
|
|
15
|
-
convert({ html, markdown, header, footer, properties, pdfFormat, emulatedMediaType, }) {
|
|
15
|
+
convert({ html, markdown, header, footer, properties, pdfFormat, pdfUA, emulatedMediaType, waitDelay, waitForExpression, userAgent, extraHttpHeaders, failOnConsoleExceptions, }) {
|
|
16
16
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
17
17
|
yield fs_1.promises.access(html, fs_1.constants.R_OK);
|
|
18
18
|
yield fs_1.promises.access(markdown, fs_1.constants.R_OK);
|
|
19
19
|
const data = new form_data_1.default();
|
|
20
|
-
if (pdfFormat) {
|
|
21
|
-
data.append("pdfFormat", pdfFormat);
|
|
22
|
-
}
|
|
23
20
|
data.append("index.html", (0, fs_1.createReadStream)(html));
|
|
24
21
|
data.append("file.md", (0, fs_1.createReadStream)(markdown));
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
22
|
+
converter_utils_1.ConverterUtils.customize(data, {
|
|
23
|
+
header,
|
|
24
|
+
footer,
|
|
25
|
+
properties,
|
|
26
|
+
pdfFormat,
|
|
27
|
+
pdfUA,
|
|
28
|
+
emulatedMediaType,
|
|
29
|
+
waitDelay,
|
|
30
|
+
waitForExpression,
|
|
31
|
+
userAgent,
|
|
32
|
+
extraHttpHeaders,
|
|
33
|
+
failOnConsoleExceptions,
|
|
34
|
+
});
|
|
39
35
|
return common_1.GotenbergUtils.fetch(this.endpoint, data);
|
|
40
36
|
});
|
|
41
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.converter.js","sourceRoot":"","sources":["../../../src/chromium/converters/markdown.converter.ts"],"names":[],"mappings":";;;;AAAA,2BAAqE;AAErE,kEAAiC;AAEjC,yCAAyD;
|
|
1
|
+
{"version":3,"file":"markdown.converter.js","sourceRoot":"","sources":["../../../src/chromium/converters/markdown.converter.ts"],"names":[],"mappings":";;;;AAAA,2BAAqE;AAErE,kEAAiC;AAEjC,yCAAyD;AAKzD,8DAA0D;AAC1D,2CAAwC;AACxC,mDAAkD;AAElD,MAAa,iBAAkB,SAAQ,qBAAS;IAC9C;QACE,KAAK,CAAC,2BAAa,CAAC,QAAQ,CAAC,CAAC;IAChC,CAAC;IAEK,OAAO,CAAC,EACZ,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,MAAM,EACN,UAAU,EACV,SAAS,EACT,KAAK,EACL,iBAAiB,EACjB,SAAS,EACT,iBAAiB,EACjB,SAAS,EACT,gBAAgB,EAChB,uBAAuB,GAexB;;YACC,MAAM,aAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,cAAS,CAAC,IAAI,CAAC,CAAC;YAC5C,MAAM,aAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,cAAS,CAAC,IAAI,CAAC,CAAC;YAChD,MAAM,IAAI,GAAG,IAAI,mBAAQ,EAAE,CAAC;YAE5B,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,IAAA,qBAAgB,EAAC,IAAI,CAAC,CAAC,CAAC;YAClD,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,IAAA,qBAAgB,EAAC,QAAQ,CAAC,CAAC,CAAC;YAEnD,gCAAc,CAAC,SAAS,CAAC,IAAI,EAAE;gBAC7B,MAAM;gBACN,MAAM;gBACN,UAAU;gBACV,SAAS;gBACT,KAAK;gBACL,iBAAiB;gBACjB,SAAS;gBACT,iBAAiB;gBACjB,SAAS;gBACT,gBAAgB;gBAChB,uBAAuB;aACxB,CAAC,CAAC;YAEH,OAAO,uBAAc,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QACnD,CAAC;KAAA;CACF;AAzDD,8CAyDC"}
|
|
@@ -2,17 +2,22 @@
|
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import { PathLike } from "fs";
|
|
4
4
|
import { PdfFormat } from "../../common";
|
|
5
|
-
import { IConverter } from "../interfaces/converter.interface";
|
|
6
5
|
import { EmulatedMediaType, PageProperties } from "../interfaces/converter.types";
|
|
7
6
|
import { Converter } from "./converter";
|
|
8
|
-
export declare class UrlConverter extends Converter
|
|
7
|
+
export declare class UrlConverter extends Converter {
|
|
9
8
|
constructor();
|
|
10
|
-
convert({ url, header, footer, properties, pdfFormat, emulatedMediaType, }: {
|
|
9
|
+
convert({ url, header, footer, properties, pdfFormat, pdfUA, emulatedMediaType, waitDelay, waitForExpression, userAgent, extraHttpHeaders, failOnConsoleExceptions, }: {
|
|
11
10
|
url: string;
|
|
12
11
|
header?: PathLike;
|
|
13
12
|
footer?: PathLike;
|
|
14
13
|
properties?: PageProperties;
|
|
15
14
|
pdfFormat?: PdfFormat;
|
|
15
|
+
pdfUA?: boolean;
|
|
16
16
|
emulatedMediaType?: EmulatedMediaType;
|
|
17
|
+
waitDelay?: string;
|
|
18
|
+
waitForExpression?: string;
|
|
19
|
+
userAgent?: string;
|
|
20
|
+
extraHttpHeaders?: Record<string, string>;
|
|
21
|
+
failOnConsoleExceptions?: boolean;
|
|
17
22
|
}): Promise<Buffer>;
|
|
18
23
|
}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UrlConverter = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const fs_1 = require("fs");
|
|
6
5
|
const url_1 = require("url");
|
|
7
6
|
const form_data_1 = tslib_1.__importDefault(require("form-data"));
|
|
8
7
|
const common_1 = require("../../common");
|
|
@@ -13,28 +12,24 @@ class UrlConverter extends converter_1.Converter {
|
|
|
13
12
|
constructor() {
|
|
14
13
|
super(main_config_1.ChromiumRoute.URL);
|
|
15
14
|
}
|
|
16
|
-
convert({ url, header, footer, properties, pdfFormat, emulatedMediaType, }) {
|
|
15
|
+
convert({ url, header, footer, properties, pdfFormat, pdfUA, emulatedMediaType, waitDelay, waitForExpression, userAgent, extraHttpHeaders, failOnConsoleExceptions, }) {
|
|
17
16
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
18
17
|
const _url = new url_1.URL(url);
|
|
19
18
|
const data = new form_data_1.default();
|
|
20
|
-
if (pdfFormat) {
|
|
21
|
-
data.append("pdfFormat", pdfFormat);
|
|
22
|
-
}
|
|
23
19
|
data.append("url", _url.href);
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
20
|
+
converter_utils_1.ConverterUtils.customize(data, {
|
|
21
|
+
header,
|
|
22
|
+
footer,
|
|
23
|
+
properties,
|
|
24
|
+
pdfFormat,
|
|
25
|
+
pdfUA,
|
|
26
|
+
emulatedMediaType,
|
|
27
|
+
waitDelay,
|
|
28
|
+
waitForExpression,
|
|
29
|
+
userAgent,
|
|
30
|
+
extraHttpHeaders,
|
|
31
|
+
failOnConsoleExceptions,
|
|
32
|
+
});
|
|
38
33
|
return common_1.GotenbergUtils.fetch(this.endpoint, data);
|
|
39
34
|
});
|
|
40
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.converter.js","sourceRoot":"","sources":["../../../src/chromium/converters/url.converter.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"url.converter.js","sourceRoot":"","sources":["../../../src/chromium/converters/url.converter.ts"],"names":[],"mappings":";;;;AAEA,6BAA0B;AAE1B,kEAAiC;AAEjC,yCAAyD;AAKzD,8DAA0D;AAC1D,2CAAwC;AACxC,mDAAkD;AAElD,MAAa,YAAa,SAAQ,qBAAS;IACzC;QACE,KAAK,CAAC,2BAAa,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;IAEK,OAAO,CAAC,EACZ,GAAG,EACH,MAAM,EACN,MAAM,EACN,UAAU,EACV,SAAS,EACT,KAAK,EACL,iBAAiB,EACjB,SAAS,EACT,iBAAiB,EACjB,SAAS,EACT,gBAAgB,EAChB,uBAAuB,GAcxB;;YACC,MAAM,IAAI,GAAG,IAAI,SAAG,CAAC,GAAG,CAAC,CAAC;YAC1B,MAAM,IAAI,GAAG,IAAI,mBAAQ,EAAE,CAAC;YAE5B,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YAE9B,gCAAc,CAAC,SAAS,CAAC,IAAI,EAAE;gBAC7B,MAAM;gBACN,MAAM;gBACN,UAAU;gBACV,SAAS;gBACT,KAAK;gBACL,iBAAiB;gBACjB,SAAS;gBACT,iBAAiB;gBACjB,SAAS;gBACT,gBAAgB;gBAChB,uBAAuB;aACxB,CAAC,CAAC;YAEH,OAAO,uBAAc,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QACnD,CAAC;KAAA;CACF;AArDD,oCAqDC"}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { PathLike } from "fs";
|
|
3
|
+
import { PdfFormat } from "../../common";
|
|
1
4
|
type PageSize = {
|
|
2
5
|
width: number;
|
|
3
6
|
height: number;
|
|
@@ -13,6 +16,7 @@ export type PageProperties = {
|
|
|
13
16
|
margins?: PageMargins;
|
|
14
17
|
preferCssPageSize?: boolean;
|
|
15
18
|
printBackground?: boolean;
|
|
19
|
+
omitBackground?: boolean;
|
|
16
20
|
landscape?: boolean;
|
|
17
21
|
scale?: number;
|
|
18
22
|
nativePageRanges?: {
|
|
@@ -21,4 +25,17 @@ export type PageProperties = {
|
|
|
21
25
|
};
|
|
22
26
|
};
|
|
23
27
|
export type EmulatedMediaType = "screen" | "print";
|
|
28
|
+
export type ConversionOptions = {
|
|
29
|
+
header?: PathLike;
|
|
30
|
+
footer?: PathLike;
|
|
31
|
+
properties?: PageProperties;
|
|
32
|
+
pdfFormat?: PdfFormat;
|
|
33
|
+
pdfUA?: boolean;
|
|
34
|
+
emulatedMediaType?: EmulatedMediaType;
|
|
35
|
+
waitDelay?: string;
|
|
36
|
+
waitForExpression?: string;
|
|
37
|
+
userAgent?: string;
|
|
38
|
+
extraHttpHeaders?: Record<string, string>;
|
|
39
|
+
failOnConsoleExceptions?: boolean;
|
|
40
|
+
};
|
|
24
41
|
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import FormData from "form-data";
|
|
2
|
-
import { PageProperties } from "../interfaces/converter.types";
|
|
2
|
+
import { ConversionOptions, PageProperties } from "../interfaces/converter.types";
|
|
3
3
|
export declare class ConverterUtils {
|
|
4
4
|
static injectPageProperties(data: FormData, pageProperties: PageProperties): void;
|
|
5
|
+
static customize(data: FormData, options: ConversionOptions): Promise<void>;
|
|
5
6
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ConverterUtils = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const fs_1 = require("fs");
|
|
4
6
|
const gotenberg_utils_1 = require("../../common/gotenberg.utils");
|
|
5
7
|
class ConverterUtils {
|
|
6
8
|
static injectPageProperties(data, pageProperties) {
|
|
@@ -25,6 +27,9 @@ class ConverterUtils {
|
|
|
25
27
|
if (pageProperties.printBackground) {
|
|
26
28
|
data.append("printBackground", String(pageProperties.printBackground));
|
|
27
29
|
}
|
|
30
|
+
if (pageProperties.omitBackground) {
|
|
31
|
+
data.append("omitBackground", String(pageProperties.omitBackground));
|
|
32
|
+
}
|
|
28
33
|
if (pageProperties.landscape) {
|
|
29
34
|
data.append("landscape", String(pageProperties.landscape));
|
|
30
35
|
}
|
|
@@ -40,6 +45,45 @@ class ConverterUtils {
|
|
|
40
45
|
data.append("nativePageRanges", `${pageProperties.nativePageRanges.from}-${pageProperties.nativePageRanges.to}`);
|
|
41
46
|
}
|
|
42
47
|
}
|
|
48
|
+
static customize(data, options) {
|
|
49
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
if (options.pdfFormat) {
|
|
51
|
+
data.append("pdfa", options.pdfFormat);
|
|
52
|
+
}
|
|
53
|
+
if (options.pdfUA) {
|
|
54
|
+
data.append("pdfua", String(options.pdfUA));
|
|
55
|
+
}
|
|
56
|
+
if (options.header) {
|
|
57
|
+
yield fs_1.promises.access(options.header, fs_1.constants.R_OK);
|
|
58
|
+
data.append("header.html", (0, fs_1.createReadStream)(options.header));
|
|
59
|
+
}
|
|
60
|
+
if (options.footer) {
|
|
61
|
+
yield fs_1.promises.access(options.footer, fs_1.constants.R_OK);
|
|
62
|
+
data.append("footer.html", (0, fs_1.createReadStream)(options.footer));
|
|
63
|
+
}
|
|
64
|
+
if (options.emulatedMediaType) {
|
|
65
|
+
data.append("emulatedMediaType", options.emulatedMediaType);
|
|
66
|
+
}
|
|
67
|
+
if (options.properties) {
|
|
68
|
+
ConverterUtils.injectPageProperties(data, options.properties);
|
|
69
|
+
}
|
|
70
|
+
if (options.waitDelay) {
|
|
71
|
+
data.append("waitDelay", options.waitDelay);
|
|
72
|
+
}
|
|
73
|
+
if (options.waitForExpression) {
|
|
74
|
+
data.append("waitForExpression", options.waitForExpression);
|
|
75
|
+
}
|
|
76
|
+
if (options.userAgent) {
|
|
77
|
+
data.append("userAgent", options.userAgent);
|
|
78
|
+
}
|
|
79
|
+
if (options.extraHttpHeaders) {
|
|
80
|
+
data.append("extraHttpHeaders", JSON.stringify(options.extraHttpHeaders));
|
|
81
|
+
}
|
|
82
|
+
if (options.failOnConsoleExceptions) {
|
|
83
|
+
data.append("failOnConsoleExceptions", String(options.failOnConsoleExceptions));
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
43
87
|
}
|
|
44
88
|
exports.ConverterUtils = ConverterUtils;
|
|
45
89
|
//# sourceMappingURL=converter.utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"converter.utils.js","sourceRoot":"","sources":["../../../src/chromium/utils/converter.utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"converter.utils.js","sourceRoot":"","sources":["../../../src/chromium/utils/converter.utils.ts"],"names":[],"mappings":";;;;AAAA,2BAA2D;AAG3D,kEAA8D;AAM9D,MAAa,cAAc;IAClB,MAAM,CAAC,oBAAoB,CAChC,IAAc,EACd,cAA8B;QAE9B,IAAI,cAAc,CAAC,IAAI,EAAE,CAAC;YACxB,gCAAc,CAAC,MAAM,CACnB,cAAc,CAAC,IAAI,CAAC,KAAK,IAAI,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,MAAM,IAAI,GAAG,EACrE,4EAA4E,CAC7E,CAAC;YAEF,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,cAAc,CAAC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,OAAO,CAAC,uBAAuB,EAAE,CAAC;gBACpC,IAAI,CAAC,MAAM,CACT,yBAAyB,EACzB,MAAM,CAAC,OAAO,CAAC,uBAAuB,CAAC,CACxC,CAAC;YACJ,CAAC;QACH,CAAC;KAAA;CACF;AA/HD,wCA+HC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gotenberg.utils.js","sourceRoot":"","sources":["../../src/common/gotenberg.utils.ts"],"names":[],"mappings":";;;;AACA,oEAA+B;AAE/B,MAAa,cAAc;IAClB,MAAM,CAAC,MAAM,CAAC,SAAkB,EAAE,OAAe;QACtD,IAAI,CAAC,SAAS,EAAE;
|
|
1
|
+
{"version":3,"file":"gotenberg.utils.js","sourceRoot":"","sources":["../../src/common/gotenberg.utils.ts"],"names":[],"mappings":";;;;AACA,oEAA+B;AAE/B,MAAa,cAAc;IAClB,MAAM,CAAC,MAAM,CAAC,SAAkB,EAAE,OAAe;QACtD,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;IAEM,MAAM,CAAO,KAAK,CAAC,QAAgB,EAAE,IAAc;;YACxD,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAK,EAAC,QAAQ,EAAE;gBACrC,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE,IAAI;gBACV,OAAO,oBACF,IAAI,CAAC,UAAU,EAAE,CACrB;aACF,CAAC,CAAC;YAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;gBACjB,MAAM,IAAI,KAAK,CAAC,GAAG,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;YAC/D,CAAC;YACD,OAAO,QAAQ,CAAC,MAAM,EAAE,CAAC;QAC3B,CAAC;KAAA;CACF;AArBD,wCAqBC"}
|
package/dist/gotenberg.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gotenberg.js","sourceRoot":"","sources":["../src/gotenberg.ts"],"names":[],"mappings":";;;;AAAA,OAAO,CAAC,GAAG,CAAC,0BAA0B,GAAG,GAAG,CAAC;AAE7C,uDAAiC;AACjC,mDAA6B;AAC7B,4DAA4B;AAE5B,wEAAwE;AACxE,MAAM,OAAO,GAAG,QAAQ,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;AAC/C,MAAM,eAAe,GAAG,MAAM,CAAC;AAE/B,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;AAEpE,oDAAoD;AACpD,IAAI,YAAY,CAAC,KAAK,EAAE;
|
|
1
|
+
{"version":3,"file":"gotenberg.js","sourceRoot":"","sources":["../src/gotenberg.ts"],"names":[],"mappings":";;;;AAAA,OAAO,CAAC,GAAG,CAAC,0BAA0B,GAAG,GAAG,CAAC;AAE7C,uDAAiC;AACjC,mDAA6B;AAC7B,4DAA4B;AAE5B,wEAAwE;AACxE,MAAM,OAAO,GAAG,QAAQ,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;AAC/C,MAAM,eAAe,GAAG,MAAM,CAAC;AAE/B,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;AAEpE,oDAAoD;AACpD,IAAI,YAAY,CAAC,KAAK,EAAE,CAAC;IACvB,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;AACzD,CAAC;AAED,MAAa,SAAS;;AAAtB,8BAGC;AAFe,kBAAQ,GACpB,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,gBAAM,CAAC,GAAG,CAAS,oBAAoB,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"libre-office.utils.js","sourceRoot":"","sources":["../../../src/libre-office/utils/libre-office.utils.ts"],"names":[],"mappings":";;;;AAAA,2BAAqE;AACrE,wDAAwB;AAIxB,yCAA8C;AAC9C,2CAAsD;AAGtD,MAAa,gBAAgB;IACpB,MAAM,CAAO,WAAW,CAAC,KAAiB,EAAE,IAAc;;YAC/D,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;
|
|
1
|
+
{"version":3,"file":"libre-office.utils.js","sourceRoot":"","sources":["../../../src/libre-office/utils/libre-office.utils.ts"],"names":[],"mappings":";;;;AAAA,2BAAqE;AACrE,wDAAwB;AAIxB,yCAA8C;AAC9C,2CAAsD;AAGtD,MAAa,gBAAgB;IACpB,MAAM,CAAO,WAAW,CAAC,KAAiB,EAAE,IAAc;;YAC/D,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBACzB,MAAM,aAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,cAAS,CAAC,IAAI,CAAC,CAAC;gBAC5C,MAAM,QAAQ,GAAG,cAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;gBAChD,MAAM,SAAS,GAAG,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;gBACzC,IAAI,mCAAuB,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;oBAChD,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAA,qBAAgB,EAAC,IAAI,CAAC,CAAC,CAAC;gBAChD,CAAC;qBAAM,CAAC;oBACN,MAAM,IAAI,KAAK,CAAC,GAAG,SAAS,mBAAmB,CAAC,CAAC;gBACnD,CAAC;YACH,CAAC;QACH,CAAC;KAAA;IAEM,MAAM,CAAC,oBAAoB,CAChC,IAAc,EACd,cAA8B;QAE9B,IAAI,cAAc,CAAC,SAAS,EAAE,CAAC;YAC7B,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC;QAC7D,CAAC;QAED,IAAI,cAAc,CAAC,gBAAgB,EAAE,CAAC;YACpC,uBAAc,CAAC,MAAM,CACnB,cAAc,CAAC,gBAAgB,CAAC,IAAI,GAAG,CAAC;gBACtC,cAAc,CAAC,gBAAgB,CAAC,EAAE,GAAG,CAAC;gBACtC,cAAc,CAAC,gBAAgB,CAAC,EAAE;oBAChC,cAAc,CAAC,gBAAgB,CAAC,IAAI,EACxC,0BAA0B,CAC3B,CAAC;YAEF,IAAI,CAAC,MAAM,CACT,kBAAkB,EAClB,GAAG,cAAc,CAAC,gBAAgB,CAAC,IAAI,IAAI,cAAc,CAAC,gBAAgB,CAAC,EAAE,EAAE,CAChF,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AArCD,4CAqCC"}
|
|
@@ -7,10 +7,11 @@ export declare class PDFEngine {
|
|
|
7
7
|
static merge({ files }: {
|
|
8
8
|
files: PathLike[];
|
|
9
9
|
}): Promise<Buffer>;
|
|
10
|
-
static convert({ files, properties, pdfFormat, merge, }: {
|
|
10
|
+
static convert({ files, properties, pdfFormat, pdfUA, merge, }: {
|
|
11
11
|
files: PathLike[];
|
|
12
12
|
properties?: PageProperties;
|
|
13
13
|
pdfFormat?: PdfFormat;
|
|
14
|
+
pdfUA?: boolean;
|
|
14
15
|
merge?: boolean;
|
|
15
16
|
}): Promise<Buffer>;
|
|
16
17
|
static generate(filename: string, buffer: Buffer): Promise<void>;
|
|
@@ -18,11 +18,14 @@ class PDFEngine {
|
|
|
18
18
|
return common_1.GotenbergUtils.fetch(endpoint, data);
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
|
-
static convert({ files, properties, pdfFormat, merge, }) {
|
|
21
|
+
static convert({ files, properties, pdfFormat, pdfUA, merge, }) {
|
|
22
22
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
23
23
|
const data = new form_data_1.default();
|
|
24
24
|
if (pdfFormat) {
|
|
25
|
-
data.append("
|
|
25
|
+
data.append("pdfa", pdfFormat);
|
|
26
|
+
}
|
|
27
|
+
if (pdfUA) {
|
|
28
|
+
data.append("pdfUA", String(pdfUA));
|
|
26
29
|
}
|
|
27
30
|
if (merge) {
|
|
28
31
|
data.append("merge", String(merge));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pdf.engine.js","sourceRoot":"","sources":["../../src/pdf-engines/pdf.engine.ts"],"names":[],"mappings":";;;;AAAA,2BAAwC;AACxC,wDAAwB;AAExB,kEAAiC;AAEjC,gDAA4C;AAC5C,sCAAsD;AACtD,kDAAmE;AACnE,uDAAsD;AAEtD,MAAa,SAAS;IACb,MAAM,CAAO,KAAK,CAAC,EAAE,KAAK,EAAyB;;YACxD,MAAM,IAAI,GAAG,IAAI,mBAAQ,EAAE,CAAC;YAC5B,MAAM,6BAAc,CAAC,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;YAC9C,MAAM,QAAQ,GAAG,GAAG,wBAAU,CAAC,kBAAkB,IAAI,wBAAU,CAAC,gBAAgB,IAAI,wBAAU,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC;YACzH,OAAO,uBAAc,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAC9C,CAAC;KAAA;IAEM,MAAM,CAAO,OAAO,CAAC,EAC1B,KAAK,EACL,UAAU,EACV,SAAS,EACT,KAAK,
|
|
1
|
+
{"version":3,"file":"pdf.engine.js","sourceRoot":"","sources":["../../src/pdf-engines/pdf.engine.ts"],"names":[],"mappings":";;;;AAAA,2BAAwC;AACxC,wDAAwB;AAExB,kEAAiC;AAEjC,gDAA4C;AAC5C,sCAAsD;AACtD,kDAAmE;AACnE,uDAAsD;AAEtD,MAAa,SAAS;IACb,MAAM,CAAO,KAAK,CAAC,EAAE,KAAK,EAAyB;;YACxD,MAAM,IAAI,GAAG,IAAI,mBAAQ,EAAE,CAAC;YAC5B,MAAM,6BAAc,CAAC,WAAW,CAAC,KAAK,EAAE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C,GAAG,EAAE,EAAE,eAAe,CAAC,CAAC;YACnE,MAAM,aAAQ,CAAC,KAAK,CAAC,cAAI,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YACvE,MAAM,aAAQ,CAAC,SAAS,CAAC,cAAI,CAAC,OAAO,CAAC,aAAa,EAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,CAAC;QAC1E,CAAC;KAAA;CACF;AAtDD,8BAsDC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.utils.js","sourceRoot":"","sources":["../../../src/pdf-engines/utils/engine.utils.ts"],"names":[],"mappings":";;;;AAAA,2BAAqE;AACrE,wDAAwB;AAIxB,MAAa,cAAc;IAClB,MAAM,CAAO,WAAW,CAAC,KAAiB,EAAE,IAAc;;YAC/D,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;
|
|
1
|
+
{"version":3,"file":"engine.utils.js","sourceRoot":"","sources":["../../../src/pdf-engines/utils/engine.utils.ts"],"names":[],"mappings":";;;;AAAA,2BAAqE;AACrE,wDAAwB;AAIxB,MAAa,cAAc;IAClB,MAAM,CAAO,WAAW,CAAC,KAAiB,EAAE,IAAc;;YAC/D,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBACzB,MAAM,aAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,cAAS,CAAC,IAAI,CAAC,CAAC;gBAC5C,MAAM,QAAQ,GAAG,cAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;gBAChD,MAAM,SAAS,GAAG,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;gBACzC,IAAI,SAAS,KAAK,MAAM,EAAE,CAAC;oBACzB,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAA,qBAAgB,EAAC,IAAI,CAAC,CAAC,CAAC;gBAChD,CAAC;qBAAM,CAAC;oBACN,MAAM,IAAI,KAAK,CAAC,GAAG,SAAS,mBAAmB,CAAC,CAAC;gBACnD,CAAC;YACH,CAAC;QACH,CAAC;KAAA;CACF;AAbD,wCAaC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chromiumly",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"description": "A lightweight Typescript library that interacts with Gotenberg's different modules to convert a variety of document formats to PDF files.",
|
|
5
5
|
"main": "dist/main.js",
|
|
6
6
|
"types": "dist/main.d.ts",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"author": "Taha Cherfia <taha.cherfia@gmail.com>",
|
|
16
16
|
"license": "MIT",
|
|
17
17
|
"engines": {
|
|
18
|
-
"node": ">=
|
|
18
|
+
"node": ">=18.x"
|
|
19
19
|
},
|
|
20
20
|
"keywords": [
|
|
21
21
|
"gotenberg",
|
|
@@ -29,25 +29,40 @@
|
|
|
29
29
|
"clean": "rm -rf dist build",
|
|
30
30
|
"lint": "eslint src/ --ext .js,.ts",
|
|
31
31
|
"build": "yarn clean && tsc -p tsconfig.json",
|
|
32
|
-
"test": "jest --runInBand --ci --coverage --reporters=default --reporters=jest-junit"
|
|
32
|
+
"test": "jest --runInBand --ci --coverage --reporters=default --reporters=jest-junit",
|
|
33
|
+
"commit": "git-cz",
|
|
34
|
+
"release": "release-it"
|
|
35
|
+
},
|
|
36
|
+
"config": {
|
|
37
|
+
"commitizen": {
|
|
38
|
+
"path": "@commitlint/cz-commitlint"
|
|
39
|
+
}
|
|
33
40
|
},
|
|
34
41
|
"devDependencies": {
|
|
35
|
-
"@babel/preset-typescript": "7.23.
|
|
36
|
-
"@
|
|
42
|
+
"@babel/preset-typescript": "7.23.3",
|
|
43
|
+
"@commitlint/cli": "18.4.3",
|
|
44
|
+
"@commitlint/config-conventional": "18.4.3",
|
|
45
|
+
"@commitlint/cz-commitlint": "^18.4.3",
|
|
46
|
+
"@release-it/conventional-changelog": "8.0.1",
|
|
47
|
+
"@types/config": "3.3.3",
|
|
37
48
|
"@types/dotenv": "8.2.0",
|
|
38
49
|
"@types/form-data": "2.5.0",
|
|
39
|
-
"@types/jest": "29.5.
|
|
40
|
-
"@types/node": "20.
|
|
41
|
-
"@types/node-fetch": "2.6.
|
|
42
|
-
"@typescript-eslint/eslint-plugin": "6.
|
|
43
|
-
"@typescript-eslint/parser": "6.
|
|
44
|
-
"
|
|
50
|
+
"@types/jest": "29.5.10",
|
|
51
|
+
"@types/node": "20.10.2",
|
|
52
|
+
"@types/node-fetch": "2.6.9",
|
|
53
|
+
"@typescript-eslint/eslint-plugin": "6.13.1",
|
|
54
|
+
"@typescript-eslint/parser": "6.13.1",
|
|
55
|
+
"commitizen": "4.3.0",
|
|
56
|
+
"eslint": "8.55.0",
|
|
57
|
+
"husky": "8.0.3",
|
|
58
|
+
"inquirer": "8",
|
|
45
59
|
"jest": "29.7.0",
|
|
46
60
|
"jest-junit": "16.0.0",
|
|
61
|
+
"release-it": "17.0.0",
|
|
47
62
|
"ts-jest": "29.1.1",
|
|
48
63
|
"ts-node": "10.9.1",
|
|
49
64
|
"tslib": "2.6.2",
|
|
50
|
-
"typescript": "5.
|
|
65
|
+
"typescript": "5.3.2"
|
|
51
66
|
},
|
|
52
67
|
"dependencies": {
|
|
53
68
|
"config": "3.3.9",
|
|
@@ -3,7 +3,6 @@ import { constants, createReadStream, PathLike, promises } from "fs";
|
|
|
3
3
|
import FormData from "form-data";
|
|
4
4
|
|
|
5
5
|
import { GotenbergUtils, PdfFormat } from "../../common";
|
|
6
|
-
import { IConverter } from "../interfaces/converter.interface";
|
|
7
6
|
import {
|
|
8
7
|
EmulatedMediaType,
|
|
9
8
|
PageProperties,
|
|
@@ -12,7 +11,7 @@ import { ConverterUtils } from "../utils/converter.utils";
|
|
|
12
11
|
import { Converter } from "./converter";
|
|
13
12
|
import { ChromiumRoute } from "../../main.config";
|
|
14
13
|
|
|
15
|
-
export class HtmlConverter extends Converter
|
|
14
|
+
export class HtmlConverter extends Converter {
|
|
16
15
|
constructor() {
|
|
17
16
|
super(ChromiumRoute.HTML);
|
|
18
17
|
}
|
|
@@ -23,41 +22,45 @@ export class HtmlConverter extends Converter implements IConverter {
|
|
|
23
22
|
footer,
|
|
24
23
|
properties,
|
|
25
24
|
pdfFormat,
|
|
25
|
+
pdfUA,
|
|
26
26
|
emulatedMediaType,
|
|
27
|
+
waitDelay,
|
|
28
|
+
waitForExpression,
|
|
29
|
+
userAgent,
|
|
30
|
+
extraHttpHeaders,
|
|
31
|
+
failOnConsoleExceptions,
|
|
27
32
|
}: {
|
|
28
33
|
html: PathLike;
|
|
29
34
|
header?: PathLike;
|
|
30
35
|
footer?: PathLike;
|
|
31
36
|
properties?: PageProperties;
|
|
32
37
|
pdfFormat?: PdfFormat;
|
|
38
|
+
pdfUA?: boolean;
|
|
33
39
|
emulatedMediaType?: EmulatedMediaType;
|
|
40
|
+
waitDelay?: string;
|
|
41
|
+
waitForExpression?: string;
|
|
42
|
+
userAgent?: string;
|
|
43
|
+
extraHttpHeaders?: Record<string, string>;
|
|
44
|
+
failOnConsoleExceptions?: boolean;
|
|
34
45
|
}): Promise<Buffer> {
|
|
35
46
|
await promises.access(html, constants.R_OK);
|
|
36
47
|
const data = new FormData();
|
|
37
48
|
|
|
38
|
-
if (pdfFormat) {
|
|
39
|
-
data.append("pdfFormat", pdfFormat);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
49
|
data.append("index.html", createReadStream(html));
|
|
43
50
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (properties) {
|
|
59
|
-
ConverterUtils.injectPageProperties(data, properties);
|
|
60
|
-
}
|
|
51
|
+
ConverterUtils.customize(data, {
|
|
52
|
+
header,
|
|
53
|
+
footer,
|
|
54
|
+
properties,
|
|
55
|
+
pdfFormat,
|
|
56
|
+
pdfUA,
|
|
57
|
+
emulatedMediaType,
|
|
58
|
+
waitDelay,
|
|
59
|
+
waitForExpression,
|
|
60
|
+
userAgent,
|
|
61
|
+
extraHttpHeaders,
|
|
62
|
+
failOnConsoleExceptions,
|
|
63
|
+
});
|
|
61
64
|
|
|
62
65
|
return GotenbergUtils.fetch(this.endpoint, data);
|
|
63
66
|
}
|