@ironsoftware/ironpdf 2026.5.1 → 2026.6.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/package.json +2 -2
- package/src/index.d.ts +1 -0
- package/src/index.d.ts.map +1 -1
- package/src/index.js +1 -0
- package/src/index.js.map +1 -1
- package/src/index.ts +1 -0
- package/src/internal/IronPdfEngine.ProtoFiles/iron_pdf_service.proto +5 -0
- package/src/internal/IronPdfEngine.ProtoFiles/pdfium_compress.proto +1 -0
- package/src/internal/IronPdfEngine.ProtoFiles/pdfium_form.proto +32 -0
- package/src/internal/IronPdfEngine.ProtoFiles/qpdf.proto +35 -0
- package/src/internal/access.d.ts.map +1 -1
- package/src/internal/access.js +3 -0
- package/src/internal/access.js.map +1 -1
- package/src/internal/access.ts +4 -0
- package/src/internal/generated_proto/iron_pdf_service.d.ts +14 -0
- package/src/internal/generated_proto/iron_pdf_service.d.ts.map +1 -1
- package/src/internal/generated_proto/iron_pdf_service.ts +14 -0
- package/src/internal/generated_proto/ironpdfengineproto/IronPdfService.d.ts +38 -0
- package/src/internal/generated_proto/ironpdfengineproto/IronPdfService.d.ts.map +1 -1
- package/src/internal/generated_proto/ironpdfengineproto/IronPdfService.ts +46 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumCompressImagesRequestP.d.ts +2 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumCompressImagesRequestP.d.ts.map +1 -1
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumCompressImagesRequestP.ts +2 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumDisableFormFontFallbackRequestP.d.ts +8 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumDisableFormFontFallbackRequestP.d.ts.map +1 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumDisableFormFontFallbackRequestP.js +4 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumDisableFormFontFallbackRequestP.js.map +1 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumDisableFormFontFallbackRequestP.ts +11 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumDisableFormFontFallbackResultP.d.ts +12 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumDisableFormFontFallbackResultP.d.ts.map +1 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumDisableFormFontFallbackResultP.js +4 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumDisableFormFontFallbackResultP.js.map +1 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumDisableFormFontFallbackResultP.ts +15 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumSetFormFontRequestStreamP.d.ts +25 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumSetFormFontRequestStreamP.d.ts.map +1 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumSetFormFontRequestStreamP.js +4 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumSetFormFontRequestStreamP.js.map +1 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumSetFormFontRequestStreamP.ts +28 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumSetFormFontResultP.d.ts +12 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumSetFormFontResultP.d.ts.map +1 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumSetFormFontResultP.js +4 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumSetFormFontResultP.js.map +1 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumSetFormFontResultP.ts +15 -0
- package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressAndSaveAsAdvancedFromBytesRequestStreamP.d.ts +23 -0
- package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressAndSaveAsAdvancedFromBytesRequestStreamP.d.ts.map +1 -0
- package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressAndSaveAsAdvancedFromBytesRequestStreamP.js +4 -0
- package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressAndSaveAsAdvancedFromBytesRequestStreamP.js.map +1 -0
- package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressAndSaveAsAdvancedFromBytesRequestStreamP.ts +26 -0
- package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressAndSaveAsAdvancedRequestP.d.ts +15 -0
- package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressAndSaveAsAdvancedRequestP.d.ts.map +1 -0
- package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressAndSaveAsAdvancedRequestP.js +4 -0
- package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressAndSaveAsAdvancedRequestP.js.map +1 -0
- package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressAndSaveAsAdvancedRequestP.ts +18 -0
- package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressionFlagsP.d.ts +30 -0
- package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressionFlagsP.d.ts.map +1 -0
- package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressionFlagsP.js +4 -0
- package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressionFlagsP.js.map +1 -0
- package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressionFlagsP.ts +33 -0
- package/src/internal/grpc_layer/pdfium/compress.d.ts +28 -0
- package/src/internal/grpc_layer/pdfium/compress.d.ts.map +1 -1
- package/src/internal/grpc_layer/pdfium/compress.js +154 -3
- package/src/internal/grpc_layer/pdfium/compress.js.map +1 -1
- package/src/internal/grpc_layer/pdfium/compress.ts +191 -1
- package/src/internal/grpc_layer/pdfium/form.d.ts +15 -0
- package/src/internal/grpc_layer/pdfium/form.d.ts.map +1 -0
- package/src/internal/grpc_layer/pdfium/form.js +99 -0
- package/src/internal/grpc_layer/pdfium/form.js.map +1 -0
- package/src/internal/grpc_layer/pdfium/form.ts +119 -0
- package/src/internal/grpc_layer/pdfium/formFontValidator.d.ts +26 -0
- package/src/internal/grpc_layer/pdfium/formFontValidator.d.ts.map +1 -0
- package/src/internal/grpc_layer/pdfium/formFontValidator.js +81 -0
- package/src/internal/grpc_layer/pdfium/formFontValidator.js.map +1 -0
- package/src/internal/grpc_layer/pdfium/formFontValidator.ts +86 -0
- package/src/public/compression.d.ts +92 -0
- package/src/public/compression.d.ts.map +1 -0
- package/src/public/compression.js +26 -0
- package/src/public/compression.js.map +1 -0
- package/src/public/compression.ts +107 -0
- package/src/public/ironpdfglobalconfig.d.ts +12 -0
- package/src/public/ironpdfglobalconfig.d.ts.map +1 -1
- package/src/public/ironpdfglobalconfig.js +7 -0
- package/src/public/ironpdfglobalconfig.js.map +1 -1
- package/src/public/ironpdfglobalconfig.ts +19 -0
- package/src/public/pdfDocument.d.ts +66 -0
- package/src/public/pdfDocument.d.ts.map +1 -1
- package/src/public/pdfDocument.js +148 -0
- package/src/public/pdfDocument.js.map +1 -1
- package/src/public/pdfDocument.ts +154 -1
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import * as grpc from "@grpc/grpc-js";
|
|
2
|
+
import {Buffer} from "buffer";
|
|
3
|
+
import {Access} from "../../access";
|
|
4
|
+
import {IronPdfServiceClient} from "../../generated_proto/ironpdfengineproto/IronPdfService";
|
|
5
|
+
import {
|
|
6
|
+
PdfiumSetFormFontRequestStreamP
|
|
7
|
+
} from "../../generated_proto/ironpdfengineproto/PdfiumSetFormFontRequestStreamP";
|
|
8
|
+
import {
|
|
9
|
+
PdfiumSetFormFontResultP__Output
|
|
10
|
+
} from "../../generated_proto/ironpdfengineproto/PdfiumSetFormFontResultP";
|
|
11
|
+
import {
|
|
12
|
+
PdfiumDisableFormFontFallbackResultP__Output
|
|
13
|
+
} from "../../generated_proto/ironpdfengineproto/PdfiumDisableFormFontFallbackResultP";
|
|
14
|
+
import {chunkBuffer, handleRemoteException} from "../util";
|
|
15
|
+
import {validateFormFontData, validateFormFontName} from "./formFontValidator";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Stream a font (or just a name reference) to the engine so subsequent
|
|
19
|
+
* form-field fills with non-ASCII values use the supplied font instead of
|
|
20
|
+
* triggering the automatic Tahoma/Arial fallback embed.
|
|
21
|
+
*/
|
|
22
|
+
export async function setFormFont(
|
|
23
|
+
id: string,
|
|
24
|
+
fontName: string,
|
|
25
|
+
fontData: Buffer | undefined,
|
|
26
|
+
forceEmbed: boolean
|
|
27
|
+
): Promise<void> {
|
|
28
|
+
validateFormFontName(fontName);
|
|
29
|
+
// Distinguish between "name-only mode" (caller passed undefined/null) and
|
|
30
|
+
// "caller passed bytes". An explicit Buffer — even an empty one — runs the
|
|
31
|
+
// data validator, which rejects empty/oversize/non-sfnt payloads. Mirrors
|
|
32
|
+
// .NET FormFontValidator behaviour where an empty byte[] is a caller error.
|
|
33
|
+
if (fontData !== undefined && fontData !== null) {
|
|
34
|
+
validateFormFontData(fontData);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const client: IronPdfServiceClient = await Access.ensureConnection();
|
|
38
|
+
|
|
39
|
+
return new Promise(
|
|
40
|
+
(resolve: () => void, reject: (errorMsg: string) => void) => {
|
|
41
|
+
let resolved = false;
|
|
42
|
+
const stream: grpc.ClientWritableStream<PdfiumSetFormFontRequestStreamP> =
|
|
43
|
+
client.Pdfium_Form_SetFormFont(
|
|
44
|
+
(
|
|
45
|
+
err: grpc.ServiceError | null,
|
|
46
|
+
value: PdfiumSetFormFontResultP__Output | undefined
|
|
47
|
+
) => {
|
|
48
|
+
if (resolved) return;
|
|
49
|
+
resolved = true;
|
|
50
|
+
if (err) {
|
|
51
|
+
reject(`${err.name}/n${err.message}`);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (!value) {
|
|
55
|
+
reject("No response from IronPdfEngine for setFormFont");
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (value.exception) {
|
|
59
|
+
handleRemoteException(value.exception, reject);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
resolve();
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
// Send Info first.
|
|
67
|
+
stream.write({
|
|
68
|
+
info: {
|
|
69
|
+
document: {documentId: id},
|
|
70
|
+
fontName: fontName,
|
|
71
|
+
fontBytesSize: fontData ? fontData.length : 0,
|
|
72
|
+
forceEmbed: forceEmbed,
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// Stream bytes (if any).
|
|
77
|
+
if (fontData && fontData.length > 0) {
|
|
78
|
+
for (const chunk of chunkBuffer(fontData)) {
|
|
79
|
+
stream.write({fontBytesChunk: chunk});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
stream.end();
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Suppress the engine's automatic Tahoma/Arial fallback embed for non-ASCII
|
|
89
|
+
* form-field values without registering a replacement font.
|
|
90
|
+
*/
|
|
91
|
+
export async function disableFormFontFallback(id: string): Promise<void> {
|
|
92
|
+
const client: IronPdfServiceClient = await Access.ensureConnection();
|
|
93
|
+
|
|
94
|
+
return new Promise(
|
|
95
|
+
(resolve: () => void, reject: (errorMsg: string) => void) => {
|
|
96
|
+
client.Pdfium_Form_DisableFormFontFallback(
|
|
97
|
+
{document: {documentId: id}},
|
|
98
|
+
(
|
|
99
|
+
err: grpc.ServiceError | null,
|
|
100
|
+
value: PdfiumDisableFormFontFallbackResultP__Output | undefined
|
|
101
|
+
) => {
|
|
102
|
+
if (err) {
|
|
103
|
+
reject(`${err.name}/n${err.message}`);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (!value) {
|
|
107
|
+
reject("No response from IronPdfEngine for disableFormFontFallback");
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (value.exception) {
|
|
111
|
+
handleRemoteException(value.exception, reject);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
resolve();
|
|
115
|
+
}
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
);
|
|
119
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client-side validation for {@link setFormFont} arguments. Mirrors the
|
|
3
|
+
* Java FormFontValidator and .NET FormFontValidator added for PDF-2184.
|
|
4
|
+
*
|
|
5
|
+
* The engine validates again on receipt — this client check is the
|
|
6
|
+
* fail-fast layer that surfaces obvious mistakes before any network I/O.
|
|
7
|
+
*/
|
|
8
|
+
/// <reference types="node" />
|
|
9
|
+
/// <reference types="node" />
|
|
10
|
+
/**
|
|
11
|
+
* Validate a PDF font name. Allowed characters: letters, digits, '_', '-',
|
|
12
|
+
* '.', '+'. The '+' is permitted to accept subset prefixes like
|
|
13
|
+
* "AAAAAA+Poppins-Regular". Names must be 1-63 characters.
|
|
14
|
+
*
|
|
15
|
+
* @throws Error when the name fails validation.
|
|
16
|
+
*/
|
|
17
|
+
export declare function validateFormFontName(fontName: string): void;
|
|
18
|
+
/**
|
|
19
|
+
* Validate raw font bytes look like a TrueType / OpenType / TTC sfnt
|
|
20
|
+
* container. Catches the obvious cases: empty payload, oversize payload,
|
|
21
|
+
* ASCII text passed instead of bytes, and all-zero payloads.
|
|
22
|
+
*
|
|
23
|
+
* @throws Error when the data fails validation.
|
|
24
|
+
*/
|
|
25
|
+
export declare function validateFormFontData(fontData: Buffer): void;
|
|
26
|
+
//# sourceMappingURL=formFontValidator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formFontValidator.d.ts","sourceRoot":"","sources":["formFontValidator.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;;;AAMH;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAc3D;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CA2C3D"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Client-side validation for {@link setFormFont} arguments. Mirrors the
|
|
4
|
+
* Java FormFontValidator and .NET FormFontValidator added for PDF-2184.
|
|
5
|
+
*
|
|
6
|
+
* The engine validates again on receipt — this client check is the
|
|
7
|
+
* fail-fast layer that surfaces obvious mistakes before any network I/O.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.validateFormFontData = exports.validateFormFontName = void 0;
|
|
11
|
+
const MAX_NAME_LENGTH = 63;
|
|
12
|
+
const MAX_FONT_BYTES = 50 * 1024 * 1024; // 50 MB
|
|
13
|
+
const ALLOWED_NAME = /^[A-Za-z0-9_\-.+]+$/;
|
|
14
|
+
/**
|
|
15
|
+
* Validate a PDF font name. Allowed characters: letters, digits, '_', '-',
|
|
16
|
+
* '.', '+'. The '+' is permitted to accept subset prefixes like
|
|
17
|
+
* "AAAAAA+Poppins-Regular". Names must be 1-63 characters.
|
|
18
|
+
*
|
|
19
|
+
* @throws Error when the name fails validation.
|
|
20
|
+
*/
|
|
21
|
+
function validateFormFontName(fontName) {
|
|
22
|
+
if (fontName == null || typeof fontName !== "string" || fontName.length === 0) {
|
|
23
|
+
throw new Error("fontName must be a non-empty string");
|
|
24
|
+
}
|
|
25
|
+
if (fontName.length > MAX_NAME_LENGTH) {
|
|
26
|
+
throw new Error(`fontName must be at most ${MAX_NAME_LENGTH} characters (got ${fontName.length})`);
|
|
27
|
+
}
|
|
28
|
+
if (!ALLOWED_NAME.test(fontName)) {
|
|
29
|
+
throw new Error("fontName may only contain letters, digits, and the characters '_', '-', '.', '+'");
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.validateFormFontName = validateFormFontName;
|
|
33
|
+
/**
|
|
34
|
+
* Validate raw font bytes look like a TrueType / OpenType / TTC sfnt
|
|
35
|
+
* container. Catches the obvious cases: empty payload, oversize payload,
|
|
36
|
+
* ASCII text passed instead of bytes, and all-zero payloads.
|
|
37
|
+
*
|
|
38
|
+
* @throws Error when the data fails validation.
|
|
39
|
+
*/
|
|
40
|
+
function validateFormFontData(fontData) {
|
|
41
|
+
var _a;
|
|
42
|
+
if (!fontData || fontData.length === 0) {
|
|
43
|
+
throw new Error("fontData must not be empty");
|
|
44
|
+
}
|
|
45
|
+
if (fontData.length > MAX_FONT_BYTES) {
|
|
46
|
+
throw new Error(`fontData exceeds the ${MAX_FONT_BYTES} byte limit (got ${fontData.length})`);
|
|
47
|
+
}
|
|
48
|
+
if (fontData.length < 4) {
|
|
49
|
+
throw new Error("fontData is too small to be a valid font file");
|
|
50
|
+
}
|
|
51
|
+
// Reject obviously-non-font payloads: all-zero buffer or a pure ASCII text
|
|
52
|
+
// payload. We don't try to fully parse the sfnt header here — the engine
|
|
53
|
+
// does that — but we do catch the common mistakes.
|
|
54
|
+
let nonZero = false;
|
|
55
|
+
let asciiOnly = true;
|
|
56
|
+
for (let i = 0; i < Math.min(fontData.length, 4096); i++) {
|
|
57
|
+
const b = (_a = fontData[i]) !== null && _a !== void 0 ? _a : 0;
|
|
58
|
+
if (b !== 0)
|
|
59
|
+
nonZero = true;
|
|
60
|
+
if (b > 0x7e || (b < 0x20 && b !== 0x09 && b !== 0x0a && b !== 0x0d)) {
|
|
61
|
+
asciiOnly = false;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (!nonZero) {
|
|
65
|
+
throw new Error("fontData is all zeros — not a valid font file");
|
|
66
|
+
}
|
|
67
|
+
if (asciiOnly) {
|
|
68
|
+
throw new Error("fontData looks like ASCII text — not a valid font file");
|
|
69
|
+
}
|
|
70
|
+
// sfnt magic — TTF (0x00010000), OTF ('OTTO'), TTC ('ttcf'), or 'true'.
|
|
71
|
+
const m0 = fontData[0], m1 = fontData[1], m2 = fontData[2], m3 = fontData[3];
|
|
72
|
+
const isTtfV1 = m0 === 0x00 && m1 === 0x01 && m2 === 0x00 && m3 === 0x00;
|
|
73
|
+
const isOtto = m0 === 0x4f && m1 === 0x54 && m2 === 0x54 && m3 === 0x4f;
|
|
74
|
+
const isTtcf = m0 === 0x74 && m1 === 0x74 && m2 === 0x63 && m3 === 0x66;
|
|
75
|
+
const isTrue = m0 === 0x74 && m1 === 0x72 && m2 === 0x75 && m3 === 0x65;
|
|
76
|
+
if (!(isTtfV1 || isOtto || isTtcf || isTrue)) {
|
|
77
|
+
throw new Error("fontData does not have a recognised TTF/OTF/TTC sfnt magic");
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.validateFormFontData = validateFormFontData;
|
|
81
|
+
//# sourceMappingURL=formFontValidator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formFontValidator.js","sourceRoot":"","sources":["formFontValidator.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client-side validation for {@link setFormFont} arguments. Mirrors the
|
|
3
|
+
* Java FormFontValidator and .NET FormFontValidator added for PDF-2184.
|
|
4
|
+
*
|
|
5
|
+
* The engine validates again on receipt — this client check is the
|
|
6
|
+
* fail-fast layer that surfaces obvious mistakes before any network I/O.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const MAX_NAME_LENGTH = 63;
|
|
10
|
+
const MAX_FONT_BYTES = 50 * 1024 * 1024; // 50 MB
|
|
11
|
+
const ALLOWED_NAME = /^[A-Za-z0-9_\-.+]+$/;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Validate a PDF font name. Allowed characters: letters, digits, '_', '-',
|
|
15
|
+
* '.', '+'. The '+' is permitted to accept subset prefixes like
|
|
16
|
+
* "AAAAAA+Poppins-Regular". Names must be 1-63 characters.
|
|
17
|
+
*
|
|
18
|
+
* @throws Error when the name fails validation.
|
|
19
|
+
*/
|
|
20
|
+
export function validateFormFontName(fontName: string): void {
|
|
21
|
+
if (fontName == null || typeof fontName !== "string" || fontName.length === 0) {
|
|
22
|
+
throw new Error("fontName must be a non-empty string");
|
|
23
|
+
}
|
|
24
|
+
if (fontName.length > MAX_NAME_LENGTH) {
|
|
25
|
+
throw new Error(
|
|
26
|
+
`fontName must be at most ${MAX_NAME_LENGTH} characters (got ${fontName.length})`
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
if (!ALLOWED_NAME.test(fontName)) {
|
|
30
|
+
throw new Error(
|
|
31
|
+
"fontName may only contain letters, digits, and the characters '_', '-', '.', '+'"
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Validate raw font bytes look like a TrueType / OpenType / TTC sfnt
|
|
38
|
+
* container. Catches the obvious cases: empty payload, oversize payload,
|
|
39
|
+
* ASCII text passed instead of bytes, and all-zero payloads.
|
|
40
|
+
*
|
|
41
|
+
* @throws Error when the data fails validation.
|
|
42
|
+
*/
|
|
43
|
+
export function validateFormFontData(fontData: Buffer): void {
|
|
44
|
+
if (!fontData || fontData.length === 0) {
|
|
45
|
+
throw new Error("fontData must not be empty");
|
|
46
|
+
}
|
|
47
|
+
if (fontData.length > MAX_FONT_BYTES) {
|
|
48
|
+
throw new Error(
|
|
49
|
+
`fontData exceeds the ${MAX_FONT_BYTES} byte limit (got ${fontData.length})`
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
if (fontData.length < 4) {
|
|
53
|
+
throw new Error("fontData is too small to be a valid font file");
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Reject obviously-non-font payloads: all-zero buffer or a pure ASCII text
|
|
57
|
+
// payload. We don't try to fully parse the sfnt header here — the engine
|
|
58
|
+
// does that — but we do catch the common mistakes.
|
|
59
|
+
let nonZero = false;
|
|
60
|
+
let asciiOnly = true;
|
|
61
|
+
for (let i = 0; i < Math.min(fontData.length, 4096); i++) {
|
|
62
|
+
const b = fontData[i] ?? 0;
|
|
63
|
+
if (b !== 0) nonZero = true;
|
|
64
|
+
if (b > 0x7e || (b < 0x20 && b !== 0x09 && b !== 0x0a && b !== 0x0d)) {
|
|
65
|
+
asciiOnly = false;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (!nonZero) {
|
|
69
|
+
throw new Error("fontData is all zeros — not a valid font file");
|
|
70
|
+
}
|
|
71
|
+
if (asciiOnly) {
|
|
72
|
+
throw new Error("fontData looks like ASCII text — not a valid font file");
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// sfnt magic — TTF (0x00010000), OTF ('OTTO'), TTC ('ttcf'), or 'true'.
|
|
76
|
+
const m0 = fontData[0], m1 = fontData[1], m2 = fontData[2], m3 = fontData[3];
|
|
77
|
+
const isTtfV1 = m0 === 0x00 && m1 === 0x01 && m2 === 0x00 && m3 === 0x00;
|
|
78
|
+
const isOtto = m0 === 0x4f && m1 === 0x54 && m2 === 0x54 && m3 === 0x4f;
|
|
79
|
+
const isTtcf = m0 === 0x74 && m1 === 0x74 && m2 === 0x63 && m3 === 0x66;
|
|
80
|
+
const isTrue = m0 === 0x74 && m1 === 0x72 && m2 === 0x75 && m3 === 0x65;
|
|
81
|
+
if (!(isTtfV1 || isOtto || isTtcf || isTrue)) {
|
|
82
|
+
throw new Error(
|
|
83
|
+
"fontData does not have a recognised TTF/OTF/TTC sfnt magic"
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Object stream mode used when writing the compressed PDF.
|
|
3
|
+
*
|
|
4
|
+
* Values are the literal strings the engine expects on
|
|
5
|
+
* {@code QPdfCompressionFlagsP.object_streams}.
|
|
6
|
+
*/
|
|
7
|
+
export declare enum ObjectStreamMode {
|
|
8
|
+
/**
|
|
9
|
+
* Pack indirect objects into object streams. Smallest output for PDF 1.5+ (default).
|
|
10
|
+
*/
|
|
11
|
+
Generate = "generate",
|
|
12
|
+
/**
|
|
13
|
+
* Keep the input's object stream layout unchanged.
|
|
14
|
+
*/
|
|
15
|
+
Preserve = "preserve",
|
|
16
|
+
/**
|
|
17
|
+
* Write every object as a top-level indirect object (no object streams).
|
|
18
|
+
* Use when consumer tools cannot read object streams.
|
|
19
|
+
*/
|
|
20
|
+
Disable = "disable"
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Configuration for the advanced compression pipeline.
|
|
24
|
+
*
|
|
25
|
+
* @example Web/email (strongest size reduction)
|
|
26
|
+
* ```ts
|
|
27
|
+
* const opts: AdvancedCompressionOptions = {
|
|
28
|
+
* jpegQuality: 70,
|
|
29
|
+
* targetImageDpi: 150,
|
|
30
|
+
* removeStructureTree: true,
|
|
31
|
+
* };
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @example Print quality
|
|
35
|
+
* ```ts
|
|
36
|
+
* const opts: AdvancedCompressionOptions = {
|
|
37
|
+
* jpegQuality: 90,
|
|
38
|
+
* targetImageDpi: 300,
|
|
39
|
+
* };
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export interface AdvancedCompressionOptions {
|
|
43
|
+
/**
|
|
44
|
+
* JPEG quality used when re-encoding images during optimization (1-100).
|
|
45
|
+
* When set, automatically enables image optimization.
|
|
46
|
+
*
|
|
47
|
+
* Default: `null` (no image re-encoding).
|
|
48
|
+
*
|
|
49
|
+
* Where the re-encoding happens depends on {@link targetImageDpi}:
|
|
50
|
+
* - `targetImageDpi` set (default 150): each image is downsampled and
|
|
51
|
+
* re-encoded at this quality.
|
|
52
|
+
* - `targetImageDpi = null`: qpdf re-encodes images at this quality
|
|
53
|
+
* without changing pixel dimensions.
|
|
54
|
+
*/
|
|
55
|
+
jpegQuality?: number | null;
|
|
56
|
+
/**
|
|
57
|
+
* Target DPI for image downsampling during advanced compression.
|
|
58
|
+
* Images whose effective rendered DPI exceeds this value are
|
|
59
|
+
* downsampled before re-encoding.
|
|
60
|
+
*
|
|
61
|
+
* Default: `150`. Set to `null` (or `0`) to disable downsampling.
|
|
62
|
+
*
|
|
63
|
+
* **Lossy** — once an image is downsampled it cannot be restored to its
|
|
64
|
+
* original resolution.
|
|
65
|
+
*/
|
|
66
|
+
targetImageDpi?: number | null;
|
|
67
|
+
/** 4:4:4 chroma subsampling when true (better color), 4:1:1 when false. Default true. */
|
|
68
|
+
highQualityImageSubsampling?: boolean;
|
|
69
|
+
/** Remove the document structure tree before compression. Default false. */
|
|
70
|
+
removeStructureTree?: boolean;
|
|
71
|
+
/** Compress content streams using zlib/Flate. Default true. */
|
|
72
|
+
compressStreams?: boolean;
|
|
73
|
+
/** Re-compress already Flate-encoded streams using {@link compressionLevel}. Default true. */
|
|
74
|
+
recompressFlate?: boolean;
|
|
75
|
+
/** zlib compression level (0-9). Default 9. */
|
|
76
|
+
compressionLevel?: number;
|
|
77
|
+
/** Object stream mode used when writing the output PDF. Default {@link ObjectStreamMode.Generate}. */
|
|
78
|
+
objectStreams?: ObjectStreamMode;
|
|
79
|
+
/** Drop indirect objects that are not referenced from the catalog. Default true. */
|
|
80
|
+
removeUnreferencedResources?: boolean;
|
|
81
|
+
/** Merge a page's content streams so they Flate-compress together. Default true. */
|
|
82
|
+
coalesceContents?: boolean;
|
|
83
|
+
/** Decode generalized filters (FlateDecode, LZW, ASCII85, ASCIIHex) before re-encoding. Default true. */
|
|
84
|
+
decodeGeneralizedStreams?: boolean;
|
|
85
|
+
/** Minimum image width (pixels) for image optimization to apply. Default 0. */
|
|
86
|
+
optimizeImagesMinWidth?: number;
|
|
87
|
+
/** Minimum image height (pixels) for image optimization to apply. Default 0. */
|
|
88
|
+
optimizeImagesMinHeight?: number;
|
|
89
|
+
/** Minimum image area (width × height) for image optimization to apply. Default 0. */
|
|
90
|
+
optimizeImagesMinArea?: number;
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=compression.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compression.d.ts","sourceRoot":"","sources":["compression.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,oBAAY,gBAAgB;IAC3B;;OAEG;IACH,QAAQ,aAAa;IAErB;;OAEG;IACH,QAAQ,aAAa;IAErB;;;OAGG;IACH,OAAO,YAAY;CACnB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,0BAA0B;IAC1C;;;;;;;;;;;OAWG;IACH,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAE5B;;;;;;;;;OASG;IACH,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAE/B,yFAAyF;IACzF,2BAA2B,CAAC,EAAE,OAAO,CAAC;IAEtC,4EAA4E;IAC5E,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B,+DAA+D;IAC/D,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B,8FAA8F;IAC9F,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B,+CAA+C;IAC/C,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B,sGAAsG;IACtG,aAAa,CAAC,EAAE,gBAAgB,CAAC;IAEjC,oFAAoF;IACpF,2BAA2B,CAAC,EAAE,OAAO,CAAC;IAEtC,oFAAoF;IACpF,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B,yGAAyG;IACzG,wBAAwB,CAAC,EAAE,OAAO,CAAC;IAEnC,+EAA+E;IAC/E,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAEhC,gFAAgF;IAChF,uBAAuB,CAAC,EAAE,MAAM,CAAC;IAEjC,sFAAsF;IACtF,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAC/B"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ObjectStreamMode = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Object stream mode used when writing the compressed PDF.
|
|
6
|
+
*
|
|
7
|
+
* Values are the literal strings the engine expects on
|
|
8
|
+
* {@code QPdfCompressionFlagsP.object_streams}.
|
|
9
|
+
*/
|
|
10
|
+
var ObjectStreamMode;
|
|
11
|
+
(function (ObjectStreamMode) {
|
|
12
|
+
/**
|
|
13
|
+
* Pack indirect objects into object streams. Smallest output for PDF 1.5+ (default).
|
|
14
|
+
*/
|
|
15
|
+
ObjectStreamMode["Generate"] = "generate";
|
|
16
|
+
/**
|
|
17
|
+
* Keep the input's object stream layout unchanged.
|
|
18
|
+
*/
|
|
19
|
+
ObjectStreamMode["Preserve"] = "preserve";
|
|
20
|
+
/**
|
|
21
|
+
* Write every object as a top-level indirect object (no object streams).
|
|
22
|
+
* Use when consumer tools cannot read object streams.
|
|
23
|
+
*/
|
|
24
|
+
ObjectStreamMode["Disable"] = "disable";
|
|
25
|
+
})(ObjectStreamMode = exports.ObjectStreamMode || (exports.ObjectStreamMode = {}));
|
|
26
|
+
//# sourceMappingURL=compression.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compression.js","sourceRoot":"","sources":["compression.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,IAAY,gBAgBX;AAhBD,WAAY,gBAAgB;IAC3B;;OAEG;IACH,yCAAqB,CAAA;IAErB;;OAEG;IACH,yCAAqB,CAAA;IAErB;;;OAGG;IACH,uCAAmB,CAAA;AACpB,CAAC,EAhBW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAgB3B"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Object stream mode used when writing the compressed PDF.
|
|
3
|
+
*
|
|
4
|
+
* Values are the literal strings the engine expects on
|
|
5
|
+
* {@code QPdfCompressionFlagsP.object_streams}.
|
|
6
|
+
*/
|
|
7
|
+
export enum ObjectStreamMode {
|
|
8
|
+
/**
|
|
9
|
+
* Pack indirect objects into object streams. Smallest output for PDF 1.5+ (default).
|
|
10
|
+
*/
|
|
11
|
+
Generate = "generate",
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Keep the input's object stream layout unchanged.
|
|
15
|
+
*/
|
|
16
|
+
Preserve = "preserve",
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Write every object as a top-level indirect object (no object streams).
|
|
20
|
+
* Use when consumer tools cannot read object streams.
|
|
21
|
+
*/
|
|
22
|
+
Disable = "disable",
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Configuration for the advanced compression pipeline.
|
|
27
|
+
*
|
|
28
|
+
* @example Web/email (strongest size reduction)
|
|
29
|
+
* ```ts
|
|
30
|
+
* const opts: AdvancedCompressionOptions = {
|
|
31
|
+
* jpegQuality: 70,
|
|
32
|
+
* targetImageDpi: 150,
|
|
33
|
+
* removeStructureTree: true,
|
|
34
|
+
* };
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @example Print quality
|
|
38
|
+
* ```ts
|
|
39
|
+
* const opts: AdvancedCompressionOptions = {
|
|
40
|
+
* jpegQuality: 90,
|
|
41
|
+
* targetImageDpi: 300,
|
|
42
|
+
* };
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export interface AdvancedCompressionOptions {
|
|
46
|
+
/**
|
|
47
|
+
* JPEG quality used when re-encoding images during optimization (1-100).
|
|
48
|
+
* When set, automatically enables image optimization.
|
|
49
|
+
*
|
|
50
|
+
* Default: `null` (no image re-encoding).
|
|
51
|
+
*
|
|
52
|
+
* Where the re-encoding happens depends on {@link targetImageDpi}:
|
|
53
|
+
* - `targetImageDpi` set (default 150): each image is downsampled and
|
|
54
|
+
* re-encoded at this quality.
|
|
55
|
+
* - `targetImageDpi = null`: qpdf re-encodes images at this quality
|
|
56
|
+
* without changing pixel dimensions.
|
|
57
|
+
*/
|
|
58
|
+
jpegQuality?: number | null;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Target DPI for image downsampling during advanced compression.
|
|
62
|
+
* Images whose effective rendered DPI exceeds this value are
|
|
63
|
+
* downsampled before re-encoding.
|
|
64
|
+
*
|
|
65
|
+
* Default: `150`. Set to `null` (or `0`) to disable downsampling.
|
|
66
|
+
*
|
|
67
|
+
* **Lossy** — once an image is downsampled it cannot be restored to its
|
|
68
|
+
* original resolution.
|
|
69
|
+
*/
|
|
70
|
+
targetImageDpi?: number | null;
|
|
71
|
+
|
|
72
|
+
/** 4:4:4 chroma subsampling when true (better color), 4:1:1 when false. Default true. */
|
|
73
|
+
highQualityImageSubsampling?: boolean;
|
|
74
|
+
|
|
75
|
+
/** Remove the document structure tree before compression. Default false. */
|
|
76
|
+
removeStructureTree?: boolean;
|
|
77
|
+
|
|
78
|
+
/** Compress content streams using zlib/Flate. Default true. */
|
|
79
|
+
compressStreams?: boolean;
|
|
80
|
+
|
|
81
|
+
/** Re-compress already Flate-encoded streams using {@link compressionLevel}. Default true. */
|
|
82
|
+
recompressFlate?: boolean;
|
|
83
|
+
|
|
84
|
+
/** zlib compression level (0-9). Default 9. */
|
|
85
|
+
compressionLevel?: number;
|
|
86
|
+
|
|
87
|
+
/** Object stream mode used when writing the output PDF. Default {@link ObjectStreamMode.Generate}. */
|
|
88
|
+
objectStreams?: ObjectStreamMode;
|
|
89
|
+
|
|
90
|
+
/** Drop indirect objects that are not referenced from the catalog. Default true. */
|
|
91
|
+
removeUnreferencedResources?: boolean;
|
|
92
|
+
|
|
93
|
+
/** Merge a page's content streams so they Flate-compress together. Default true. */
|
|
94
|
+
coalesceContents?: boolean;
|
|
95
|
+
|
|
96
|
+
/** Decode generalized filters (FlateDecode, LZW, ASCII85, ASCIIHex) before re-encoding. Default true. */
|
|
97
|
+
decodeGeneralizedStreams?: boolean;
|
|
98
|
+
|
|
99
|
+
/** Minimum image width (pixels) for image optimization to apply. Default 0. */
|
|
100
|
+
optimizeImagesMinWidth?: number;
|
|
101
|
+
|
|
102
|
+
/** Minimum image height (pixels) for image optimization to apply. Default 0. */
|
|
103
|
+
optimizeImagesMinHeight?: number;
|
|
104
|
+
|
|
105
|
+
/** Minimum image area (width × height) for image optimization to apply. Default 0. */
|
|
106
|
+
optimizeImagesMinArea?: number;
|
|
107
|
+
}
|
|
@@ -91,5 +91,17 @@ export interface IronPdfConfig {
|
|
|
91
91
|
* @default true
|
|
92
92
|
*/
|
|
93
93
|
autoInstallDependency?: boolean | undefined;
|
|
94
|
+
/**
|
|
95
|
+
* Watchdog timeout (in seconds) for queued IronPdfEngine Chrome jobs. If a
|
|
96
|
+
* render does not complete within this window the queue slot is reclaimed
|
|
97
|
+
* so a single hung native call cannot wedge the engine queue under load.
|
|
98
|
+
*
|
|
99
|
+
* Forwarded to the engine subprocess
|
|
100
|
+
* via the {@code job_queue_watchdog_timeout_seconds} CLI argument; leave
|
|
101
|
+
* undefined or 0 to use the engine's built-in default.
|
|
102
|
+
*
|
|
103
|
+
* @default undefined
|
|
104
|
+
*/
|
|
105
|
+
jobQueueWatchdogTimeoutSeconds?: number | undefined;
|
|
94
106
|
}
|
|
95
107
|
//# sourceMappingURL=ironpdfglobalconfig.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ironpdfglobalconfig.d.ts","sourceRoot":"","sources":["ironpdfglobalconfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,SAAS,CAAC;AAEvC;;;;GAIG;AACH,qBAAa,mBAAmB;IAC/B,OAAO,CAAC,MAAM,CAAC,SAAS,CAAsB;IAE9C,OAAO,CAAC,MAAM,CAAC,OAAO,CAKpB;IACF,OAAO;WASO,WAAW;IAIzB;;;;OAIG;WACW,SAAS,CAAC,aAAa,EAAE,aAAa;
|
|
1
|
+
{"version":3,"file":"ironpdfglobalconfig.d.ts","sourceRoot":"","sources":["ironpdfglobalconfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,SAAS,CAAC;AAEvC;;;;GAIG;AACH,qBAAa,mBAAmB;IAC/B,OAAO,CAAC,MAAM,CAAC,SAAS,CAAsB;IAE9C,OAAO,CAAC,MAAM,CAAC,OAAO,CAKpB;IACF,OAAO;WASO,WAAW;IAIzB;;;;OAIG;WACW,SAAS,CAAC,aAAa,EAAE,aAAa;WAwBtC,SAAS,IAAI,aAAa;IAIxC,OAAc,oBAAoB,EAAE,MAAM,CAEU;CACpD;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B;;;OAGG;IACH,oBAAoB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1C;;;;;;;;OAQG;IACH,0BAA0B,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChD;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAChC;;;;;;;;;;;;;;;OAeG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACpC;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC;;;OAGG;IACH,sBAAsB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5C;;;OAGG;IACH,aAAa,CAAC,EAAC,cAAc,GAAG,SAAS,CAAC;IAC1C;;;;;;;OAOG;IACH,qBAAqB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC5C;;;;;;;;;;OAUG;IACH,8BAA8B,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACpD"}
|
|
@@ -36,6 +36,13 @@ class IronPdfGlobalConfig {
|
|
|
36
36
|
IronPdfGlobalConfig._config.ironPdfEngineDockerAddress =
|
|
37
37
|
ironPdfConfig.ironPdfEngineDockerAddress;
|
|
38
38
|
}
|
|
39
|
+
if (ironPdfConfig.jobQueueWatchdogTimeoutSeconds != undefined) {
|
|
40
|
+
if (ironPdfConfig.jobQueueWatchdogTimeoutSeconds < 0) {
|
|
41
|
+
throw new Error("jobQueueWatchdogTimeoutSeconds must be non-negative");
|
|
42
|
+
}
|
|
43
|
+
IronPdfGlobalConfig._config.jobQueueWatchdogTimeoutSeconds =
|
|
44
|
+
ironPdfConfig.jobQueueWatchdogTimeoutSeconds;
|
|
45
|
+
}
|
|
39
46
|
}
|
|
40
47
|
static getConfig() {
|
|
41
48
|
return IronPdfGlobalConfig._config;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ironpdfglobalconfig.js","sourceRoot":"","sources":["ironpdfglobalconfig.ts"],"names":[],"mappings":";;;AAEA;;;;GAIG;AACH,MAAa,mBAAmB;IAS/B;QACC,IAAI,mBAAmB,CAAC,SAAS,EAAE;YAClC,MAAM,IAAI,KAAK,CACd,uEAAuE,CACvE,CAAC;SACF;QACD,mBAAmB,CAAC,SAAS,GAAG,IAAI,CAAC;IACtC,CAAC;IAEM,MAAM,CAAC,WAAW;QACxB,OAAO,mBAAmB,CAAC,SAAS,IAAI,CAAC,mBAAmB,CAAC,SAAS,GAAG,IAAI,mBAAmB,EAAE,CAAC,CAAC;IACrG,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,SAAS,CAAC,aAA4B;QACnD,IAAI,aAAa,CAAC,SAAS,IAAI,SAAS,EAAE;YACzC,mBAAmB,CAAC,OAAO,CAAC,SAAS,GAAG,aAAa,CAAC,SAAS,CAAC;SAChE;QACD,IAAI,aAAa,CAAC,UAAU,EAAE;YAC7B,mBAAmB,CAAC,OAAO,CAAC,UAAU,GAAG,aAAa,CAAC,UAAU,CAAC;SAClE;QACD,IAAI,aAAa,CAAC,oBAAoB,EAAE;YACvC,mBAAmB,CAAC,OAAO,CAAC,oBAAoB;gBAC/C,aAAa,CAAC,oBAAoB,CAAC;SACpC;QACD,IAAI,aAAa,CAAC,0BAA0B,EAAE;YAC7C,mBAAmB,CAAC,OAAO,CAAC,0BAA0B;gBACrD,aAAa,CAAC,0BAA0B,CAAC;SAC1C;IACF,CAAC;IAEM,MAAM,CAAC,SAAS;QACtB,OAAO,mBAAmB,CAAC,OAAO,CAAC;IACpC,CAAC;;
|
|
1
|
+
{"version":3,"file":"ironpdfglobalconfig.js","sourceRoot":"","sources":["ironpdfglobalconfig.ts"],"names":[],"mappings":";;;AAEA;;;;GAIG;AACH,MAAa,mBAAmB;IAS/B;QACC,IAAI,mBAAmB,CAAC,SAAS,EAAE;YAClC,MAAM,IAAI,KAAK,CACd,uEAAuE,CACvE,CAAC;SACF;QACD,mBAAmB,CAAC,SAAS,GAAG,IAAI,CAAC;IACtC,CAAC;IAEM,MAAM,CAAC,WAAW;QACxB,OAAO,mBAAmB,CAAC,SAAS,IAAI,CAAC,mBAAmB,CAAC,SAAS,GAAG,IAAI,mBAAmB,EAAE,CAAC,CAAC;IACrG,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,SAAS,CAAC,aAA4B;QACnD,IAAI,aAAa,CAAC,SAAS,IAAI,SAAS,EAAE;YACzC,mBAAmB,CAAC,OAAO,CAAC,SAAS,GAAG,aAAa,CAAC,SAAS,CAAC;SAChE;QACD,IAAI,aAAa,CAAC,UAAU,EAAE;YAC7B,mBAAmB,CAAC,OAAO,CAAC,UAAU,GAAG,aAAa,CAAC,UAAU,CAAC;SAClE;QACD,IAAI,aAAa,CAAC,oBAAoB,EAAE;YACvC,mBAAmB,CAAC,OAAO,CAAC,oBAAoB;gBAC/C,aAAa,CAAC,oBAAoB,CAAC;SACpC;QACD,IAAI,aAAa,CAAC,0BAA0B,EAAE;YAC7C,mBAAmB,CAAC,OAAO,CAAC,0BAA0B;gBACrD,aAAa,CAAC,0BAA0B,CAAC;SAC1C;QACD,IAAI,aAAa,CAAC,8BAA8B,IAAI,SAAS,EAAE;YAC9D,IAAI,aAAa,CAAC,8BAA8B,GAAG,CAAC,EAAE;gBACrD,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;aACvE;YACD,mBAAmB,CAAC,OAAO,CAAC,8BAA8B;gBACzD,aAAa,CAAC,8BAA8B,CAAC;SAC9C;IACF,CAAC;IAEM,MAAM,CAAC,SAAS;QACtB,OAAO,mBAAmB,CAAC,OAAO,CAAC;IACpC,CAAC;;AArDF,kDA0DC;AAvDe,2BAAO,GAAkB;IACvC,oBAAoB,EAAE,iBAAiB;IACvC,0BAA0B,EAAE,SAAS;IACrC,SAAS,EAAE,KAAK;IAChB,UAAU,EAAE,SAAS;CACrB,CAAC;AA+CY,wCAAoB;AACjC,8DAA8D;AAC9D,OAAO,CAAC,oBAAoB,CAAC,CAAC,oBAAoB,CAAC"}
|
|
@@ -47,6 +47,13 @@ export class IronPdfGlobalConfig {
|
|
|
47
47
|
IronPdfGlobalConfig._config.ironPdfEngineDockerAddress =
|
|
48
48
|
ironPdfConfig.ironPdfEngineDockerAddress;
|
|
49
49
|
}
|
|
50
|
+
if (ironPdfConfig.jobQueueWatchdogTimeoutSeconds != undefined) {
|
|
51
|
+
if (ironPdfConfig.jobQueueWatchdogTimeoutSeconds < 0) {
|
|
52
|
+
throw new Error("jobQueueWatchdogTimeoutSeconds must be non-negative");
|
|
53
|
+
}
|
|
54
|
+
IronPdfGlobalConfig._config.jobQueueWatchdogTimeoutSeconds =
|
|
55
|
+
ironPdfConfig.jobQueueWatchdogTimeoutSeconds;
|
|
56
|
+
}
|
|
50
57
|
}
|
|
51
58
|
|
|
52
59
|
public static getConfig(): IronPdfConfig {
|
|
@@ -131,4 +138,16 @@ export interface IronPdfConfig {
|
|
|
131
138
|
* @default true
|
|
132
139
|
*/
|
|
133
140
|
autoInstallDependency?: boolean | undefined;
|
|
141
|
+
/**
|
|
142
|
+
* Watchdog timeout (in seconds) for queued IronPdfEngine Chrome jobs. If a
|
|
143
|
+
* render does not complete within this window the queue slot is reclaimed
|
|
144
|
+
* so a single hung native call cannot wedge the engine queue under load.
|
|
145
|
+
*
|
|
146
|
+
* Forwarded to the engine subprocess
|
|
147
|
+
* via the {@code job_queue_watchdog_timeout_seconds} CLI argument; leave
|
|
148
|
+
* undefined or 0 to use the engine's built-in default.
|
|
149
|
+
*
|
|
150
|
+
* @default undefined
|
|
151
|
+
*/
|
|
152
|
+
jobQueueWatchdogTimeoutSeconds?: number | undefined;
|
|
134
153
|
}
|