@ironsoftware/ironpdf 2026.4.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.
Files changed (141) hide show
  1. package/package.json +3 -3
  2. package/src/index.d.ts +3 -0
  3. package/src/index.d.ts.map +1 -1
  4. package/src/index.js +3 -0
  5. package/src/index.js.map +1 -1
  6. package/src/index.ts +3 -0
  7. package/src/internal/IronPdfEngine.ProtoFiles/chrome_render.proto +6 -0
  8. package/src/internal/IronPdfEngine.ProtoFiles/iron_pdf_service.proto +7 -1
  9. package/src/internal/IronPdfEngine.ProtoFiles/pdfium_compress.proto +1 -0
  10. package/src/internal/IronPdfEngine.ProtoFiles/pdfium_form.proto +32 -0
  11. package/src/internal/IronPdfEngine.ProtoFiles/qpdf.proto +51 -0
  12. package/src/internal/access.d.ts.map +1 -1
  13. package/src/internal/access.js +3 -0
  14. package/src/internal/access.js.map +1 -1
  15. package/src/internal/access.ts +4 -0
  16. package/src/internal/generated_proto/iron_pdf_service.d.ts +628 -305
  17. package/src/internal/generated_proto/iron_pdf_service.d.ts.map +1 -1
  18. package/src/internal/generated_proto/iron_pdf_service.ts +628 -305
  19. package/src/internal/generated_proto/ironpdfengineproto/ChromePdfRenderOptionsP.d.ts +15 -0
  20. package/src/internal/generated_proto/ironpdfengineproto/ChromePdfRenderOptionsP.d.ts.map +1 -1
  21. package/src/internal/generated_proto/ironpdfengineproto/ChromePdfRenderOptionsP.ts +15 -0
  22. package/src/internal/generated_proto/ironpdfengineproto/IronPdfService.d.ts +52 -0
  23. package/src/internal/generated_proto/ironpdfengineproto/IronPdfService.d.ts.map +1 -1
  24. package/src/internal/generated_proto/ironpdfengineproto/IronPdfService.ts +64 -0
  25. package/src/internal/generated_proto/ironpdfengineproto/PdfiumCompressImagesRequestP.d.ts +2 -0
  26. package/src/internal/generated_proto/ironpdfengineproto/PdfiumCompressImagesRequestP.d.ts.map +1 -1
  27. package/src/internal/generated_proto/ironpdfengineproto/PdfiumCompressImagesRequestP.ts +2 -0
  28. package/src/internal/generated_proto/ironpdfengineproto/PdfiumDisableFormFontFallbackRequestP.d.ts +8 -0
  29. package/src/internal/generated_proto/ironpdfengineproto/PdfiumDisableFormFontFallbackRequestP.d.ts.map +1 -0
  30. package/src/internal/generated_proto/ironpdfengineproto/PdfiumDisableFormFontFallbackRequestP.js +4 -0
  31. package/src/internal/generated_proto/ironpdfengineproto/PdfiumDisableFormFontFallbackRequestP.js.map +1 -0
  32. package/src/internal/generated_proto/ironpdfengineproto/PdfiumDisableFormFontFallbackRequestP.ts +11 -0
  33. package/src/internal/generated_proto/ironpdfengineproto/PdfiumDisableFormFontFallbackResultP.d.ts +12 -0
  34. package/src/internal/generated_proto/ironpdfengineproto/PdfiumDisableFormFontFallbackResultP.d.ts.map +1 -0
  35. package/src/internal/generated_proto/ironpdfengineproto/PdfiumDisableFormFontFallbackResultP.js +4 -0
  36. package/src/internal/generated_proto/ironpdfengineproto/PdfiumDisableFormFontFallbackResultP.js.map +1 -0
  37. package/src/internal/generated_proto/ironpdfengineproto/PdfiumDisableFormFontFallbackResultP.ts +15 -0
  38. package/src/internal/generated_proto/ironpdfengineproto/PdfiumSetFormFontRequestStreamP.d.ts +25 -0
  39. package/src/internal/generated_proto/ironpdfengineproto/PdfiumSetFormFontRequestStreamP.d.ts.map +1 -0
  40. package/src/internal/generated_proto/ironpdfengineproto/PdfiumSetFormFontRequestStreamP.js +4 -0
  41. package/src/internal/generated_proto/ironpdfengineproto/PdfiumSetFormFontRequestStreamP.js.map +1 -0
  42. package/src/internal/generated_proto/ironpdfengineproto/PdfiumSetFormFontRequestStreamP.ts +28 -0
  43. package/src/internal/generated_proto/ironpdfengineproto/PdfiumSetFormFontResultP.d.ts +12 -0
  44. package/src/internal/generated_proto/ironpdfengineproto/PdfiumSetFormFontResultP.d.ts.map +1 -0
  45. package/src/internal/generated_proto/ironpdfengineproto/PdfiumSetFormFontResultP.js +4 -0
  46. package/src/internal/generated_proto/ironpdfengineproto/PdfiumSetFormFontResultP.js.map +1 -0
  47. package/src/internal/generated_proto/ironpdfengineproto/PdfiumSetFormFontResultP.ts +15 -0
  48. package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressAndSaveAsAdvancedFromBytesRequestStreamP.d.ts +23 -0
  49. package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressAndSaveAsAdvancedFromBytesRequestStreamP.d.ts.map +1 -0
  50. package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressAndSaveAsAdvancedFromBytesRequestStreamP.js +4 -0
  51. package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressAndSaveAsAdvancedFromBytesRequestStreamP.js.map +1 -0
  52. package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressAndSaveAsAdvancedFromBytesRequestStreamP.ts +26 -0
  53. package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressAndSaveAsAdvancedRequestP.d.ts +15 -0
  54. package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressAndSaveAsAdvancedRequestP.d.ts.map +1 -0
  55. package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressAndSaveAsAdvancedRequestP.js +4 -0
  56. package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressAndSaveAsAdvancedRequestP.js.map +1 -0
  57. package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressAndSaveAsAdvancedRequestP.ts +18 -0
  58. package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressionFlagsP.d.ts +30 -0
  59. package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressionFlagsP.d.ts.map +1 -0
  60. package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressionFlagsP.js +4 -0
  61. package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressionFlagsP.js.map +1 -0
  62. package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressionFlagsP.ts +33 -0
  63. package/src/internal/generated_proto/ironpdfengineproto/QPdfLinearizeInMemoryRequestIdP.d.ts +10 -0
  64. package/src/internal/generated_proto/ironpdfengineproto/QPdfLinearizeInMemoryRequestIdP.d.ts.map +1 -0
  65. package/src/internal/generated_proto/ironpdfengineproto/QPdfLinearizeInMemoryRequestIdP.js +4 -0
  66. package/src/internal/generated_proto/ironpdfengineproto/QPdfLinearizeInMemoryRequestIdP.js.map +1 -0
  67. package/src/internal/generated_proto/ironpdfengineproto/QPdfLinearizeInMemoryRequestIdP.ts +13 -0
  68. package/src/internal/generated_proto/ironpdfengineproto/QPdfLinearizeInMemoryRequestStreamP.d.ts +18 -0
  69. package/src/internal/generated_proto/ironpdfengineproto/QPdfLinearizeInMemoryRequestStreamP.d.ts.map +1 -0
  70. package/src/internal/generated_proto/ironpdfengineproto/QPdfLinearizeInMemoryRequestStreamP.js +4 -0
  71. package/src/internal/generated_proto/ironpdfengineproto/QPdfLinearizeInMemoryRequestStreamP.js.map +1 -0
  72. package/src/internal/generated_proto/ironpdfengineproto/QPdfLinearizeInMemoryRequestStreamP.ts +21 -0
  73. package/src/internal/grpc_layer/chrome/converter.d.ts +10 -0
  74. package/src/internal/grpc_layer/chrome/converter.d.ts.map +1 -1
  75. package/src/internal/grpc_layer/chrome/converter.js +61 -2
  76. package/src/internal/grpc_layer/chrome/converter.js.map +1 -1
  77. package/src/internal/grpc_layer/chrome/converter.ts +67 -0
  78. package/src/internal/grpc_layer/pdfium/annotations.d.ts +30 -0
  79. package/src/internal/grpc_layer/pdfium/annotations.d.ts.map +1 -0
  80. package/src/internal/grpc_layer/pdfium/annotations.js +161 -0
  81. package/src/internal/grpc_layer/pdfium/annotations.js.map +1 -0
  82. package/src/internal/grpc_layer/pdfium/annotations.ts +190 -0
  83. package/src/internal/grpc_layer/pdfium/bookmarks.d.ts +7 -0
  84. package/src/internal/grpc_layer/pdfium/bookmarks.d.ts.map +1 -0
  85. package/src/internal/grpc_layer/pdfium/bookmarks.js +53 -0
  86. package/src/internal/grpc_layer/pdfium/bookmarks.js.map +1 -0
  87. package/src/internal/grpc_layer/pdfium/bookmarks.ts +50 -0
  88. package/src/internal/grpc_layer/pdfium/compress.d.ts +28 -0
  89. package/src/internal/grpc_layer/pdfium/compress.d.ts.map +1 -1
  90. package/src/internal/grpc_layer/pdfium/compress.js +154 -3
  91. package/src/internal/grpc_layer/pdfium/compress.js.map +1 -1
  92. package/src/internal/grpc_layer/pdfium/compress.ts +191 -1
  93. package/src/internal/grpc_layer/pdfium/form.d.ts +15 -0
  94. package/src/internal/grpc_layer/pdfium/form.d.ts.map +1 -0
  95. package/src/internal/grpc_layer/pdfium/form.js +99 -0
  96. package/src/internal/grpc_layer/pdfium/form.js.map +1 -0
  97. package/src/internal/grpc_layer/pdfium/form.ts +119 -0
  98. package/src/internal/grpc_layer/pdfium/formFontValidator.d.ts +26 -0
  99. package/src/internal/grpc_layer/pdfium/formFontValidator.d.ts.map +1 -0
  100. package/src/internal/grpc_layer/pdfium/formFontValidator.js +81 -0
  101. package/src/internal/grpc_layer/pdfium/formFontValidator.js.map +1 -0
  102. package/src/internal/grpc_layer/pdfium/formFontValidator.ts +86 -0
  103. package/src/internal/grpc_layer/pdfium/linearize.d.ts +48 -0
  104. package/src/internal/grpc_layer/pdfium/linearize.d.ts.map +1 -0
  105. package/src/internal/grpc_layer/pdfium/linearize.js +309 -0
  106. package/src/internal/grpc_layer/pdfium/linearize.js.map +1 -0
  107. package/src/internal/grpc_layer/pdfium/linearize.ts +338 -0
  108. package/src/internal/zod/renderSchema.d.ts.map +1 -1
  109. package/src/internal/zod/renderSchema.js +6 -1
  110. package/src/internal/zod/renderSchema.js.map +1 -1
  111. package/src/internal/zod/renderSchema.ts +6 -1
  112. package/src/public/annotation.d.ts +166 -0
  113. package/src/public/annotation.d.ts.map +1 -0
  114. package/src/public/annotation.js +61 -0
  115. package/src/public/annotation.js.map +1 -0
  116. package/src/public/annotation.ts +166 -0
  117. package/src/public/bookmark.d.ts +25 -0
  118. package/src/public/bookmark.d.ts.map +1 -0
  119. package/src/public/bookmark.js +3 -0
  120. package/src/public/bookmark.js.map +1 -0
  121. package/src/public/bookmark.ts +28 -0
  122. package/src/public/compression.d.ts +92 -0
  123. package/src/public/compression.d.ts.map +1 -0
  124. package/src/public/compression.js +26 -0
  125. package/src/public/compression.js.map +1 -0
  126. package/src/public/compression.ts +107 -0
  127. package/src/public/ironpdfglobalconfig.d.ts +12 -0
  128. package/src/public/ironpdfglobalconfig.d.ts.map +1 -1
  129. package/src/public/ironpdfglobalconfig.js +7 -0
  130. package/src/public/ironpdfglobalconfig.js.map +1 -1
  131. package/src/public/ironpdfglobalconfig.ts +19 -0
  132. package/src/public/pdfDocument.d.ts +234 -1
  133. package/src/public/pdfDocument.d.ts.map +1 -1
  134. package/src/public/pdfDocument.js +489 -17
  135. package/src/public/pdfDocument.js.map +1 -1
  136. package/src/public/pdfDocument.ts +518 -19
  137. package/src/public/render.d.ts +104 -0
  138. package/src/public/render.d.ts.map +1 -1
  139. package/src/public/render.js +35 -1
  140. package/src/public/render.js.map +1 -1
  141. package/src/public/render.ts +101 -0
@@ -0,0 +1,338 @@
1
+ import * as grpc from "@grpc/grpc-js";
2
+ import {Buffer} from "buffer";
3
+ import * as fs from "fs";
4
+ import * as os from "os";
5
+ import * as path from "path";
6
+ import {PassThrough, Readable} from "stream";
7
+ import {Access} from "../../access";
8
+ import {IronPdfServiceClient} from "../../generated_proto/ironpdfengineproto/IronPdfService";
9
+ import {BytesResultStreamP__Output} from "../../generated_proto/ironpdfengineproto/BytesResultStreamP";
10
+ import {BooleanResultP__Output} from "../../generated_proto/ironpdfengineproto/BooleanResultP";
11
+ import {
12
+ QPdfIsLinearizedRequestStreamP
13
+ } from "../../generated_proto/ironpdfengineproto/QPdfIsLinearizedRequestStreamP";
14
+ import {
15
+ QPdfLinearizeInMemoryRequestStreamP
16
+ } from "../../generated_proto/ironpdfengineproto/QPdfLinearizeInMemoryRequestStreamP";
17
+ import {
18
+ QPdfSaveAsLinearizedFromBytesRequestStreamP
19
+ } from "../../generated_proto/ironpdfengineproto/QPdfSaveAsLinearizedFromBytesRequestStreamP";
20
+ import {LinearizationMode} from "../../../public/render";
21
+ import {chunkBuffer, handleRemoteException} from "../util";
22
+
23
+ /**
24
+ * Check if the given PDF bytes represent a linearized ("Fast Web View") PDF.
25
+ */
26
+ export async function isLinearizedFromBytes(
27
+ pdfBytes: Buffer,
28
+ password = ""
29
+ ): Promise<boolean> {
30
+ const client: IronPdfServiceClient = await Access.ensureConnection();
31
+
32
+ return new Promise(
33
+ (resolve: (_: boolean) => void, reject: (errorMsg: string) => void) => {
34
+ const stream: grpc.ClientWritableStream<QPdfIsLinearizedRequestStreamP> =
35
+ client.QPdf_Linearization_IsLinearized(
36
+ (err: grpc.ServiceError | null, value: BooleanResultP__Output | undefined) => {
37
+ if (err) {
38
+ reject(`${err.name}/n${err.message}`);
39
+ } else if (value) {
40
+ if (value.exception) {
41
+ handleRemoteException(value.exception, reject);
42
+ return;
43
+ }
44
+ resolve(value.result ?? false);
45
+ } else {
46
+ reject("No response from IronPdfEngine for isLinearized");
47
+ }
48
+ }
49
+ );
50
+
51
+ stream.write({info: {password: password ?? ""}});
52
+ chunkBuffer(pdfBytes).forEach((chunk) => {
53
+ stream.write({pdfBytesChunk: chunk});
54
+ });
55
+ stream.end();
56
+ }
57
+ );
58
+ }
59
+
60
+ /**
61
+ * Linearize a PDF held by the engine (by document id) and return the linearized bytes
62
+ * via the {@code QPdf_Linearization_LinearizeInMemoryFromId} unary-request/server-streaming RPC.
63
+ */
64
+ export async function linearizeInMemoryFromId(
65
+ id: string,
66
+ password = ""
67
+ ): Promise<Buffer> {
68
+ const client: IronPdfServiceClient = await Access.ensureConnection();
69
+
70
+ return new Promise(
71
+ (resolve: (_: Buffer) => void, reject: (errorMsg: string) => void) => {
72
+ const stream: grpc.ClientReadableStream<BytesResultStreamP__Output> =
73
+ client.QPdf_Linearization_LinearizeInMemoryFromId({
74
+ document: {documentId: id},
75
+ password: password ?? "",
76
+ });
77
+
78
+ const buffers: Buffer[] = [];
79
+ stream.on("data", (data: BytesResultStreamP__Output) => {
80
+ if (data.exception) {
81
+ handleRemoteException(data.exception, reject);
82
+ } else if (data.resultChunk) {
83
+ buffers.push(data.resultChunk);
84
+ }
85
+ });
86
+
87
+ stream.on("error", (err: Error) => {
88
+ reject(`${err.name}/n${err.message}`);
89
+ });
90
+
91
+ stream.on("end", () => {
92
+ resolve(Buffer.concat(buffers));
93
+ });
94
+ }
95
+ );
96
+ }
97
+
98
+ /**
99
+ * Linearize a PDF held by the engine (by document id) and stream the linearized bytes
100
+ * as a {@link Readable}. Useful for piping to HTTP responses or file streams without
101
+ * buffering the entire PDF in memory.
102
+ */
103
+ export async function linearizeInMemoryFromIdStream(
104
+ id: string,
105
+ password = ""
106
+ ): Promise<Readable> {
107
+ const client: IronPdfServiceClient = await Access.ensureConnection();
108
+
109
+ const passThrough = new PassThrough();
110
+
111
+ const stream: grpc.ClientReadableStream<BytesResultStreamP__Output> =
112
+ client.QPdf_Linearization_LinearizeInMemoryFromId({
113
+ document: {documentId: id},
114
+ password: password ?? "",
115
+ });
116
+
117
+ stream.on("data", (data: BytesResultStreamP__Output) => {
118
+ if (data.exception) {
119
+ passThrough.destroy(
120
+ new Error(`${data.exception.message}/n${data.exception.remoteStackTrace}`)
121
+ );
122
+ } else if (data.resultChunk) {
123
+ passThrough.write(data.resultChunk);
124
+ }
125
+ });
126
+
127
+ stream.on("error", (err: Error) => {
128
+ passThrough.destroy(err);
129
+ });
130
+
131
+ stream.on("end", () => {
132
+ passThrough.end();
133
+ });
134
+
135
+ return passThrough;
136
+ }
137
+
138
+ /**
139
+ * Linearize a PDF provided as raw bytes and return the linearized bytes via the
140
+ * bidirectional streaming {@code QPdf_Linearization_LinearizeInMemory} RPC.
141
+ */
142
+ export async function linearizeInMemoryFromBytes(
143
+ pdfBytes: Buffer,
144
+ password = ""
145
+ ): Promise<Buffer> {
146
+ const client: IronPdfServiceClient = await Access.ensureConnection();
147
+
148
+ return new Promise(
149
+ (resolve: (_: Buffer) => void, reject: (errorMsg: string) => void) => {
150
+ const stream: grpc.ClientDuplexStream<
151
+ QPdfLinearizeInMemoryRequestStreamP,
152
+ BytesResultStreamP__Output
153
+ > = client.QPdf_Linearization_LinearizeInMemory();
154
+
155
+ const buffers: Buffer[] = [];
156
+ stream.on("data", (data: BytesResultStreamP__Output) => {
157
+ if (data.exception) {
158
+ handleRemoteException(data.exception, reject);
159
+ } else if (data.resultChunk) {
160
+ buffers.push(data.resultChunk);
161
+ }
162
+ });
163
+
164
+ stream.on("error", (err: Error) => {
165
+ reject(`${err.name}/n${err.message}`);
166
+ });
167
+
168
+ stream.on("end", () => {
169
+ resolve(Buffer.concat(buffers));
170
+ });
171
+
172
+ stream.write({info: {password: password ?? ""}});
173
+ chunkBuffer(pdfBytes).forEach((chunk) => {
174
+ stream.write({pdfBytesChunk: chunk});
175
+ });
176
+ stream.end();
177
+ }
178
+ );
179
+ }
180
+
181
+ /**
182
+ * Core linearization logic shared across all linearization entry points. Implements the
183
+ * {@link LinearizationMode} strategy pattern. Mirrors {@code PdfDocument.LinearizePdfCore}
184
+ * on the C# side.
185
+ */
186
+ export async function linearizeCoreFromBytes(
187
+ pdfBytes: Buffer,
188
+ password = "",
189
+ mode: LinearizationMode = LinearizationMode.Automatic
190
+ ): Promise<Buffer> {
191
+ if (!pdfBytes || pdfBytes.length === 0) {
192
+ throw new Error("The PDF bytes cannot be null or empty.");
193
+ }
194
+
195
+ if (mode === LinearizationMode.InMemory) {
196
+ return linearizeInMemoryFromBytes(pdfBytes, password);
197
+ }
198
+
199
+ if (mode === LinearizationMode.FileBased) {
200
+ // Explicit FileBased — let any disk error bubble up.
201
+ return linearizeViaTempFile(pdfBytes, password);
202
+ }
203
+
204
+ // Automatic mode
205
+ if (canWriteToTemp()) {
206
+ try {
207
+ return await linearizeViaTempFile(pdfBytes, password);
208
+ } catch (e) {
209
+ console.warn(
210
+ `Automatic Linearization: Disk attempt failed (${(e as Error).message}). ` +
211
+ "Falling back to Memory linearization."
212
+ );
213
+ return linearizeInMemoryFromBytes(pdfBytes, password);
214
+ }
215
+ }
216
+ console.warn("Automatic Linearization: No write permission detected. Using Memory linearization.");
217
+ return linearizeInMemoryFromBytes(pdfBytes, password);
218
+ }
219
+
220
+ /**
221
+ * Variant of {@link linearizeCoreFromBytes} that starts from an open document on the engine.
222
+ * For {@link LinearizationMode.InMemory} we use the cheap document-id RPC; for the disk-based
223
+ * paths we have to fetch the bytes once and delegate to {@link linearizeCoreFromBytes}.
224
+ */
225
+ export async function linearizeCoreFromId(
226
+ id: string,
227
+ getBytes: () => Promise<Buffer>,
228
+ password = "",
229
+ mode: LinearizationMode = LinearizationMode.Automatic
230
+ ): Promise<Buffer> {
231
+ if (mode === LinearizationMode.InMemory) {
232
+ return linearizeInMemoryFromId(id, password);
233
+ }
234
+ const pdfBytes = await getBytes();
235
+ return linearizeCoreFromBytes(pdfBytes, password, mode);
236
+ }
237
+
238
+ /**
239
+ * Linearize via the engine's file-based RPC and persist the result through a client-side
240
+ * temporary file. The client-side disk write is the difference between this and
241
+ * {@link linearizeInMemoryFromBytes} — when the client filesystem is read-only,
242
+ * {@code FileBased} mode fails here so {@link LinearizationMode.Automatic} can fall back.
243
+ *
244
+ * Mirrors C# {@code PdfDocument.LinearizeViaTempFile}.
245
+ */
246
+ async function linearizeViaTempFile(pdfBytes: Buffer, password: string): Promise<Buffer> {
247
+ const linearized = await saveAsLinearizedFromBytes(pdfBytes, "", password);
248
+ const tempPath = path.join(
249
+ os.tmpdir(),
250
+ `ironpdf-linearize-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2, 10)}.pdf`
251
+ );
252
+ try {
253
+ fs.writeFileSync(tempPath, linearized);
254
+ return fs.readFileSync(tempPath);
255
+ } finally {
256
+ try {
257
+ if (fs.existsSync(tempPath)) {
258
+ fs.unlinkSync(tempPath);
259
+ }
260
+ } catch {
261
+ // best-effort cleanup
262
+ }
263
+ }
264
+ }
265
+
266
+ /**
267
+ * Probe whether the current process can create files in the system temp directory.
268
+ */
269
+ function canWriteToTemp(): boolean {
270
+ const probePath = path.join(
271
+ os.tmpdir(),
272
+ `ironpdf-probe-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2, 10)}.tmp`
273
+ );
274
+ try {
275
+ fs.writeFileSync(probePath, "");
276
+ return true;
277
+ } catch {
278
+ return false;
279
+ } finally {
280
+ try {
281
+ if (fs.existsSync(probePath)) {
282
+ fs.unlinkSync(probePath);
283
+ }
284
+ } catch {
285
+ // best-effort cleanup
286
+ }
287
+ }
288
+ }
289
+
290
+ /**
291
+ * Linearize a PDF provided as raw bytes and save the result to disk via the file-based
292
+ * streaming {@code QPdf_Linearization_SaveAsLinearizedFromBytes} RPC.
293
+ *
294
+ * Mirrors the in-memory behavior used by {@link compressInMemory} in {@code compress.ts}:
295
+ * the engine streams the linearized bytes back, and we concatenate and persist them
296
+ * locally at {@code outputPath}.
297
+ */
298
+ export async function saveAsLinearizedFromBytes(
299
+ pdfBytes: Buffer,
300
+ outputPath: string,
301
+ password = ""
302
+ ): Promise<Buffer> {
303
+ const client: IronPdfServiceClient = await Access.ensureConnection();
304
+
305
+ return new Promise(
306
+ (resolve: (_: Buffer) => void, reject: (errorMsg: string) => void) => {
307
+ const stream: grpc.ClientDuplexStream<
308
+ QPdfSaveAsLinearizedFromBytesRequestStreamP,
309
+ BytesResultStreamP__Output
310
+ > = client.QPdf_Linearization_SaveAsLinearizedFromBytes();
311
+
312
+ const buffers: Buffer[] = [];
313
+ stream.on("data", (data: BytesResultStreamP__Output) => {
314
+ if (data.exception) {
315
+ handleRemoteException(data.exception, reject);
316
+ } else if (data.resultChunk) {
317
+ buffers.push(data.resultChunk);
318
+ }
319
+ });
320
+
321
+ stream.on("error", (err: Error) => {
322
+ reject(`${err.name}/n${err.message}`);
323
+ });
324
+
325
+ stream.on("end", () => {
326
+ resolve(Buffer.concat(buffers));
327
+ });
328
+
329
+ stream.write({
330
+ info: {outputPath: outputPath, password: password ?? ""},
331
+ });
332
+ chunkBuffer(pdfBytes).forEach((chunk) => {
333
+ stream.write({pdfBytesChunk: chunk});
334
+ });
335
+ stream.end();
336
+ }
337
+ );
338
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"renderSchema.d.ts","sourceRoot":"","sources":["renderSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAA;AACrB,OAAO,EACN,sBAAsB,EACtB,oBAAoB,EACpB,OAAO,EACP,wBAAwB,EACxB,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EAAE,kBAAkB,EACnC,WAAW,EACX,MAAM,qBAAqB,CAAC;AAK7B,eAAO,MAAM,iBAAiB,EAAG,CAAC,CAAC,OAAO,CAAC,WAAW,CAA6B,CAAA;AAEnF,eAAO,MAAM,wBAAwB,EAAE,CAAC,CAAC,OAAO,CAAC,kBAAkB,CAKjE,CAAA;AAEF,eAAO,MAAM,uBAAuB,EAAE,CAAC,CAAC,OAAO,CAAC,iBAAiB,CAK/D,CAAA;AAEF,eAAO,MAAM,yBAAyB,EAAG,CAAC,CAAC,OAAO,CAAC,mBAAmB,CAKpE,CAAA;AAEF,eAAO,MAAM,yBAAyB,EAAG,CAAC,CAAC,OAAO,CAAC,mBAAmB,CAKpE,CAAA;AAEF,eAAO,MAAM,yBAAyB,EAAG,CAAC,CAAC,OAAO,CAAC,mBAAmB,CAKpE,CAAA;AAEF,eAAO,MAAM,qBAAqB,EAAG,CAAC,CAAC,OAAO,CAAC,eAAe,CAE5D,CAAA;AAEF,eAAO,MAAM,8BAA8B,EAAG,CAAC,CAAC,OAAO,CAAC,wBAAwB,CAM9E,CAAA;AAEF,eAAO,MAAM,aAAa,EAAG,CAAC,CAAC,OAAO,CAAC,OAAO,CAQ5C,CAAA;AAEF,eAAO,MAAM,0BAA0B,EAAG,CAAC,CAAC,OAAO,CAAC,oBAAoB,CAKtE,CAAA;AAEF,eAAO,MAAM,4BAA4B,EAAG,CAAC,CAAC,OAAO,CAAC,sBAAsB,CAuB1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
  htmlFooter: affixSchema_1.htmlAffixSchema.optional(),
85
85
  textHeader: affixSchema_1.textAffixSchema.optional(),
86
86
  textFooter: affixSchema_1.textAffixSchema.optional(),
87
- useMarginsOnHeaderAndFooter: typeSchema_1.useMarginsSchema.optional()
87
+ useMarginsOnHeaderAndFooter: typeSchema_1.useMarginsSchema.optional(),
88
+ autoBookmarksFromHeadings: zod_1.z.boolean().optional(),
89
+ autoBookmarkMinHeadingLevel: zod_1.z.number().int().min(1).max(6).optional(),
90
+ autoBookmarkMaxHeadingLevel: zod_1.z.number().int().min(1).max(6).optional(),
91
+ autoBookmarkCssSelectors: zod_1.z.array(zod_1.z.string()).optional(),
92
+ elementQuerySelectors: zod_1.z.array(zod_1.z.string()).optional()
88
93
  });
89
94
  //# sourceMappingURL=renderSchema.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"renderSchema.js","sourceRoot":"","sources":["renderSchema.ts"],"names":[],"mappings":";;;AAAA,6BAAqB;AACrB,gDAW6B;AAC7B,6CAAyI;AACzI,+CAA4E;AAC5E,+CAA+D;AAElD,QAAA,iBAAiB,GAA4B,OAAC,CAAC,UAAU,CAAC,oBAAW,CAAC,CAAA;AAEtE,QAAA,wBAAwB,GAAkC,OAAC,CAAC,MAAM,CAAC;IAC/E,IAAI,EAAE,OAAC,CAAC,OAAO,CAAC,oBAAW,CAAC,WAAW,CAAC;IACxC,KAAK,EAAE,OAAC;SACN,MAAM,EAAE;SACR,QAAQ,EAAE;CACZ,CAAC,CAAA;AAEW,QAAA,uBAAuB,GAAiC,OAAC,CAAC,MAAM,CAAC;IAC7E,IAAI,EAAE,OAAC,CAAC,OAAO,CAAC,oBAAW,CAAC,UAAU,CAAC;IACvC,WAAW,EAAE,OAAC;SACZ,MAAM,EAAE;SACR,QAAQ,EAAE;CACZ,CAAC,CAAA;AAEW,QAAA,yBAAyB,GAAoC,OAAC,CAAC,MAAM,CAAC;IAClF,IAAI,EAAE,OAAC,CAAC,OAAO,CAAC,oBAAW,CAAC,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Ae,CAAC,QAAQ,EAAE;IACrC,UAAU,EAAC,6BAAe,CAAC,QAAQ,EAAE;IACrC,UAAU,EAAC,6BAAe,CAAC,QAAQ,EAAE;IACrC,2BAA2B,EAAE,6BAAgB,CAAC,QAAQ,EAAE;IACxD,yBAAyB,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IACjD,2BAA2B,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACtE,2BAA2B,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACtE,wBAAwB,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IACxD,qBAAqB,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;CACrD,CAAC,CAAA"}
@@ -103,6 +103,11 @@ export const chromePdfRenderOptionsSchema : z.ZodType<ChromePdfRenderOptions> =
103
103
  htmlFooter:htmlAffixSchema.optional(),
104
104
  textHeader:textAffixSchema.optional(),
105
105
  textFooter:textAffixSchema.optional(),
106
- useMarginsOnHeaderAndFooter: useMarginsSchema.optional()
106
+ useMarginsOnHeaderAndFooter: useMarginsSchema.optional(),
107
+ autoBookmarksFromHeadings: z.boolean().optional(),
108
+ autoBookmarkMinHeadingLevel: z.number().int().min(1).max(6).optional(),
109
+ autoBookmarkMaxHeadingLevel: z.number().int().min(1).max(6).optional(),
110
+ autoBookmarkCssSelectors: z.array(z.string()).optional(),
111
+ elementQuerySelectors: z.array(z.string()).optional()
107
112
  })
108
113
 
@@ -0,0 +1,166 @@
1
+ /**
2
+ * Destination type that controls how a PDF reader displays the target page when a
3
+ * bookmark or internal hyperlink is followed.
4
+ *
5
+ * Mirrors {@code IronPdf.Bookmarks.BookmarkDestinations} on the C# side. The numeric
6
+ * value of each entry is what the engine expects on the wire, so the order must match
7
+ * the C# enum.
8
+ *
9
+ * Corresponds to the PDF 1.7 specification §12.3.2 "Explicit Destinations".
10
+ */
11
+ export declare enum BookmarkDestinations {
12
+ /**
13
+ * Fit the entire destination page within the window (PDF {@code /Fit}).
14
+ * No additional coordinates are used.
15
+ */
16
+ Page = 0,
17
+ /**
18
+ * Scroll to a specific Y coordinate on the destination page while fitting the
19
+ * page width to the window (PDF {@code /FitH}).
20
+ * Uses {@link LinkAnnotation.destinationTop}.
21
+ */
22
+ PageY = 1,
23
+ /**
24
+ * Scroll to a specific X coordinate on the destination page while fitting the
25
+ * page height to the window (PDF {@code /FitV}).
26
+ * Uses {@link LinkAnnotation.destinationLeft}.
27
+ */
28
+ PageX = 2,
29
+ /**
30
+ * Scroll to a specific position and zoom level (PDF {@code /XYZ}).
31
+ * Uses {@link LinkAnnotation.destinationLeft}, {@link LinkAnnotation.destinationTop},
32
+ * and {@link LinkAnnotation.destinationZoom}. A {@code destinationZoom} of 0 means
33
+ * "inherit the current zoom".
34
+ */
35
+ PageZoom = 3,
36
+ /**
37
+ * Fit the specified rectangle of the destination page into the window (PDF {@code /FitR}).
38
+ * Uses {@link LinkAnnotation.destinationLeft}, {@link LinkAnnotation.destinationBottom},
39
+ * {@link LinkAnnotation.destinationRight}, and {@link LinkAnnotation.destinationTop}.
40
+ */
41
+ PageRect = 4,
42
+ /**
43
+ * Fit the bounding box of the destination page into the window (PDF {@code /FitB}).
44
+ */
45
+ PageBounds = 5,
46
+ /**
47
+ * Scroll to a Y coordinate while fitting the bounding box width to the window
48
+ * (PDF {@code /FitBH}). Uses {@link LinkAnnotation.destinationTop}.
49
+ */
50
+ PageBoundsY = 6,
51
+ /**
52
+ * Scroll to an X coordinate while fitting the bounding box height to the window
53
+ * (PDF {@code /FitBV}). Uses {@link LinkAnnotation.destinationLeft}.
54
+ */
55
+ PageBoundsX = 7
56
+ }
57
+ /**
58
+ * Defines a clickable link annotation that navigates to a specific page within the same
59
+ * PDF document. Useful for building custom tables of contents, cross-references, and
60
+ * in-document navigation.
61
+ *
62
+ * Mirrors {@code IronPdf.Annotations.LinkAnnotation} on the C# side.
63
+ *
64
+ * @example
65
+ * ```ts
66
+ * // Simple TOC link: from page 0 to page 3
67
+ * await pdf.addLinkAnnotation({
68
+ * pageIndex: 0,
69
+ * destinationPageIndex: 3,
70
+ * x: 72, y: 700,
71
+ * width: 300, height: 18,
72
+ * contents: "Chapter 1 - Introduction",
73
+ * });
74
+ *
75
+ * // Scroll-to-position link: jump to y=400 on page 1
76
+ * await pdf.addLinkAnnotation({
77
+ * pageIndex: 0,
78
+ * destinationPageIndex: 1,
79
+ * destinationType: BookmarkDestinations.PageZoom,
80
+ * destinationTop: 400,
81
+ * destinationZoom: 100,
82
+ * x: 72, y: 650,
83
+ * width: 300, height: 18,
84
+ * });
85
+ * ```
86
+ *
87
+ * <b>Coordinate note:</b> {@code y} sets the <em>bottom</em> edge of the clickable area
88
+ * using PDF coordinates (origin at bottom-left of page).
89
+ */
90
+ export interface LinkAnnotation {
91
+ /** Zero-based index of the page where the link is placed. */
92
+ pageIndex: number;
93
+ /** Zero-based index of the page to navigate to when clicked. */
94
+ destinationPageIndex: number;
95
+ /**
96
+ * Destination type controlling how the target page is displayed.
97
+ * @default BookmarkDestinations.Page
98
+ */
99
+ destinationType?: BookmarkDestinations;
100
+ /**
101
+ * Left coordinate of the destination position, in points.
102
+ * Used by {@link BookmarkDestinations.PageZoom}, {@link BookmarkDestinations.PageX},
103
+ * {@link BookmarkDestinations.PageRect}, and {@link BookmarkDestinations.PageBoundsX}.
104
+ */
105
+ destinationLeft?: number;
106
+ /**
107
+ * Right coordinate of the destination position, in points.
108
+ * Used by {@link BookmarkDestinations.PageRect}.
109
+ */
110
+ destinationRight?: number;
111
+ /**
112
+ * Top coordinate of the destination position, in points.
113
+ * Used by {@link BookmarkDestinations.PageZoom}, {@link BookmarkDestinations.PageY},
114
+ * {@link BookmarkDestinations.PageRect}, and {@link BookmarkDestinations.PageBoundsY}.
115
+ */
116
+ destinationTop?: number;
117
+ /**
118
+ * Bottom coordinate of the destination position, in points.
119
+ * Used by {@link BookmarkDestinations.PageRect}.
120
+ */
121
+ destinationBottom?: number;
122
+ /**
123
+ * Zoom level (in percent) for the destination. Used by
124
+ * {@link BookmarkDestinations.PageZoom}. A value of 0 means inherit the current zoom.
125
+ */
126
+ destinationZoom?: number;
127
+ /**
128
+ * Horizontal X position from the LEFT edge of the page, in points.
129
+ */
130
+ x: number;
131
+ /**
132
+ * Vertical Y position from the BOTTOM edge of the page, in points.
133
+ * PDF coordinate system places Y=0 at the bottom of the page.
134
+ */
135
+ y: number;
136
+ /** Width of the clickable link area, in points. */
137
+ width: number;
138
+ /** Height of the clickable link area, in points. */
139
+ height: number;
140
+ /**
141
+ * Color code for the link border in CSS `#RRGGBB` format.
142
+ * @default undefined (no explicit color)
143
+ */
144
+ colorCode?: string;
145
+ /**
146
+ * Whether the link annotation is hidden from users.
147
+ * @default false
148
+ */
149
+ hidden?: boolean;
150
+ /**
151
+ * Descriptive text content for this link annotation.
152
+ * @default ""
153
+ */
154
+ contents?: string;
155
+ /**
156
+ * Title for this link annotation.
157
+ * @default ""
158
+ */
159
+ title?: string;
160
+ /**
161
+ * Whether the link annotation displays a visible border when clicked.
162
+ * @default false
163
+ */
164
+ showBorder?: boolean;
165
+ }
166
+ //# sourceMappingURL=annotation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"annotation.d.ts","sourceRoot":"","sources":["annotation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,oBAAY,oBAAoB;IAC/B;;;OAGG;IACH,IAAI,IAAI;IACR;;;;OAIG;IACH,KAAK,IAAI;IACT;;;;OAIG;IACH,KAAK,IAAI;IACT;;;;;OAKG;IACH,QAAQ,IAAI;IACZ;;;;OAIG;IACH,QAAQ,IAAI;IACZ;;OAEG;IACH,UAAU,IAAI;IACd;;;OAGG;IACH,WAAW,IAAI;IACf;;;OAGG;IACH,WAAW,IAAI;CACf;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,WAAW,cAAc;IAC9B,6DAA6D;IAC7D,SAAS,EAAE,MAAM,CAAC;IAClB,gEAAgE;IAChE,oBAAoB,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,eAAe,CAAC,EAAE,oBAAoB,CAAC;IACvC;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,CAAC,EAAE,MAAM,CAAC;IACV;;;OAGG;IACH,CAAC,EAAE,MAAM,CAAC;IACV,mDAAmD;IACnD,KAAK,EAAE,MAAM,CAAC;IACd,oDAAoD;IACpD,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACrB"}
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BookmarkDestinations = void 0;
4
+ /**
5
+ * Destination type that controls how a PDF reader displays the target page when a
6
+ * bookmark or internal hyperlink is followed.
7
+ *
8
+ * Mirrors {@code IronPdf.Bookmarks.BookmarkDestinations} on the C# side. The numeric
9
+ * value of each entry is what the engine expects on the wire, so the order must match
10
+ * the C# enum.
11
+ *
12
+ * Corresponds to the PDF 1.7 specification §12.3.2 "Explicit Destinations".
13
+ */
14
+ var BookmarkDestinations;
15
+ (function (BookmarkDestinations) {
16
+ /**
17
+ * Fit the entire destination page within the window (PDF {@code /Fit}).
18
+ * No additional coordinates are used.
19
+ */
20
+ BookmarkDestinations[BookmarkDestinations["Page"] = 0] = "Page";
21
+ /**
22
+ * Scroll to a specific Y coordinate on the destination page while fitting the
23
+ * page width to the window (PDF {@code /FitH}).
24
+ * Uses {@link LinkAnnotation.destinationTop}.
25
+ */
26
+ BookmarkDestinations[BookmarkDestinations["PageY"] = 1] = "PageY";
27
+ /**
28
+ * Scroll to a specific X coordinate on the destination page while fitting the
29
+ * page height to the window (PDF {@code /FitV}).
30
+ * Uses {@link LinkAnnotation.destinationLeft}.
31
+ */
32
+ BookmarkDestinations[BookmarkDestinations["PageX"] = 2] = "PageX";
33
+ /**
34
+ * Scroll to a specific position and zoom level (PDF {@code /XYZ}).
35
+ * Uses {@link LinkAnnotation.destinationLeft}, {@link LinkAnnotation.destinationTop},
36
+ * and {@link LinkAnnotation.destinationZoom}. A {@code destinationZoom} of 0 means
37
+ * "inherit the current zoom".
38
+ */
39
+ BookmarkDestinations[BookmarkDestinations["PageZoom"] = 3] = "PageZoom";
40
+ /**
41
+ * Fit the specified rectangle of the destination page into the window (PDF {@code /FitR}).
42
+ * Uses {@link LinkAnnotation.destinationLeft}, {@link LinkAnnotation.destinationBottom},
43
+ * {@link LinkAnnotation.destinationRight}, and {@link LinkAnnotation.destinationTop}.
44
+ */
45
+ BookmarkDestinations[BookmarkDestinations["PageRect"] = 4] = "PageRect";
46
+ /**
47
+ * Fit the bounding box of the destination page into the window (PDF {@code /FitB}).
48
+ */
49
+ BookmarkDestinations[BookmarkDestinations["PageBounds"] = 5] = "PageBounds";
50
+ /**
51
+ * Scroll to a Y coordinate while fitting the bounding box width to the window
52
+ * (PDF {@code /FitBH}). Uses {@link LinkAnnotation.destinationTop}.
53
+ */
54
+ BookmarkDestinations[BookmarkDestinations["PageBoundsY"] = 6] = "PageBoundsY";
55
+ /**
56
+ * Scroll to an X coordinate while fitting the bounding box height to the window
57
+ * (PDF {@code /FitBV}). Uses {@link LinkAnnotation.destinationLeft}.
58
+ */
59
+ BookmarkDestinations[BookmarkDestinations["PageBoundsX"] = 7] = "PageBoundsX";
60
+ })(BookmarkDestinations = exports.BookmarkDestinations || (exports.BookmarkDestinations = {}));
61
+ //# sourceMappingURL=annotation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"annotation.js","sourceRoot":"","sources":["annotation.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;GASG;AACH,IAAY,oBA6CX;AA7CD,WAAY,oBAAoB;IAC/B;;;OAGG;IACH,+DAAQ,CAAA;IACR;;;;OAIG;IACH,iEAAS,CAAA;IACT;;;;OAIG;IACH,iEAAS,CAAA;IACT;;;;;OAKG;IACH,uEAAY,CAAA;IACZ;;;;OAIG;IACH,uEAAY,CAAA;IACZ;;OAEG;IACH,2EAAc,CAAA;IACd;;;OAGG;IACH,6EAAe,CAAA;IACf;;;OAGG;IACH,6EAAe,CAAA;AAChB,CAAC,EA7CW,oBAAoB,GAApB,4BAAoB,KAApB,4BAAoB,QA6C/B"}