@ironsoftware/ironpdf 2026.4.1 → 2026.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/index.d.ts +2 -0
- package/src/index.d.ts.map +1 -1
- package/src/index.js +2 -0
- package/src/index.js.map +1 -1
- package/src/index.ts +2 -0
- package/src/internal/IronPdfEngine.ProtoFiles/chrome_render.proto +6 -0
- package/src/internal/IronPdfEngine.ProtoFiles/iron_pdf_service.proto +2 -1
- package/src/internal/IronPdfEngine.ProtoFiles/qpdf.proto +16 -0
- package/src/internal/generated_proto/iron_pdf_service.d.ts +614 -305
- package/src/internal/generated_proto/iron_pdf_service.d.ts.map +1 -1
- package/src/internal/generated_proto/iron_pdf_service.ts +614 -305
- package/src/internal/generated_proto/ironpdfengineproto/ChromePdfRenderOptionsP.d.ts +15 -0
- package/src/internal/generated_proto/ironpdfengineproto/ChromePdfRenderOptionsP.d.ts.map +1 -1
- package/src/internal/generated_proto/ironpdfengineproto/ChromePdfRenderOptionsP.ts +15 -0
- package/src/internal/generated_proto/ironpdfengineproto/IronPdfService.d.ts +14 -0
- package/src/internal/generated_proto/ironpdfengineproto/IronPdfService.d.ts.map +1 -1
- package/src/internal/generated_proto/ironpdfengineproto/IronPdfService.ts +18 -0
- package/src/internal/generated_proto/ironpdfengineproto/QPdfLinearizeInMemoryRequestIdP.d.ts +10 -0
- package/src/internal/generated_proto/ironpdfengineproto/QPdfLinearizeInMemoryRequestIdP.d.ts.map +1 -0
- package/src/internal/generated_proto/ironpdfengineproto/QPdfLinearizeInMemoryRequestIdP.js +4 -0
- package/src/internal/generated_proto/ironpdfengineproto/QPdfLinearizeInMemoryRequestIdP.js.map +1 -0
- package/src/internal/generated_proto/ironpdfengineproto/QPdfLinearizeInMemoryRequestIdP.ts +13 -0
- package/src/internal/generated_proto/ironpdfengineproto/QPdfLinearizeInMemoryRequestStreamP.d.ts +18 -0
- package/src/internal/generated_proto/ironpdfengineproto/QPdfLinearizeInMemoryRequestStreamP.d.ts.map +1 -0
- package/src/internal/generated_proto/ironpdfengineproto/QPdfLinearizeInMemoryRequestStreamP.js +4 -0
- package/src/internal/generated_proto/ironpdfengineproto/QPdfLinearizeInMemoryRequestStreamP.js.map +1 -0
- package/src/internal/generated_proto/ironpdfengineproto/QPdfLinearizeInMemoryRequestStreamP.ts +21 -0
- package/src/internal/grpc_layer/chrome/converter.d.ts +10 -0
- package/src/internal/grpc_layer/chrome/converter.d.ts.map +1 -1
- package/src/internal/grpc_layer/chrome/converter.js +61 -2
- package/src/internal/grpc_layer/chrome/converter.js.map +1 -1
- package/src/internal/grpc_layer/chrome/converter.ts +67 -0
- package/src/internal/grpc_layer/pdfium/annotations.d.ts +30 -0
- package/src/internal/grpc_layer/pdfium/annotations.d.ts.map +1 -0
- package/src/internal/grpc_layer/pdfium/annotations.js +161 -0
- package/src/internal/grpc_layer/pdfium/annotations.js.map +1 -0
- package/src/internal/grpc_layer/pdfium/annotations.ts +190 -0
- package/src/internal/grpc_layer/pdfium/bookmarks.d.ts +7 -0
- package/src/internal/grpc_layer/pdfium/bookmarks.d.ts.map +1 -0
- package/src/internal/grpc_layer/pdfium/bookmarks.js +53 -0
- package/src/internal/grpc_layer/pdfium/bookmarks.js.map +1 -0
- package/src/internal/grpc_layer/pdfium/bookmarks.ts +50 -0
- package/src/internal/grpc_layer/pdfium/linearize.d.ts +48 -0
- package/src/internal/grpc_layer/pdfium/linearize.d.ts.map +1 -0
- package/src/internal/grpc_layer/pdfium/linearize.js +309 -0
- package/src/internal/grpc_layer/pdfium/linearize.js.map +1 -0
- package/src/internal/grpc_layer/pdfium/linearize.ts +338 -0
- package/src/internal/zod/renderSchema.d.ts.map +1 -1
- package/src/internal/zod/renderSchema.js +6 -1
- package/src/internal/zod/renderSchema.js.map +1 -1
- package/src/internal/zod/renderSchema.ts +6 -1
- package/src/public/annotation.d.ts +166 -0
- package/src/public/annotation.d.ts.map +1 -0
- package/src/public/annotation.js +61 -0
- package/src/public/annotation.js.map +1 -0
- package/src/public/annotation.ts +166 -0
- package/src/public/bookmark.d.ts +25 -0
- package/src/public/bookmark.d.ts.map +1 -0
- package/src/public/bookmark.js +3 -0
- package/src/public/bookmark.js.map +1 -0
- package/src/public/bookmark.ts +28 -0
- package/src/public/pdfDocument.d.ts +168 -1
- package/src/public/pdfDocument.d.ts.map +1 -1
- package/src/public/pdfDocument.js +341 -17
- package/src/public/pdfDocument.js.map +1 -1
- package/src/public/pdfDocument.ts +364 -18
- package/src/public/render.d.ts +104 -0
- package/src/public/render.d.ts.map +1 -1
- package/src/public/render.js +35 -1
- package/src/public/render.js.map +1 -1
- package/src/public/render.ts +101 -0
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
/// <reference types="node" />
|
|
4
4
|
import { Buffer } from "buffer";
|
|
5
|
-
import { BarcodeStampOptions, BarcodeType, ChangeTrackingModes, ChromePdfRenderOptions, DigitalSignature, VerifiedSignature, HtmlAffix, HtmlFilePath, HtmlStampOptions, HtmlString, HttpLoginCredentials, ImageBuffer, ImageFilePath, ImageStampOptions, ImageToPdfOptions, ImageType, PageInfo, PageRotation, PdfInput, PdfPageSelection, PdfPaperSize, PdfPassword, PdfPermission, SaveOptions, TextAffix, TextStampOptions } from "./types";
|
|
5
|
+
import { BarcodeStampOptions, BarcodeType, ChangeTrackingModes, ChromePdfRenderOptions, DigitalSignature, VerifiedSignature, HtmlAffix, HtmlFilePath, HtmlStampOptions, HtmlString, HttpLoginCredentials, ImageBuffer, ImageFilePath, ImageStampOptions, ImageToPdfOptions, ImageType, LinearizationMode, PageInfo, PageRotation, PdfInput, PdfPageSelection, PdfPaperSize, PdfPassword, PdfPermission, RenderedElementLocation, SaveOptions, TextAffix, TextStampOptions } from "./types";
|
|
6
|
+
import { LinkAnnotation } from "./annotation";
|
|
7
|
+
import { Bookmark } from "./bookmark";
|
|
6
8
|
import { Readable } from "stream";
|
|
7
9
|
import { PdfAVersions, PdfUAVersions } from "../internal/grpc_layer/pdfium/pdfa";
|
|
8
10
|
import { NaturalLanguages } from "./naturalLanguages";
|
|
@@ -190,6 +192,129 @@ export declare class PdfDocument {
|
|
|
190
192
|
* @param imageQuality Optional JPEG quality (1-100) for image compression. If omitted, default compression is applied.
|
|
191
193
|
*/
|
|
192
194
|
compressAndSaveAs(filePath: string, imageQuality?: number): Promise<void>;
|
|
195
|
+
/**
|
|
196
|
+
* Linearize the current PDF document and return the result as a {@link Buffer} (byte array).
|
|
197
|
+
* Produces a web-optimized PDF that can be viewed incrementally in a browser.
|
|
198
|
+
*
|
|
199
|
+
* @param mode Linearization strategy. Defaults to {@link LinearizationMode.Automatic}.
|
|
200
|
+
* @returns A Promise resolving to a Buffer containing the linearized PDF bytes.
|
|
201
|
+
*/
|
|
202
|
+
linearizePdfToBytes(mode?: LinearizationMode): Promise<Buffer>;
|
|
203
|
+
/**
|
|
204
|
+
* Linearize the current PDF document and return the result as a {@link Readable} stream.
|
|
205
|
+
* Useful for piping directly to file streams or HTTP responses without buffering the
|
|
206
|
+
* entire PDF in memory.
|
|
207
|
+
*
|
|
208
|
+
* <b>Note:</b> Stream output is only supported with {@link LinearizationMode.InMemory}
|
|
209
|
+
* (or {@link LinearizationMode.Automatic} when memory mode is selected). For
|
|
210
|
+
* {@link LinearizationMode.FileBased} use {@link linearizePdfToBytes} or
|
|
211
|
+
* {@link saveAsLinearized}.
|
|
212
|
+
*
|
|
213
|
+
* @returns A Promise resolving to a Readable stream of the linearized PDF bytes.
|
|
214
|
+
*/
|
|
215
|
+
linearizePdfToStream(): Promise<Readable>;
|
|
216
|
+
/**
|
|
217
|
+
* Linearize the current PDF document and save the result to the given output file path.
|
|
218
|
+
*
|
|
219
|
+
* @param outputFilePath The file path to save the linearized PDF.
|
|
220
|
+
* @param mode Linearization strategy. Defaults to {@link LinearizationMode.Automatic}.
|
|
221
|
+
*/
|
|
222
|
+
saveAsLinearized(outputFilePath: string, mode?: LinearizationMode): Promise<void>;
|
|
223
|
+
/**
|
|
224
|
+
* Check whether the PDF file at the given path is linearized ("Fast Web View").
|
|
225
|
+
*
|
|
226
|
+
* @param pdfFilePath Path to a PDF file on disk.
|
|
227
|
+
* @param password Optional password for encrypted PDFs.
|
|
228
|
+
* @returns A Promise resolving to true if the file is linearized, false otherwise.
|
|
229
|
+
*/
|
|
230
|
+
static isLinearized(pdfFilePath: string, password?: string): Promise<boolean>;
|
|
231
|
+
/**
|
|
232
|
+
* Linearize the given PDF bytes and return the linearized bytes.
|
|
233
|
+
* Static helper for linearizing PDFs without creating a PdfDocument instance.
|
|
234
|
+
*
|
|
235
|
+
* @param pdfBytes Buffer containing the PDF data.
|
|
236
|
+
* @param password Optional password to decrypt the PDF if encrypted.
|
|
237
|
+
* @param mode Linearization strategy. Defaults to {@link LinearizationMode.Automatic}.
|
|
238
|
+
*/
|
|
239
|
+
static linearizePdfBytesToBytes(pdfBytes: Buffer, password?: string, mode?: LinearizationMode): Promise<Buffer>;
|
|
240
|
+
/**
|
|
241
|
+
* Linearize the given PDF bytes and save the result to the given output file path.
|
|
242
|
+
* Static helper for linearizing PDFs without creating a PdfDocument instance.
|
|
243
|
+
*
|
|
244
|
+
* @param pdfBytes Buffer containing the PDF data.
|
|
245
|
+
* @param outputFilePath The file path to save the linearized PDF.
|
|
246
|
+
* @param password Optional password to decrypt the PDF if encrypted.
|
|
247
|
+
* @param mode Linearization strategy. Defaults to {@link LinearizationMode.Automatic}.
|
|
248
|
+
*/
|
|
249
|
+
static saveAsLinearizedFromBytes(pdfBytes: Buffer, outputFilePath: string, password?: string, mode?: LinearizationMode): Promise<void>;
|
|
250
|
+
/**
|
|
251
|
+
* Retrieves the rendered page locations of HTML elements that were tracked during rendering.
|
|
252
|
+
*
|
|
253
|
+
* To use this feature, set {@link ChromePdfRenderOptions.elementQuerySelectors} with CSS
|
|
254
|
+
* selectors before rendering. After rendering, call this method to retrieve the page index
|
|
255
|
+
* and coordinates of each matched element.
|
|
256
|
+
*
|
|
257
|
+
* Results are cached on first call and reused on subsequent calls. If you modify the
|
|
258
|
+
* document's annotations after rendering, call {@link resetElementLocationCache} to force
|
|
259
|
+
* the cache to be rebuilt on next access.
|
|
260
|
+
*
|
|
261
|
+
* Mirrors {@code IronPdf.PdfDocument.GetElementLocations()} on the C# side.
|
|
262
|
+
*
|
|
263
|
+
* @returns A list of {@link RenderedElementLocation} objects, one per matched element,
|
|
264
|
+
* sorted in document order. Returns an empty list if no element query selectors were
|
|
265
|
+
* configured or no elements matched.
|
|
266
|
+
*/
|
|
267
|
+
getElementLocations(): Promise<RenderedElementLocation[]>;
|
|
268
|
+
/**
|
|
269
|
+
* Clears the cached result of {@link getElementLocations}, forcing a fresh scan of the
|
|
270
|
+
* document's annotations on the next call. Call this if you've modified the document's
|
|
271
|
+
* annotations or structure after rendering.
|
|
272
|
+
*/
|
|
273
|
+
resetElementLocationCache(): void;
|
|
274
|
+
/**
|
|
275
|
+
* Retrieves all outline bookmarks (table-of-contents entries) in this PDF document.
|
|
276
|
+
*
|
|
277
|
+
* <p>Bookmarks are returned as a flat list with parent linkage via
|
|
278
|
+
* {@link Bookmark.parentItemId}. Roots have an empty {@code parentItemId}.
|
|
279
|
+
* Use {@link Bookmark.hierarchy} for depth information.</p>
|
|
280
|
+
*
|
|
281
|
+
* <p>Auto-bookmarks generated from HTML headings (via
|
|
282
|
+
* {@link ChromePdfRenderOptions.autoBookmarksFromHeadings}) are included.</p>
|
|
283
|
+
*
|
|
284
|
+
* <p>Mirrors {@code IronPdf.PdfDocument.Bookmarks} on the C# side.</p>
|
|
285
|
+
*
|
|
286
|
+
* @returns A list of {@link Bookmark} objects, sorted in document order.
|
|
287
|
+
* Returns an empty list if the document has no bookmarks.
|
|
288
|
+
*/
|
|
289
|
+
getBookmarks(): Promise<Bookmark[]>;
|
|
290
|
+
/**
|
|
291
|
+
* Adds a clickable internal hyperlink annotation that navigates to another page within
|
|
292
|
+
* the same PDF document. Useful for building custom tables of contents, cross-references,
|
|
293
|
+
* and in-document navigation.
|
|
294
|
+
*
|
|
295
|
+
* The target page and display options are configured via the {@link LinkAnnotation}
|
|
296
|
+
* fields ({@code destinationPageIndex}, {@code destinationType}, etc.).
|
|
297
|
+
*
|
|
298
|
+
* Mirrors {@code IronPdf.Annotations.LinkAnnotation} on the C# side.
|
|
299
|
+
*
|
|
300
|
+
* @example
|
|
301
|
+
* ```ts
|
|
302
|
+
* await pdf.addLinkAnnotation({
|
|
303
|
+
* pageIndex: 0,
|
|
304
|
+
* destinationPageIndex: 3,
|
|
305
|
+
* x: 72, y: 700,
|
|
306
|
+
* width: 300, height: 18,
|
|
307
|
+
* contents: "Chapter 1",
|
|
308
|
+
* });
|
|
309
|
+
* ```
|
|
310
|
+
*/
|
|
311
|
+
addLinkAnnotation(link: LinkAnnotation): Promise<void>;
|
|
312
|
+
/**
|
|
313
|
+
* Retrieves the number of annotations contained on the specified page.
|
|
314
|
+
*
|
|
315
|
+
* @param pageIndex Zero-based page index. The first page has a page index of 0.
|
|
316
|
+
*/
|
|
317
|
+
getAnnotationCount(pageIndex: number): Promise<number>;
|
|
193
318
|
/**
|
|
194
319
|
* Gets information of all pages in the PdfDocument
|
|
195
320
|
*/
|
|
@@ -310,6 +435,16 @@ export declare class PdfDocument {
|
|
|
310
435
|
* @param customICC (Optional) Custom color profile file path
|
|
311
436
|
*/
|
|
312
437
|
convertToPdfA(pdfaVersion?: PdfAVersions, customICC?: string | undefined): Promise<void>;
|
|
438
|
+
/**
|
|
439
|
+
* Render HTML to PDF and convert to PDF/UA format with screen reader support.
|
|
440
|
+
* Produces a proper semantic structure tree (Sect → H1, P, etc.) for accessibility.
|
|
441
|
+
* @param html The HTML string to render
|
|
442
|
+
* @param naturalLanguages Document language for screen readers (default: English)
|
|
443
|
+
* @param options Optional render options
|
|
444
|
+
*/
|
|
445
|
+
static fromHtmlAsPdfUA(html: string, naturalLanguages?: NaturalLanguages, options?: {
|
|
446
|
+
renderOptions?: ChromePdfRenderOptions | undefined;
|
|
447
|
+
} | undefined): Promise<PdfDocument>;
|
|
313
448
|
/**
|
|
314
449
|
* Convert the current document into the specified PDF/UA standard format
|
|
315
450
|
*/
|
|
@@ -606,6 +741,38 @@ export declare class PdfDocument {
|
|
|
606
741
|
* @param imageQuality Optional JPEG quality (1-100) for image compression. If omitted, default compression is applied.
|
|
607
742
|
*/
|
|
608
743
|
private internal_compressAndSaveAs;
|
|
744
|
+
/**
|
|
745
|
+
* Linearize the current PDF document and return the result as a Buffer.
|
|
746
|
+
*/
|
|
747
|
+
private internal_linearizePdfToBytes;
|
|
748
|
+
/**
|
|
749
|
+
* Linearize the current PDF document and return the result as a Readable stream.
|
|
750
|
+
* Always uses the in-memory streaming RPC.
|
|
751
|
+
*/
|
|
752
|
+
private internal_linearizePdfToStream;
|
|
753
|
+
/**
|
|
754
|
+
* Linearize the current PDF document and save the result to the given output file path.
|
|
755
|
+
*/
|
|
756
|
+
private internal_saveAsLinearized;
|
|
757
|
+
/**
|
|
758
|
+
* Prefix used by the engine-side element query JavaScript extension when injecting anchor
|
|
759
|
+
* markers. Must match {@code IronPdf.TableOfContents.ElementQueryJavascriptExtension.ELEMENT_QUERY_PREFIX}
|
|
760
|
+
* on the C# side.
|
|
761
|
+
*/
|
|
762
|
+
private static readonly ELEMENT_QUERY_PREFIX;
|
|
763
|
+
/**
|
|
764
|
+
* Cache for {@link getElementLocations}. Built lazily on first call.
|
|
765
|
+
*
|
|
766
|
+
* The underlying element-query anchor annotations are written during rendering and are
|
|
767
|
+
* not expected to be mutated afterwards, so a simple populate-once cache is appropriate.
|
|
768
|
+
* Callers who modify the document's annotations after rendering should call
|
|
769
|
+
* {@link resetElementLocationCache} to force a rebuild.
|
|
770
|
+
*/
|
|
771
|
+
private cachedElementLocations;
|
|
772
|
+
private internal_getElementLocations;
|
|
773
|
+
private internal_addLinkAnnotation;
|
|
774
|
+
private internal_getAnnotationCount;
|
|
775
|
+
private internal_getBookmarks;
|
|
609
776
|
/**
|
|
610
777
|
* Gets information of all pages in the PdfDocument
|
|
611
778
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pdfDocument.d.ts","sourceRoot":"","sources":["pdfDocument.ts"],"names":[],"mappings":";;;AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,QAAQ,CAAC;AAC9B,OAAO,EACN,mBAAmB,EACnB,WAAW,EAAE,mBAAmB,EAChC,sBAAsB,EACtB,gBAAgB,EAChB,iBAAiB,EACjB,SAAS,EACT,YAAY,EACZ,gBAAgB,EAChB,UAAU,EACV,oBAAoB,EACpB,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,gBAAgB,EAChB,YAAY,EACZ,WAAW,EAAE,aAAa,EAC1B,WAAW,EACX,SAAS,EACT,gBAAgB,EAChB,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"pdfDocument.d.ts","sourceRoot":"","sources":["pdfDocument.ts"],"names":[],"mappings":";;;AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,QAAQ,CAAC;AAC9B,OAAO,EACN,mBAAmB,EACnB,WAAW,EAAE,mBAAmB,EAChC,sBAAsB,EACtB,gBAAgB,EAChB,iBAAiB,EACjB,SAAS,EACT,YAAY,EACZ,gBAAgB,EAChB,UAAU,EACV,oBAAoB,EACpB,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,SAAS,EACT,iBAAiB,EACjB,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,gBAAgB,EAChB,YAAY,EACZ,WAAW,EAAE,aAAa,EAC1B,uBAAuB,EACvB,WAAW,EACX,SAAS,EACT,gBAAgB,EAChB,MAAM,SAAS,CAAC;AAiDjB,OAAO,EAAC,cAAc,EAAC,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AACpC,OAAO,EAAC,QAAQ,EAAC,MAAM,QAAQ,CAA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YACW,yBAAyB;IAYvC;;;;;;;OAOG;YACW,gCAAgC;IAmC9C;;;;;;;;OAQG;YACW,8BAA8B;IAgC5C;;;;;OAKG;YACW,oBAAoB;YAQpB,oBAAoB;IASlC;;;;OAIG;YACW,sBAAsB;IAIpC;;OAEG;YACW,uBAAuB;IAOrC;;OAEG;YACW,oBAAoB;IAIlC;;;;OAIG;YACW,4BAA4B;IAO1C;;;OAGG;YACW,uBAAuB;IAKrC;;;OAGG;YACW,yBAAyB;IASvC;;;;;;;OAOG;YACW,6BAA6B;IAI3C;;OAEG;YACW,iBAAiB;IAK/B;;OAEG;YACW,uBAAuB;IAIrC;;OAEG;YACW,8BAA8B;IAO5C;;;;OAIG;YACW,sBAAsB;IAOpC;;;;OAIG;YACW,sBAAsB;IAOpC;;;;OAIG;YACW,sBAAsB;IAOpC;;;;OAIG;YACW,sBAAsB;IAUpC;;;;OAIG;YACW,kBAAkB;IAoBhC;;;;OAIG;YACW,mBAAmB;IAiBjC;;;;OAIG;YACW,kBAAkB;IAchC;;;;OAIG;YACW,qBAAqB;IAsBnC;;;;;;;OAOG;YACW,oCAAoC;IAclD;;;;;;;OAOG;YACW,oCAAoC;IAiBlD;;;;OAIG;YACW,qCAAqC;IAInD;;;OAGG;YACW,wBAAwB;IAUtC;;;;;;OAMG;YACW,yBAAyB;IAUvC;;;OAGG;YACW,sBAAsB;IAIpC;;;OAGG;YACW,sBAAsB;IAIpC;;;;;OAKG;YACW,gCAAgC;CAe9C"}
|
|
@@ -33,6 +33,9 @@ const io_1 = require("../internal/grpc_layer/pdfium/io");
|
|
|
33
33
|
const access_1 = require("../internal/access");
|
|
34
34
|
const image_1 = require("../internal/grpc_layer/chrome/image");
|
|
35
35
|
const compress_1 = require("../internal/grpc_layer/pdfium/compress");
|
|
36
|
+
const linearize_1 = require("../internal/grpc_layer/pdfium/linearize");
|
|
37
|
+
const annotations_1 = require("../internal/grpc_layer/pdfium/annotations");
|
|
38
|
+
const bookmarks_1 = require("../internal/grpc_layer/pdfium/bookmarks");
|
|
36
39
|
const page_1 = require("../internal/grpc_layer/pdfium/page");
|
|
37
40
|
const image_2 = require("../internal/grpc_layer/pdfium/image");
|
|
38
41
|
const jimp_1 = __importDefault(require("jimp"));
|
|
@@ -44,6 +47,7 @@ const headerFooter_1 = require("../internal/grpc_layer/pdfium/headerFooter");
|
|
|
44
47
|
const stamp_1 = require("../internal/grpc_layer/chrome/stamp");
|
|
45
48
|
const BackgroundForeground_1 = require("../internal/grpc_layer/pdfium/BackgroundForeground");
|
|
46
49
|
const security_1 = require("../internal/grpc_layer/pdfium/security");
|
|
50
|
+
const naturalLanguages_1 = require("./naturalLanguages");
|
|
47
51
|
/**
|
|
48
52
|
* Represents a PDF document. Allows: loading, editing, manipulating, merging, signing printing and saving PDFs.
|
|
49
53
|
*
|
|
@@ -286,6 +290,201 @@ class PdfDocument {
|
|
|
286
290
|
});
|
|
287
291
|
}
|
|
288
292
|
//#endregion
|
|
293
|
+
//#region linearize
|
|
294
|
+
/**
|
|
295
|
+
* Linearize the current PDF document and return the result as a {@link Buffer} (byte array).
|
|
296
|
+
* Produces a web-optimized PDF that can be viewed incrementally in a browser.
|
|
297
|
+
*
|
|
298
|
+
* @param mode Linearization strategy. Defaults to {@link LinearizationMode.Automatic}.
|
|
299
|
+
* @returns A Promise resolving to a Buffer containing the linearized PDF bytes.
|
|
300
|
+
*/
|
|
301
|
+
linearizePdfToBytes(mode = types_1.LinearizationMode.Automatic) {
|
|
302
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
303
|
+
return this.internal_linearizePdfToBytes(mode);
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Linearize the current PDF document and return the result as a {@link Readable} stream.
|
|
308
|
+
* Useful for piping directly to file streams or HTTP responses without buffering the
|
|
309
|
+
* entire PDF in memory.
|
|
310
|
+
*
|
|
311
|
+
* <b>Note:</b> Stream output is only supported with {@link LinearizationMode.InMemory}
|
|
312
|
+
* (or {@link LinearizationMode.Automatic} when memory mode is selected). For
|
|
313
|
+
* {@link LinearizationMode.FileBased} use {@link linearizePdfToBytes} or
|
|
314
|
+
* {@link saveAsLinearized}.
|
|
315
|
+
*
|
|
316
|
+
* @returns A Promise resolving to a Readable stream of the linearized PDF bytes.
|
|
317
|
+
*/
|
|
318
|
+
linearizePdfToStream() {
|
|
319
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
320
|
+
return this.internal_linearizePdfToStream();
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Linearize the current PDF document and save the result to the given output file path.
|
|
325
|
+
*
|
|
326
|
+
* @param outputFilePath The file path to save the linearized PDF.
|
|
327
|
+
* @param mode Linearization strategy. Defaults to {@link LinearizationMode.Automatic}.
|
|
328
|
+
*/
|
|
329
|
+
saveAsLinearized(outputFilePath, mode = types_1.LinearizationMode.Automatic) {
|
|
330
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
331
|
+
return yield zod_1.z.function()
|
|
332
|
+
.args(typeSchema_1.filePathSchema, zod_1.z.nativeEnum(types_1.LinearizationMode).optional())
|
|
333
|
+
.returns(zod_1.z.promise(zod_1.z.void()))
|
|
334
|
+
.implement((filePath, m) => __awaiter(this, void 0, void 0, function* () {
|
|
335
|
+
return this.internal_saveAsLinearized(filePath, m !== null && m !== void 0 ? m : types_1.LinearizationMode.Automatic);
|
|
336
|
+
}))(outputFilePath, mode);
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Check whether the PDF file at the given path is linearized ("Fast Web View").
|
|
341
|
+
*
|
|
342
|
+
* @param pdfFilePath Path to a PDF file on disk.
|
|
343
|
+
* @param password Optional password for encrypted PDFs.
|
|
344
|
+
* @returns A Promise resolving to true if the file is linearized, false otherwise.
|
|
345
|
+
*/
|
|
346
|
+
static isLinearized(pdfFilePath, password = "") {
|
|
347
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
348
|
+
return yield zod_1.z.function()
|
|
349
|
+
.args(typeSchema_1.pdfFilePathSchema, typeSchema_1.stringSchema.optional())
|
|
350
|
+
.returns(zod_1.z.promise(typeSchema_1.booleanSchema))
|
|
351
|
+
.implement((filePath, pwd) => __awaiter(this, void 0, void 0, function* () {
|
|
352
|
+
const bytes = fs_1.default.readFileSync(filePath);
|
|
353
|
+
return yield (0, linearize_1.isLinearizedFromBytes)(bytes, pwd !== null && pwd !== void 0 ? pwd : "");
|
|
354
|
+
}))(pdfFilePath, password);
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Linearize the given PDF bytes and return the linearized bytes.
|
|
359
|
+
* Static helper for linearizing PDFs without creating a PdfDocument instance.
|
|
360
|
+
*
|
|
361
|
+
* @param pdfBytes Buffer containing the PDF data.
|
|
362
|
+
* @param password Optional password to decrypt the PDF if encrypted.
|
|
363
|
+
* @param mode Linearization strategy. Defaults to {@link LinearizationMode.Automatic}.
|
|
364
|
+
*/
|
|
365
|
+
static linearizePdfBytesToBytes(pdfBytes, password = "", mode = types_1.LinearizationMode.Automatic) {
|
|
366
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
367
|
+
return yield zod_1.z.function()
|
|
368
|
+
.args(typeSchema_1.bufferSchema, typeSchema_1.stringSchema.optional(), zod_1.z.nativeEnum(types_1.LinearizationMode).optional())
|
|
369
|
+
.returns(zod_1.z.promise(zod_1.z.instanceof(buffer_1.Buffer)))
|
|
370
|
+
.implement((bytes, pwd, m) => __awaiter(this, void 0, void 0, function* () {
|
|
371
|
+
return yield (0, linearize_1.linearizeCoreFromBytes)(bytes, pwd !== null && pwd !== void 0 ? pwd : "", m !== null && m !== void 0 ? m : types_1.LinearizationMode.Automatic);
|
|
372
|
+
}))(pdfBytes, password, mode);
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Linearize the given PDF bytes and save the result to the given output file path.
|
|
377
|
+
* Static helper for linearizing PDFs without creating a PdfDocument instance.
|
|
378
|
+
*
|
|
379
|
+
* @param pdfBytes Buffer containing the PDF data.
|
|
380
|
+
* @param outputFilePath The file path to save the linearized PDF.
|
|
381
|
+
* @param password Optional password to decrypt the PDF if encrypted.
|
|
382
|
+
* @param mode Linearization strategy. Defaults to {@link LinearizationMode.Automatic}.
|
|
383
|
+
*/
|
|
384
|
+
static saveAsLinearizedFromBytes(pdfBytes, outputFilePath, password = "", mode = types_1.LinearizationMode.Automatic) {
|
|
385
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
386
|
+
return yield zod_1.z.function()
|
|
387
|
+
.args(typeSchema_1.bufferSchema, typeSchema_1.filePathSchema, typeSchema_1.stringSchema.optional(), zod_1.z.nativeEnum(types_1.LinearizationMode).optional())
|
|
388
|
+
.returns(zod_1.z.promise(zod_1.z.void()))
|
|
389
|
+
.implement((bytes, filePath, pwd, m) => __awaiter(this, void 0, void 0, function* () {
|
|
390
|
+
const linearized = yield (0, linearize_1.linearizeCoreFromBytes)(bytes, pwd !== null && pwd !== void 0 ? pwd : "", m !== null && m !== void 0 ? m : types_1.LinearizationMode.Automatic);
|
|
391
|
+
fs_1.default.writeFileSync(filePath, linearized);
|
|
392
|
+
}))(pdfBytes, outputFilePath, password, mode);
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
//#endregion
|
|
396
|
+
//#region elementLocations
|
|
397
|
+
/**
|
|
398
|
+
* Retrieves the rendered page locations of HTML elements that were tracked during rendering.
|
|
399
|
+
*
|
|
400
|
+
* To use this feature, set {@link ChromePdfRenderOptions.elementQuerySelectors} with CSS
|
|
401
|
+
* selectors before rendering. After rendering, call this method to retrieve the page index
|
|
402
|
+
* and coordinates of each matched element.
|
|
403
|
+
*
|
|
404
|
+
* Results are cached on first call and reused on subsequent calls. If you modify the
|
|
405
|
+
* document's annotations after rendering, call {@link resetElementLocationCache} to force
|
|
406
|
+
* the cache to be rebuilt on next access.
|
|
407
|
+
*
|
|
408
|
+
* Mirrors {@code IronPdf.PdfDocument.GetElementLocations()} on the C# side.
|
|
409
|
+
*
|
|
410
|
+
* @returns A list of {@link RenderedElementLocation} objects, one per matched element,
|
|
411
|
+
* sorted in document order. Returns an empty list if no element query selectors were
|
|
412
|
+
* configured or no elements matched.
|
|
413
|
+
*/
|
|
414
|
+
getElementLocations() {
|
|
415
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
416
|
+
return this.internal_getElementLocations();
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Clears the cached result of {@link getElementLocations}, forcing a fresh scan of the
|
|
421
|
+
* document's annotations on the next call. Call this if you've modified the document's
|
|
422
|
+
* annotations or structure after rendering.
|
|
423
|
+
*/
|
|
424
|
+
resetElementLocationCache() {
|
|
425
|
+
this.cachedElementLocations = null;
|
|
426
|
+
}
|
|
427
|
+
//#endregion
|
|
428
|
+
//#region bookmarks
|
|
429
|
+
/**
|
|
430
|
+
* Retrieves all outline bookmarks (table-of-contents entries) in this PDF document.
|
|
431
|
+
*
|
|
432
|
+
* <p>Bookmarks are returned as a flat list with parent linkage via
|
|
433
|
+
* {@link Bookmark.parentItemId}. Roots have an empty {@code parentItemId}.
|
|
434
|
+
* Use {@link Bookmark.hierarchy} for depth information.</p>
|
|
435
|
+
*
|
|
436
|
+
* <p>Auto-bookmarks generated from HTML headings (via
|
|
437
|
+
* {@link ChromePdfRenderOptions.autoBookmarksFromHeadings}) are included.</p>
|
|
438
|
+
*
|
|
439
|
+
* <p>Mirrors {@code IronPdf.PdfDocument.Bookmarks} on the C# side.</p>
|
|
440
|
+
*
|
|
441
|
+
* @returns A list of {@link Bookmark} objects, sorted in document order.
|
|
442
|
+
* Returns an empty list if the document has no bookmarks.
|
|
443
|
+
*/
|
|
444
|
+
getBookmarks() {
|
|
445
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
446
|
+
return this.internal_getBookmarks();
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
//#endregion
|
|
450
|
+
//#region annotation
|
|
451
|
+
/**
|
|
452
|
+
* Adds a clickable internal hyperlink annotation that navigates to another page within
|
|
453
|
+
* the same PDF document. Useful for building custom tables of contents, cross-references,
|
|
454
|
+
* and in-document navigation.
|
|
455
|
+
*
|
|
456
|
+
* The target page and display options are configured via the {@link LinkAnnotation}
|
|
457
|
+
* fields ({@code destinationPageIndex}, {@code destinationType}, etc.).
|
|
458
|
+
*
|
|
459
|
+
* Mirrors {@code IronPdf.Annotations.LinkAnnotation} on the C# side.
|
|
460
|
+
*
|
|
461
|
+
* @example
|
|
462
|
+
* ```ts
|
|
463
|
+
* await pdf.addLinkAnnotation({
|
|
464
|
+
* pageIndex: 0,
|
|
465
|
+
* destinationPageIndex: 3,
|
|
466
|
+
* x: 72, y: 700,
|
|
467
|
+
* width: 300, height: 18,
|
|
468
|
+
* contents: "Chapter 1",
|
|
469
|
+
* });
|
|
470
|
+
* ```
|
|
471
|
+
*/
|
|
472
|
+
addLinkAnnotation(link) {
|
|
473
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
474
|
+
return this.internal_addLinkAnnotation(link);
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* Retrieves the number of annotations contained on the specified page.
|
|
479
|
+
*
|
|
480
|
+
* @param pageIndex Zero-based page index. The first page has a page index of 0.
|
|
481
|
+
*/
|
|
482
|
+
getAnnotationCount(pageIndex) {
|
|
483
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
484
|
+
return this.internal_getAnnotationCount(pageIndex);
|
|
485
|
+
});
|
|
486
|
+
}
|
|
487
|
+
//#endregion
|
|
289
488
|
//#region page
|
|
290
489
|
/**
|
|
291
490
|
* Gets information of all pages in the PdfDocument
|
|
@@ -485,23 +684,20 @@ class PdfDocument {
|
|
|
485
684
|
.implement(this.internal_convertToPdfA.bind(this))(pdfaVersion, customICC);
|
|
486
685
|
});
|
|
487
686
|
}
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
// await toPdfUAForScreenReader(await pdf.internal_getId(), html, naturalLanguages);
|
|
503
|
-
// return pdf;
|
|
504
|
-
// }
|
|
687
|
+
/**
|
|
688
|
+
* Render HTML to PDF and convert to PDF/UA format with screen reader support.
|
|
689
|
+
* Produces a proper semantic structure tree (Sect → H1, P, etc.) for accessibility.
|
|
690
|
+
* @param html The HTML string to render
|
|
691
|
+
* @param naturalLanguages Document language for screen readers (default: English)
|
|
692
|
+
* @param options Optional render options
|
|
693
|
+
*/
|
|
694
|
+
static fromHtmlAsPdfUA(html, naturalLanguages = naturalLanguages_1.NaturalLanguages.English, options) {
|
|
695
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
696
|
+
const pdf = yield PdfDocument.fromHtml(html, options);
|
|
697
|
+
yield (0, pdfa_1.toPdfUAForScreenReader)(yield pdf.internal_getId(), html, naturalLanguages);
|
|
698
|
+
return pdf;
|
|
699
|
+
});
|
|
700
|
+
}
|
|
505
701
|
/**
|
|
506
702
|
* Convert the current document into the specified PDF/UA standard format
|
|
507
703
|
*/
|
|
@@ -852,6 +1048,15 @@ class PdfDocument {
|
|
|
852
1048
|
*/
|
|
853
1049
|
constructor(pdfInput, password, trackChanges) {
|
|
854
1050
|
var _a;
|
|
1051
|
+
/**
|
|
1052
|
+
* Cache for {@link getElementLocations}. Built lazily on first call.
|
|
1053
|
+
*
|
|
1054
|
+
* The underlying element-query anchor annotations are written during rendering and are
|
|
1055
|
+
* not expected to be mutated afterwards, so a simple populate-once cache is appropriate.
|
|
1056
|
+
* Callers who modify the document's annotations after rendering should call
|
|
1057
|
+
* {@link resetElementLocationCache} to force a rebuild.
|
|
1058
|
+
*/
|
|
1059
|
+
this.cachedElementLocations = null;
|
|
855
1060
|
if (pdfInput) {
|
|
856
1061
|
this.pdfDocumentId = undefined;
|
|
857
1062
|
const input = (0, util_1.separatePdfInput)(pdfInput);
|
|
@@ -1164,6 +1369,117 @@ class PdfDocument {
|
|
|
1164
1369
|
});
|
|
1165
1370
|
}
|
|
1166
1371
|
//#endregion
|
|
1372
|
+
//#region linearize
|
|
1373
|
+
/**
|
|
1374
|
+
* Linearize the current PDF document and return the result as a Buffer.
|
|
1375
|
+
*/
|
|
1376
|
+
internal_linearizePdfToBytes(mode) {
|
|
1377
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1378
|
+
const id = yield this.internal_getId();
|
|
1379
|
+
return yield (0, linearize_1.linearizeCoreFromId)(id, () => this.internal_saveAsBuffer(), "", mode);
|
|
1380
|
+
});
|
|
1381
|
+
}
|
|
1382
|
+
/**
|
|
1383
|
+
* Linearize the current PDF document and return the result as a Readable stream.
|
|
1384
|
+
* Always uses the in-memory streaming RPC.
|
|
1385
|
+
*/
|
|
1386
|
+
internal_linearizePdfToStream() {
|
|
1387
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1388
|
+
return yield (0, linearize_1.linearizeInMemoryFromIdStream)(yield this.internal_getId());
|
|
1389
|
+
});
|
|
1390
|
+
}
|
|
1391
|
+
/**
|
|
1392
|
+
* Linearize the current PDF document and save the result to the given output file path.
|
|
1393
|
+
*/
|
|
1394
|
+
internal_saveAsLinearized(outputFilePath, mode) {
|
|
1395
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1396
|
+
const id = yield this.internal_getId();
|
|
1397
|
+
const linearized = yield (0, linearize_1.linearizeCoreFromId)(id, () => this.internal_saveAsBuffer(), "", mode);
|
|
1398
|
+
fs_1.default.writeFileSync(outputFilePath, linearized);
|
|
1399
|
+
});
|
|
1400
|
+
}
|
|
1401
|
+
internal_getElementLocations() {
|
|
1402
|
+
var _a, _b, _c, _d, _e;
|
|
1403
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1404
|
+
if (this.cachedElementLocations !== null) {
|
|
1405
|
+
return this.cachedElementLocations;
|
|
1406
|
+
}
|
|
1407
|
+
const id = yield this.internal_getId();
|
|
1408
|
+
const pageInfos = yield (0, page_1.getPageInfo)(id);
|
|
1409
|
+
const locations = [];
|
|
1410
|
+
for (let pageIdx = 0; pageIdx < pageInfos.length; pageIdx++) {
|
|
1411
|
+
const annotations = yield (0, annotations_1.getAnnotations)(id, pageIdx);
|
|
1412
|
+
for (const wrapped of annotations) {
|
|
1413
|
+
if (!wrapped.link)
|
|
1414
|
+
continue;
|
|
1415
|
+
const dest = wrapped.link.dest;
|
|
1416
|
+
if (!dest || !dest.startsWith(PdfDocument.ELEMENT_QUERY_PREFIX))
|
|
1417
|
+
continue;
|
|
1418
|
+
const remainder = dest.substring(PdfDocument.ELEMENT_QUERY_PREFIX.length);
|
|
1419
|
+
const dashIdx = remainder.indexOf("-");
|
|
1420
|
+
if (dashIdx <= 0)
|
|
1421
|
+
continue;
|
|
1422
|
+
const indexStr = remainder.substring(0, dashIdx);
|
|
1423
|
+
const elementIndex = parseInt(indexStr, 10);
|
|
1424
|
+
if (isNaN(elementIndex))
|
|
1425
|
+
continue;
|
|
1426
|
+
const encodedText = remainder.substring(dashIdx + 1);
|
|
1427
|
+
let text;
|
|
1428
|
+
try {
|
|
1429
|
+
text = decodeURIComponent(encodedText);
|
|
1430
|
+
}
|
|
1431
|
+
catch (_f) {
|
|
1432
|
+
text = encodedText;
|
|
1433
|
+
}
|
|
1434
|
+
const innerRect = (_a = wrapped.link.annotation) === null || _a === void 0 ? void 0 : _a.rectangle;
|
|
1435
|
+
const rectangle = innerRect
|
|
1436
|
+
? {
|
|
1437
|
+
x: (_b = innerRect.x) !== null && _b !== void 0 ? _b : 0,
|
|
1438
|
+
y: (_c = innerRect.y) !== null && _c !== void 0 ? _c : 0,
|
|
1439
|
+
width: (_d = innerRect.width) !== null && _d !== void 0 ? _d : 0,
|
|
1440
|
+
height: (_e = innerRect.height) !== null && _e !== void 0 ? _e : 0,
|
|
1441
|
+
}
|
|
1442
|
+
: { x: 0, y: 0, width: 0, height: 0 };
|
|
1443
|
+
locations.push({ text, pageIndex: pageIdx, rectangle, elementIndex });
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
locations.sort((a, b) => a.elementIndex - b.elementIndex);
|
|
1447
|
+
this.cachedElementLocations = locations;
|
|
1448
|
+
return this.cachedElementLocations;
|
|
1449
|
+
});
|
|
1450
|
+
}
|
|
1451
|
+
//#endregion
|
|
1452
|
+
//#region annotation
|
|
1453
|
+
internal_addLinkAnnotation(link) {
|
|
1454
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1455
|
+
if (!link) {
|
|
1456
|
+
throw new Error("link annotation cannot be null or undefined");
|
|
1457
|
+
}
|
|
1458
|
+
if (link.pageIndex < 0) {
|
|
1459
|
+
throw new Error("Invalid page index when adding link annotation");
|
|
1460
|
+
}
|
|
1461
|
+
if (link.destinationPageIndex < 0) {
|
|
1462
|
+
throw new Error("Invalid destination page index when adding link annotation");
|
|
1463
|
+
}
|
|
1464
|
+
yield (0, annotations_1.addLinkAnnotation)(yield this.internal_getId(), link);
|
|
1465
|
+
});
|
|
1466
|
+
}
|
|
1467
|
+
internal_getAnnotationCount(pageIndex) {
|
|
1468
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1469
|
+
if (pageIndex < 0) {
|
|
1470
|
+
throw new Error("Invalid page index when getting annotation count");
|
|
1471
|
+
}
|
|
1472
|
+
return yield (0, annotations_1.getAnnotationCount)(yield this.internal_getId(), pageIndex);
|
|
1473
|
+
});
|
|
1474
|
+
}
|
|
1475
|
+
//#endregion
|
|
1476
|
+
//#region bookmarks
|
|
1477
|
+
internal_getBookmarks() {
|
|
1478
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1479
|
+
return yield (0, bookmarks_1.getBookmarks)(yield this.internal_getId());
|
|
1480
|
+
});
|
|
1481
|
+
}
|
|
1482
|
+
//#endregion
|
|
1167
1483
|
//#region page
|
|
1168
1484
|
/**
|
|
1169
1485
|
* Gets information of all pages in the PdfDocument
|
|
@@ -1649,4 +1965,12 @@ class PdfDocument {
|
|
|
1649
1965
|
}
|
|
1650
1966
|
}
|
|
1651
1967
|
exports.PdfDocument = PdfDocument;
|
|
1968
|
+
//#endregion
|
|
1969
|
+
//#region elementLocations
|
|
1970
|
+
/**
|
|
1971
|
+
* Prefix used by the engine-side element query JavaScript extension when injecting anchor
|
|
1972
|
+
* markers. Must match {@code IronPdf.TableOfContents.ElementQueryJavascriptExtension.ELEMENT_QUERY_PREFIX}
|
|
1973
|
+
* on the C# side.
|
|
1974
|
+
*/
|
|
1975
|
+
PdfDocument.ELEMENT_QUERY_PREFIX = "ironpdf-elq-";
|
|
1652
1976
|
//# sourceMappingURL=pdfDocument.js.map
|