@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
|
@@ -67,7 +67,10 @@ import {mergePdfs, renderHtmlToPdf, renderHtmlZipToPdf, renderUrlToPdf, renderHt
|
|
|
67
67
|
import {disposePdf, getBinaryData, openPdfFileBuffer} from "../internal/grpc_layer/pdfium/io";
|
|
68
68
|
import {Access} from "../internal/access";
|
|
69
69
|
import {renderImagesBufferToPdf, renderImagesFilesToPdf} from "../internal/grpc_layer/chrome/image";
|
|
70
|
-
import {compressAndSaveAs, compressImage, compressInMemory, compressInMemoryStream, compressStructTree} from "../internal/grpc_layer/pdfium/compress";
|
|
70
|
+
import {compressAndSaveAs, compressImage, compressInMemory, compressInMemoryStream, compressStructTree, compressAndSaveAsAdvanced, compressAndSaveAsAdvancedFromBytes} from "../internal/grpc_layer/pdfium/compress";
|
|
71
|
+
import {disableFormFontFallback, setFormFont} from "../internal/grpc_layer/pdfium/form";
|
|
72
|
+
import {AdvancedCompressionOptions} from "./compression";
|
|
73
|
+
import * as path from "path";
|
|
71
74
|
import {
|
|
72
75
|
isLinearizedFromBytes,
|
|
73
76
|
linearizeCoreFromBytes,
|
|
@@ -471,6 +474,117 @@ export class PdfDocument{
|
|
|
471
474
|
(filePath, imageQuality);
|
|
472
475
|
}
|
|
473
476
|
|
|
477
|
+
/**
|
|
478
|
+
* Apply the advanced compression pipeline and save the result to a file.
|
|
479
|
+
*
|
|
480
|
+
* Combines pdfium-side image DPI downsampling with qpdf-side structural
|
|
481
|
+
* optimization in a single call.
|
|
482
|
+
*
|
|
483
|
+
* @param filePath the file path to save the compressed PDF
|
|
484
|
+
* @param options advanced compression options; pass an empty object `{}` to
|
|
485
|
+
* reproduce the legacy compressAndSaveAs behaviour with no
|
|
486
|
+
* image downsampling
|
|
487
|
+
* @param password the PDF password (empty string if none)
|
|
488
|
+
*/
|
|
489
|
+
public async compressAndSaveAsAdvanced(
|
|
490
|
+
filePath: string,
|
|
491
|
+
options: AdvancedCompressionOptions,
|
|
492
|
+
password?: string
|
|
493
|
+
): Promise<void> {
|
|
494
|
+
return this.internal_compressAndSaveAsAdvanced(filePath, options, password);
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
* Apply the advanced compression pipeline to byte[] input and save the
|
|
499
|
+
* compressed result to a file. Returns the compressed bytes as well.
|
|
500
|
+
*/
|
|
501
|
+
public static async compressAndSaveAsAdvancedFromBytes(
|
|
502
|
+
pdfBytes: Buffer,
|
|
503
|
+
filePath: string,
|
|
504
|
+
options: AdvancedCompressionOptions,
|
|
505
|
+
password?: string
|
|
506
|
+
): Promise<Buffer> {
|
|
507
|
+
if (!pdfBytes || pdfBytes.length === 0) {
|
|
508
|
+
throw new Error("pdfBytes must not be null or empty");
|
|
509
|
+
}
|
|
510
|
+
if (!options) {
|
|
511
|
+
throw new Error("options must not be null");
|
|
512
|
+
}
|
|
513
|
+
return compressAndSaveAsAdvancedFromBytes(pdfBytes, filePath, options, password ?? "");
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
//#endregion
|
|
517
|
+
|
|
518
|
+
//#region form (PDF-2184)
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* Set the document-wide form font for subsequent form-field fills. When
|
|
522
|
+
* set, the engine skips its automatic Tahoma/Arial fallback embed for
|
|
523
|
+
* non-ASCII form values and registers the supplied font in the AcroForm
|
|
524
|
+
* /DR /Font dictionary so default-appearance strings resolve correctly
|
|
525
|
+
* at render time.
|
|
526
|
+
*
|
|
527
|
+
* File-size impact:
|
|
528
|
+
* - Name-only mode (`fontData` omitted or empty): zero bytes added; the
|
|
529
|
+
* font must already be in the document.
|
|
530
|
+
* - Bytes mode and the font is already embedded with usable glyph data:
|
|
531
|
+
* zero bytes added.
|
|
532
|
+
* - Bytes mode and the font is missing or has no glyph data: the full
|
|
533
|
+
* font is embedded.
|
|
534
|
+
* - Bytes mode with `forceEmbed = true`: a fresh font copy is added
|
|
535
|
+
* alongside any existing copy; the document grows on every call.
|
|
536
|
+
*
|
|
537
|
+
* @param fontName PDF font name to register (e.g. "Poppins-Regular").
|
|
538
|
+
* Allowed characters: letters, digits, `_`, `-`, `.`, `+`.
|
|
539
|
+
* @param fontData Raw TrueType/OpenType bytes; pass `undefined` or an
|
|
540
|
+
* empty Buffer for name-only mode.
|
|
541
|
+
* @param forceEmbed When true, embed `fontData` even if a font with the
|
|
542
|
+
* same name and usable glyph data is already present.
|
|
543
|
+
*/
|
|
544
|
+
public async setFormFont(
|
|
545
|
+
fontName: string,
|
|
546
|
+
fontData?: Buffer,
|
|
547
|
+
forceEmbed = false
|
|
548
|
+
): Promise<void> {
|
|
549
|
+
return setFormFont(await this.internal_getId(), fontName, fontData, forceEmbed);
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* Load a TrueType/OpenType font from disk and apply it as the
|
|
554
|
+
* document-wide form font. The PDF font name is derived from the file
|
|
555
|
+
* name (without extension) when `fontName` is omitted.
|
|
556
|
+
*
|
|
557
|
+
* @param fontFilePath Path to a TTF/OTF/TTC font file
|
|
558
|
+
* @param fontName Optional PDF font name. When omitted the file name
|
|
559
|
+
* (without extension) is used.
|
|
560
|
+
* @param forceEmbed When true, embed even if the font is already present.
|
|
561
|
+
*/
|
|
562
|
+
public async setFormFontFromFile(
|
|
563
|
+
fontFilePath: string,
|
|
564
|
+
fontName?: string,
|
|
565
|
+
forceEmbed = false
|
|
566
|
+
): Promise<void> {
|
|
567
|
+
if (!fontFilePath) {
|
|
568
|
+
throw new Error("fontFilePath must not be empty");
|
|
569
|
+
}
|
|
570
|
+
const fontData = fs.readFileSync(fontFilePath);
|
|
571
|
+
const resolvedName = fontName ?? deriveFontNameFromPath(fontFilePath);
|
|
572
|
+
return setFormFont(await this.internal_getId(), resolvedName, fontData, forceEmbed);
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* Suppress the automatic Tahoma/Arial fallback embed for non-ASCII form
|
|
577
|
+
* values without registering any replacement font. Use when zero
|
|
578
|
+
* file-size growth is required and the template's existing font
|
|
579
|
+
* references are sufficient for the values being filled.
|
|
580
|
+
*
|
|
581
|
+
* Rendering of non-ASCII characters then depends entirely on the
|
|
582
|
+
* viewer's font substitution.
|
|
583
|
+
*/
|
|
584
|
+
public async disableFormFontFallback(): Promise<void> {
|
|
585
|
+
return disableFormFontFallback(await this.internal_getId());
|
|
586
|
+
}
|
|
587
|
+
|
|
474
588
|
//#endregion
|
|
475
589
|
|
|
476
590
|
//#region linearize
|
|
@@ -1839,6 +1953,34 @@ export class PdfDocument{
|
|
|
1839
1953
|
);
|
|
1840
1954
|
}
|
|
1841
1955
|
|
|
1956
|
+
private async internal_compressAndSaveAsAdvanced(
|
|
1957
|
+
filePath: string,
|
|
1958
|
+
options: AdvancedCompressionOptions,
|
|
1959
|
+
password?: string
|
|
1960
|
+
): Promise<void> {
|
|
1961
|
+
if (!filePath || filePath.trim().length === 0) {
|
|
1962
|
+
throw new Error("filePath must not be empty");
|
|
1963
|
+
}
|
|
1964
|
+
if (!options) {
|
|
1965
|
+
throw new Error("options must not be null");
|
|
1966
|
+
}
|
|
1967
|
+
if (
|
|
1968
|
+
options.jpegQuality !== undefined &&
|
|
1969
|
+
options.jpegQuality !== null &&
|
|
1970
|
+
(options.jpegQuality < 1 || options.jpegQuality > 100)
|
|
1971
|
+
) {
|
|
1972
|
+
throw new Error(
|
|
1973
|
+
`Invalid jpegQuality (${options.jpegQuality}). Must be between 1 and 100.`
|
|
1974
|
+
);
|
|
1975
|
+
}
|
|
1976
|
+
return await compressAndSaveAsAdvanced(
|
|
1977
|
+
await this.internal_getId(),
|
|
1978
|
+
filePath,
|
|
1979
|
+
options,
|
|
1980
|
+
password ?? ""
|
|
1981
|
+
);
|
|
1982
|
+
}
|
|
1983
|
+
|
|
1842
1984
|
//#endregion
|
|
1843
1985
|
|
|
1844
1986
|
//#region linearize
|
|
@@ -2570,3 +2712,14 @@ export class PdfDocument{
|
|
|
2570
2712
|
|
|
2571
2713
|
//#endregion
|
|
2572
2714
|
}
|
|
2715
|
+
|
|
2716
|
+
/**
|
|
2717
|
+
* Derive a PDF font name from a font file path: strip the directory and the
|
|
2718
|
+
* extension. Used by {@link PdfDocument.setFormFontFromFile} when no
|
|
2719
|
+
* explicit name is supplied.
|
|
2720
|
+
*/
|
|
2721
|
+
function deriveFontNameFromPath(fontFilePath: string): string {
|
|
2722
|
+
const base = path.basename(fontFilePath);
|
|
2723
|
+
const dot = base.lastIndexOf(".");
|
|
2724
|
+
return dot > 0 ? base.substring(0, dot) : base;
|
|
2725
|
+
}
|