@ironsoftware/ironpdf 2026.2.1 → 2026.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/internal/IronPdfEngine.ProtoFiles/iron_pdf_service.proto +2 -0
- package/src/internal/IronPdfEngine.ProtoFiles/qpdf.proto +17 -0
- package/src/internal/generated_proto/iron_pdf_service.d.ts +2 -0
- package/src/internal/generated_proto/iron_pdf_service.d.ts.map +1 -1
- package/src/internal/generated_proto/iron_pdf_service.ts +2 -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/QPdfCompressInMemoryRequestIdP.d.ts +10 -0
- package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressInMemoryRequestIdP.d.ts.map +1 -0
- package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressInMemoryRequestIdP.js +4 -0
- package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressInMemoryRequestIdP.js.map +1 -0
- package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressInMemoryRequestIdP.ts +13 -0
- package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressInMemoryRequestStreamP.d.ts +18 -0
- package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressInMemoryRequestStreamP.d.ts.map +1 -0
- package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressInMemoryRequestStreamP.js +4 -0
- package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressInMemoryRequestStreamP.js.map +1 -0
- package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressInMemoryRequestStreamP.ts +21 -0
- package/src/internal/grpc_layer/pdfium/compress.d.ts +6 -0
- package/src/internal/grpc_layer/pdfium/compress.d.ts.map +1 -1
- package/src/internal/grpc_layer/pdfium/compress.js +51 -1
- package/src/internal/grpc_layer/pdfium/compress.js.map +1 -1
- package/src/internal/grpc_layer/pdfium/compress.ts +79 -0
- package/src/public/pdfDocument.d.ts +30 -0
- package/src/public/pdfDocument.d.ts.map +1 -1
- package/src/public/pdfDocument.js +54 -0
- package/src/public/pdfDocument.js.map +1 -1
- package/src/public/pdfDocument.ts +2149 -2074
|
@@ -186,6 +186,8 @@ import type { QPdfCompleteSavingAsPdfA4RequestP as _ironpdfengineproto_QPdfCompl
|
|
|
186
186
|
import type { QPdfCompleteSavingAsPdfUA2RequestP as _ironpdfengineproto_QPdfCompleteSavingAsPdfUA2RequestP, QPdfCompleteSavingAsPdfUA2RequestP__Output as _ironpdfengineproto_QPdfCompleteSavingAsPdfUA2RequestP__Output } from '../ironpdfengineproto/QPdfCompleteSavingAsPdfUA2RequestP';
|
|
187
187
|
import type { QPdfCompressAndSaveAsFromBytesRequestStreamP as _ironpdfengineproto_QPdfCompressAndSaveAsFromBytesRequestStreamP, QPdfCompressAndSaveAsFromBytesRequestStreamP__Output as _ironpdfengineproto_QPdfCompressAndSaveAsFromBytesRequestStreamP__Output } from '../ironpdfengineproto/QPdfCompressAndSaveAsFromBytesRequestStreamP';
|
|
188
188
|
import type { QPdfCompressAndSaveAsRequestP as _ironpdfengineproto_QPdfCompressAndSaveAsRequestP, QPdfCompressAndSaveAsRequestP__Output as _ironpdfengineproto_QPdfCompressAndSaveAsRequestP__Output } from '../ironpdfengineproto/QPdfCompressAndSaveAsRequestP';
|
|
189
|
+
import type { QPdfCompressInMemoryRequestIdP as _ironpdfengineproto_QPdfCompressInMemoryRequestIdP, QPdfCompressInMemoryRequestIdP__Output as _ironpdfengineproto_QPdfCompressInMemoryRequestIdP__Output } from '../ironpdfengineproto/QPdfCompressInMemoryRequestIdP';
|
|
190
|
+
import type { QPdfCompressInMemoryRequestStreamP as _ironpdfengineproto_QPdfCompressInMemoryRequestStreamP, QPdfCompressInMemoryRequestStreamP__Output as _ironpdfengineproto_QPdfCompressInMemoryRequestStreamP__Output } from '../ironpdfengineproto/QPdfCompressInMemoryRequestStreamP';
|
|
189
191
|
import type { QPdfIsLinearizedRequestStreamP as _ironpdfengineproto_QPdfIsLinearizedRequestStreamP, QPdfIsLinearizedRequestStreamP__Output as _ironpdfengineproto_QPdfIsLinearizedRequestStreamP__Output } from '../ironpdfengineproto/QPdfIsLinearizedRequestStreamP';
|
|
190
192
|
import type { QPdfSaveAsJsonRequestStreamP as _ironpdfengineproto_QPdfSaveAsJsonRequestStreamP, QPdfSaveAsJsonRequestStreamP__Output as _ironpdfengineproto_QPdfSaveAsJsonRequestStreamP__Output } from '../ironpdfengineproto/QPdfSaveAsJsonRequestStreamP';
|
|
191
193
|
import type { QPdfSaveAsLinearizedFromBytesRequestStreamP as _ironpdfengineproto_QPdfSaveAsLinearizedFromBytesRequestStreamP, QPdfSaveAsLinearizedFromBytesRequestStreamP__Output as _ironpdfengineproto_QPdfSaveAsLinearizedFromBytesRequestStreamP__Output } from '../ironpdfengineproto/QPdfSaveAsLinearizedFromBytesRequestStreamP';
|
|
@@ -1382,6 +1384,16 @@ export interface IronPdfServiceClient extends grpc.Client {
|
|
|
1382
1384
|
qPdfCompressionCompressAndSaveAsFromBytes(metadata: grpc.Metadata, options?: grpc.CallOptions): grpc.ClientDuplexStream<_ironpdfengineproto_QPdfCompressAndSaveAsFromBytesRequestStreamP, _ironpdfengineproto_BytesResultStreamP__Output>;
|
|
1383
1385
|
qPdfCompressionCompressAndSaveAsFromBytes(options?: grpc.CallOptions): grpc.ClientDuplexStream<_ironpdfengineproto_QPdfCompressAndSaveAsFromBytesRequestStreamP, _ironpdfengineproto_BytesResultStreamP__Output>;
|
|
1384
1386
|
|
|
1387
|
+
QPdf_Compression_CompressInMemory(metadata: grpc.Metadata, options?: grpc.CallOptions): grpc.ClientDuplexStream<_ironpdfengineproto_QPdfCompressInMemoryRequestStreamP, _ironpdfengineproto_BytesResultStreamP__Output>;
|
|
1388
|
+
QPdf_Compression_CompressInMemory(options?: grpc.CallOptions): grpc.ClientDuplexStream<_ironpdfengineproto_QPdfCompressInMemoryRequestStreamP, _ironpdfengineproto_BytesResultStreamP__Output>;
|
|
1389
|
+
qPdfCompressionCompressInMemory(metadata: grpc.Metadata, options?: grpc.CallOptions): grpc.ClientDuplexStream<_ironpdfengineproto_QPdfCompressInMemoryRequestStreamP, _ironpdfengineproto_BytesResultStreamP__Output>;
|
|
1390
|
+
qPdfCompressionCompressInMemory(options?: grpc.CallOptions): grpc.ClientDuplexStream<_ironpdfengineproto_QPdfCompressInMemoryRequestStreamP, _ironpdfengineproto_BytesResultStreamP__Output>;
|
|
1391
|
+
|
|
1392
|
+
QPdf_Compression_CompressInMemoryFromId(argument: _ironpdfengineproto_QPdfCompressInMemoryRequestIdP, metadata: grpc.Metadata, options?: grpc.CallOptions): grpc.ClientReadableStream<_ironpdfengineproto_BytesResultStreamP__Output>;
|
|
1393
|
+
QPdf_Compression_CompressInMemoryFromId(argument: _ironpdfengineproto_QPdfCompressInMemoryRequestIdP, options?: grpc.CallOptions): grpc.ClientReadableStream<_ironpdfengineproto_BytesResultStreamP__Output>;
|
|
1394
|
+
qPdfCompressionCompressInMemoryFromId(argument: _ironpdfengineproto_QPdfCompressInMemoryRequestIdP, metadata: grpc.Metadata, options?: grpc.CallOptions): grpc.ClientReadableStream<_ironpdfengineproto_BytesResultStreamP__Output>;
|
|
1395
|
+
qPdfCompressionCompressInMemoryFromId(argument: _ironpdfengineproto_QPdfCompressInMemoryRequestIdP, options?: grpc.CallOptions): grpc.ClientReadableStream<_ironpdfengineproto_BytesResultStreamP__Output>;
|
|
1396
|
+
|
|
1385
1397
|
QPdf_Json_SaveAsJson(metadata: grpc.Metadata, options?: grpc.CallOptions): grpc.ClientDuplexStream<_ironpdfengineproto_QPdfSaveAsJsonRequestStreamP, _ironpdfengineproto_BytesResultStreamP__Output>;
|
|
1386
1398
|
QPdf_Json_SaveAsJson(options?: grpc.CallOptions): grpc.ClientDuplexStream<_ironpdfengineproto_QPdfSaveAsJsonRequestStreamP, _ironpdfengineproto_BytesResultStreamP__Output>;
|
|
1387
1399
|
qPdfJsonSaveAsJson(metadata: grpc.Metadata, options?: grpc.CallOptions): grpc.ClientDuplexStream<_ironpdfengineproto_QPdfSaveAsJsonRequestStreamP, _ironpdfengineproto_BytesResultStreamP__Output>;
|
|
@@ -1736,6 +1748,10 @@ export interface IronPdfServiceHandlers extends grpc.UntypedServiceImplementatio
|
|
|
1736
1748
|
|
|
1737
1749
|
QPdf_Compression_CompressAndSaveAsFromBytes: grpc.handleBidiStreamingCall<_ironpdfengineproto_QPdfCompressAndSaveAsFromBytesRequestStreamP__Output, _ironpdfengineproto_BytesResultStreamP>;
|
|
1738
1750
|
|
|
1751
|
+
QPdf_Compression_CompressInMemory: grpc.handleBidiStreamingCall<_ironpdfengineproto_QPdfCompressInMemoryRequestStreamP__Output, _ironpdfengineproto_BytesResultStreamP>;
|
|
1752
|
+
|
|
1753
|
+
QPdf_Compression_CompressInMemoryFromId: grpc.handleServerStreamingCall<_ironpdfengineproto_QPdfCompressInMemoryRequestIdP__Output, _ironpdfengineproto_BytesResultStreamP>;
|
|
1754
|
+
|
|
1739
1755
|
QPdf_Json_SaveAsJson: grpc.handleBidiStreamingCall<_ironpdfengineproto_QPdfSaveAsJsonRequestStreamP__Output, _ironpdfengineproto_BytesResultStreamP>;
|
|
1740
1756
|
|
|
1741
1757
|
QPdf_Json_ToJson: grpc.handleClientStreamingCall<_ironpdfengineproto_QPdfToJsonRequestStreamP__Output, _ironpdfengineproto_StringResultP>;
|
|
@@ -1897,6 +1913,8 @@ export interface IronPdfServiceDefinition extends grpc.ServiceDefinition {
|
|
|
1897
1913
|
Pdfium_Text_ReplaceText: MethodDefinition<_ironpdfengineproto_PdfiumReplaceTextRequestP, _ironpdfengineproto_EmptyResultP, _ironpdfengineproto_PdfiumReplaceTextRequestP__Output, _ironpdfengineproto_EmptyResultP__Output>
|
|
1898
1914
|
QPdf_Compression_CompressAndSaveAs: MethodDefinition<_ironpdfengineproto_QPdfCompressAndSaveAsRequestP, _ironpdfengineproto_BytesResultStreamP, _ironpdfengineproto_QPdfCompressAndSaveAsRequestP__Output, _ironpdfengineproto_BytesResultStreamP__Output>
|
|
1899
1915
|
QPdf_Compression_CompressAndSaveAsFromBytes: MethodDefinition<_ironpdfengineproto_QPdfCompressAndSaveAsFromBytesRequestStreamP, _ironpdfengineproto_BytesResultStreamP, _ironpdfengineproto_QPdfCompressAndSaveAsFromBytesRequestStreamP__Output, _ironpdfengineproto_BytesResultStreamP__Output>
|
|
1916
|
+
QPdf_Compression_CompressInMemory: MethodDefinition<_ironpdfengineproto_QPdfCompressInMemoryRequestStreamP, _ironpdfengineproto_BytesResultStreamP, _ironpdfengineproto_QPdfCompressInMemoryRequestStreamP__Output, _ironpdfengineproto_BytesResultStreamP__Output>
|
|
1917
|
+
QPdf_Compression_CompressInMemoryFromId: MethodDefinition<_ironpdfengineproto_QPdfCompressInMemoryRequestIdP, _ironpdfengineproto_BytesResultStreamP, _ironpdfengineproto_QPdfCompressInMemoryRequestIdP__Output, _ironpdfengineproto_BytesResultStreamP__Output>
|
|
1900
1918
|
QPdf_Json_SaveAsJson: MethodDefinition<_ironpdfengineproto_QPdfSaveAsJsonRequestStreamP, _ironpdfengineproto_BytesResultStreamP, _ironpdfengineproto_QPdfSaveAsJsonRequestStreamP__Output, _ironpdfengineproto_BytesResultStreamP__Output>
|
|
1901
1919
|
QPdf_Json_ToJson: MethodDefinition<_ironpdfengineproto_QPdfToJsonRequestStreamP, _ironpdfengineproto_StringResultP, _ironpdfengineproto_QPdfToJsonRequestStreamP__Output, _ironpdfengineproto_StringResultP__Output>
|
|
1902
1920
|
QPdf_Linearization_IsLinearized: MethodDefinition<_ironpdfengineproto_QPdfIsLinearizedRequestStreamP, _ironpdfengineproto_BooleanResultP, _ironpdfengineproto_QPdfIsLinearizedRequestStreamP__Output, _ironpdfengineproto_BooleanResultP__Output>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PdfDocumentP as _ironpdfengineproto_PdfDocumentP, PdfDocumentP__Output as _ironpdfengineproto_PdfDocumentP__Output } from '../ironpdfengineproto/PdfDocumentP';
|
|
2
|
+
export interface QPdfCompressInMemoryRequestIdP {
|
|
3
|
+
'document'?: (_ironpdfengineproto_PdfDocumentP | null);
|
|
4
|
+
'password'?: (string);
|
|
5
|
+
}
|
|
6
|
+
export interface QPdfCompressInMemoryRequestIdP__Output {
|
|
7
|
+
'document'?: (_ironpdfengineproto_PdfDocumentP__Output);
|
|
8
|
+
'password'?: (string);
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=QPdfCompressInMemoryRequestIdP.d.ts.map
|
package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressInMemoryRequestIdP.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QPdfCompressInMemoryRequestIdP.d.ts","sourceRoot":"","sources":["QPdfCompressInMemoryRequestIdP.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,IAAI,gCAAgC,EAAE,oBAAoB,IAAI,wCAAwC,EAAE,MAAM,oCAAoC,CAAC;AAE7K,MAAM,WAAW,8BAA8B;IAC7C,UAAU,CAAC,EAAE,CAAC,gCAAgC,GAAG,IAAI,CAAC,CAAC;IACvD,UAAU,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;CACvB;AAED,MAAM,WAAW,sCAAsC;IACrD,UAAU,CAAC,EAAE,CAAC,wCAAwC,CAAC,CAAC;IACxD,UAAU,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;CACvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QPdfCompressInMemoryRequestIdP.js","sourceRoot":"","sources":["QPdfCompressInMemoryRequestIdP.ts"],"names":[],"mappings":";AAAA,kEAAkE"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Original file: src/internal/IronPdfEngine.ProtoFiles/qpdf.proto
|
|
2
|
+
|
|
3
|
+
import type { PdfDocumentP as _ironpdfengineproto_PdfDocumentP, PdfDocumentP__Output as _ironpdfengineproto_PdfDocumentP__Output } from '../ironpdfengineproto/PdfDocumentP';
|
|
4
|
+
|
|
5
|
+
export interface QPdfCompressInMemoryRequestIdP {
|
|
6
|
+
'document'?: (_ironpdfengineproto_PdfDocumentP | null);
|
|
7
|
+
'password'?: (string);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface QPdfCompressInMemoryRequestIdP__Output {
|
|
11
|
+
'document'?: (_ironpdfengineproto_PdfDocumentP__Output);
|
|
12
|
+
'password'?: (string);
|
|
13
|
+
}
|
package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressInMemoryRequestStreamP.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
export interface _ironpdfengineproto_QPdfCompressInMemoryRequestStreamP_InfoP {
|
|
4
|
+
'password'?: (string);
|
|
5
|
+
}
|
|
6
|
+
export interface _ironpdfengineproto_QPdfCompressInMemoryRequestStreamP_InfoP__Output {
|
|
7
|
+
'password'?: (string);
|
|
8
|
+
}
|
|
9
|
+
export interface QPdfCompressInMemoryRequestStreamP {
|
|
10
|
+
'info'?: (_ironpdfengineproto_QPdfCompressInMemoryRequestStreamP_InfoP | null);
|
|
11
|
+
'pdfBytesChunk'?: (Buffer | Uint8Array | string);
|
|
12
|
+
'request'?: "info" | "pdfBytesChunk";
|
|
13
|
+
}
|
|
14
|
+
export interface QPdfCompressInMemoryRequestStreamP__Output {
|
|
15
|
+
'info'?: (_ironpdfengineproto_QPdfCompressInMemoryRequestStreamP_InfoP__Output);
|
|
16
|
+
'pdfBytesChunk'?: (Buffer);
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=QPdfCompressInMemoryRequestStreamP.d.ts.map
|
package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressInMemoryRequestStreamP.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QPdfCompressInMemoryRequestStreamP.d.ts","sourceRoot":"","sources":["QPdfCompressInMemoryRequestStreamP.ts"],"names":[],"mappings":";;AAGA,MAAM,WAAW,4DAA4D;IAC3E,UAAU,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;CACvB;AAED,MAAM,WAAW,oEAAoE;IACnF,UAAU,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;CACvB;AAED,MAAM,WAAW,kCAAkC;IACjD,MAAM,CAAC,EAAE,CAAC,4DAA4D,GAAG,IAAI,CAAC,CAAC;IAC/E,eAAe,CAAC,EAAE,CAAC,MAAM,GAAG,UAAU,GAAG,MAAM,CAAC,CAAC;IACjD,SAAS,CAAC,EAAE,MAAM,GAAC,eAAe,CAAC;CACpC;AAED,MAAM,WAAW,0CAA0C;IACzD,MAAM,CAAC,EAAE,CAAC,oEAAoE,CAAC,CAAC;IAChF,eAAe,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;CAC5B"}
|
package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressInMemoryRequestStreamP.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QPdfCompressInMemoryRequestStreamP.js","sourceRoot":"","sources":["QPdfCompressInMemoryRequestStreamP.ts"],"names":[],"mappings":";AAAA,kEAAkE"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Original file: src/internal/IronPdfEngine.ProtoFiles/qpdf.proto
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export interface _ironpdfengineproto_QPdfCompressInMemoryRequestStreamP_InfoP {
|
|
5
|
+
'password'?: (string);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface _ironpdfengineproto_QPdfCompressInMemoryRequestStreamP_InfoP__Output {
|
|
9
|
+
'password'?: (string);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface QPdfCompressInMemoryRequestStreamP {
|
|
13
|
+
'info'?: (_ironpdfengineproto_QPdfCompressInMemoryRequestStreamP_InfoP | null);
|
|
14
|
+
'pdfBytesChunk'?: (Buffer | Uint8Array | string);
|
|
15
|
+
'request'?: "info"|"pdfBytesChunk";
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface QPdfCompressInMemoryRequestStreamP__Output {
|
|
19
|
+
'info'?: (_ironpdfengineproto_QPdfCompressInMemoryRequestStreamP_InfoP__Output);
|
|
20
|
+
'pdfBytesChunk'?: (Buffer);
|
|
21
|
+
}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
4
|
+
import { Readable } from "stream";
|
|
1
5
|
export declare function compressImage(id: string, imageQuality: number, scaleToVisibleSize?: boolean): Promise<void>;
|
|
2
6
|
export declare function compressStructTree(id: string): Promise<void>;
|
|
7
|
+
export declare function compressInMemory(id: string, imageQuality?: number): Promise<Buffer>;
|
|
8
|
+
export declare function compressInMemoryStream(id: string, imageQuality?: number): Promise<Readable>;
|
|
3
9
|
//# sourceMappingURL=compress.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compress.d.ts","sourceRoot":"","sources":["compress.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"compress.d.ts","sourceRoot":"","sources":["compress.ts"],"names":[],"mappings":";;;AAOA,OAAO,EAAc,QAAQ,EAAC,MAAM,QAAQ,CAAC;AAE7C,wBAAsB,aAAa,CAClC,EAAE,EAAE,MAAM,EACV,YAAY,EAAE,MAAM,EACpB,kBAAkB,UAAQ,GACxB,OAAO,CAAC,IAAI,CAAC,CAwBf;AAED,wBAAsB,kBAAkB,CACvC,EAAE,EAAE,MAAM,GACR,OAAO,CAAC,IAAI,CAAC,CAsBf;AAED,wBAAsB,gBAAgB,CACrC,EAAE,EAAE,MAAM,EACV,YAAY,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,MAAM,CAAC,CAkCjB;AAED,wBAAsB,sBAAsB,CAC3C,EAAE,EAAE,MAAM,EACV,YAAY,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,QAAQ,CAAC,CAiCnB"}
|
|
@@ -9,9 +9,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.compressStructTree = exports.compressImage = void 0;
|
|
12
|
+
exports.compressInMemoryStream = exports.compressInMemory = exports.compressStructTree = exports.compressImage = void 0;
|
|
13
13
|
const access_1 = require("../../access");
|
|
14
14
|
const util_1 = require("../util");
|
|
15
|
+
const stream_1 = require("stream");
|
|
15
16
|
function compressImage(id, imageQuality, scaleToVisibleSize = false) {
|
|
16
17
|
return __awaiter(this, void 0, void 0, function* () {
|
|
17
18
|
const client = yield access_1.Access.ensureConnection();
|
|
@@ -52,4 +53,53 @@ function compressStructTree(id) {
|
|
|
52
53
|
});
|
|
53
54
|
}
|
|
54
55
|
exports.compressStructTree = compressStructTree;
|
|
56
|
+
function compressInMemory(id, imageQuality) {
|
|
57
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
+
const client = yield access_1.Access.ensureConnection();
|
|
59
|
+
return new Promise((resolve, reject) => {
|
|
60
|
+
const request = Object.assign({ document: { documentId: id }, outputPath: "", password: "" }, (imageQuality !== undefined ? { jpeg: imageQuality } : {}));
|
|
61
|
+
const stream = client.QPdf_Compression_CompressAndSaveAs(request);
|
|
62
|
+
const buffers = [];
|
|
63
|
+
stream.on("data", (data) => {
|
|
64
|
+
if (data.exception) {
|
|
65
|
+
reject(`${data.exception.message}/n${data.exception.remoteStackTrace}`);
|
|
66
|
+
}
|
|
67
|
+
else if (data.resultChunk) {
|
|
68
|
+
buffers.push(data.resultChunk);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
stream.on("error", (err) => {
|
|
72
|
+
reject(`${err.name}/n${err.message}`);
|
|
73
|
+
});
|
|
74
|
+
stream.on("end", () => {
|
|
75
|
+
resolve(Buffer.concat(buffers));
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
exports.compressInMemory = compressInMemory;
|
|
81
|
+
function compressInMemoryStream(id, imageQuality) {
|
|
82
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
+
const client = yield access_1.Access.ensureConnection();
|
|
84
|
+
const passThrough = new stream_1.PassThrough();
|
|
85
|
+
const request = Object.assign({ document: { documentId: id }, outputPath: "", password: "" }, (imageQuality !== undefined ? { jpeg: imageQuality } : {}));
|
|
86
|
+
const stream = client.QPdf_Compression_CompressAndSaveAs(request);
|
|
87
|
+
stream.on("data", (data) => {
|
|
88
|
+
if (data.exception) {
|
|
89
|
+
passThrough.destroy(new Error(`${data.exception.message}/n${data.exception.remoteStackTrace}`));
|
|
90
|
+
}
|
|
91
|
+
else if (data.resultChunk) {
|
|
92
|
+
passThrough.write(data.resultChunk);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
stream.on("error", (err) => {
|
|
96
|
+
passThrough.destroy(err);
|
|
97
|
+
});
|
|
98
|
+
stream.on("end", () => {
|
|
99
|
+
passThrough.end();
|
|
100
|
+
});
|
|
101
|
+
return passThrough;
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
exports.compressInMemoryStream = compressInMemoryStream;
|
|
55
105
|
//# sourceMappingURL=compress.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compress.js","sourceRoot":"","sources":["compress.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"compress.js","sourceRoot":"","sources":["compress.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,yCAAoC;AAGpC,kCAAmD;AACnD,mCAA6C;AAE7C,SAAsB,aAAa,CAClC,EAAU,EACV,YAAoB,EACpB,kBAA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1
|
+
import * as grpc from "@grpc/grpc-js";
|
|
1
2
|
import {ServiceError} from "@grpc/grpc-js";
|
|
2
3
|
import {IronPdfServiceClient} from "../../generated_proto/ironpdfengineproto/IronPdfService";
|
|
3
4
|
import {Access} from "../../access";
|
|
4
5
|
import {EmptyResultP__Output} from "../../generated_proto/ironpdfengineproto/EmptyResultP";
|
|
6
|
+
import {BytesResultStreamP__Output} from "../../generated_proto/ironpdfengineproto/BytesResultStreamP";
|
|
5
7
|
import {handleEmptyResultP__Output} from "../util";
|
|
8
|
+
import {PassThrough, Readable} from "stream";
|
|
6
9
|
|
|
7
10
|
export async function compressImage(
|
|
8
11
|
id: string,
|
|
@@ -60,3 +63,79 @@ export async function compressStructTree(
|
|
|
60
63
|
);
|
|
61
64
|
}
|
|
62
65
|
|
|
66
|
+
export async function compressInMemory(
|
|
67
|
+
id: string,
|
|
68
|
+
imageQuality?: number
|
|
69
|
+
): Promise<Buffer> {
|
|
70
|
+
const client: IronPdfServiceClient = await Access.ensureConnection();
|
|
71
|
+
|
|
72
|
+
return new Promise(
|
|
73
|
+
(resolve: (_: Buffer) => void, reject: (errorMsg: string) => void) => {
|
|
74
|
+
const request = {
|
|
75
|
+
document: {documentId: id},
|
|
76
|
+
outputPath: "",
|
|
77
|
+
password: "",
|
|
78
|
+
...(imageQuality !== undefined ? {jpeg: imageQuality} : {}),
|
|
79
|
+
};
|
|
80
|
+
const stream: grpc.ClientReadableStream<BytesResultStreamP__Output> =
|
|
81
|
+
client.QPdf_Compression_CompressAndSaveAs(request);
|
|
82
|
+
|
|
83
|
+
const buffers: Buffer[] = [];
|
|
84
|
+
stream.on("data", (data: BytesResultStreamP__Output) => {
|
|
85
|
+
if (data.exception) {
|
|
86
|
+
reject(
|
|
87
|
+
`${data.exception.message}/n${data.exception.remoteStackTrace}`
|
|
88
|
+
);
|
|
89
|
+
} else if (data.resultChunk) {
|
|
90
|
+
buffers.push(data.resultChunk);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
stream.on("error", (err: Error) => {
|
|
95
|
+
reject(`${err.name}/n${err.message}`);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
stream.on("end", () => {
|
|
99
|
+
resolve(Buffer.concat(buffers));
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export async function compressInMemoryStream(
|
|
106
|
+
id: string,
|
|
107
|
+
imageQuality?: number
|
|
108
|
+
): Promise<Readable> {
|
|
109
|
+
const client: IronPdfServiceClient = await Access.ensureConnection();
|
|
110
|
+
|
|
111
|
+
const passThrough = new PassThrough();
|
|
112
|
+
|
|
113
|
+
const request = {
|
|
114
|
+
document: {documentId: id},
|
|
115
|
+
outputPath: "",
|
|
116
|
+
password: "",
|
|
117
|
+
...(imageQuality !== undefined ? {jpeg: imageQuality} : {}),
|
|
118
|
+
};
|
|
119
|
+
const stream: grpc.ClientReadableStream<BytesResultStreamP__Output> =
|
|
120
|
+
client.QPdf_Compression_CompressAndSaveAs(request);
|
|
121
|
+
|
|
122
|
+
stream.on("data", (data: BytesResultStreamP__Output) => {
|
|
123
|
+
if (data.exception) {
|
|
124
|
+
passThrough.destroy(
|
|
125
|
+
new Error(`${data.exception.message}/n${data.exception.remoteStackTrace}`)
|
|
126
|
+
);
|
|
127
|
+
} else if (data.resultChunk) {
|
|
128
|
+
passThrough.write(data.resultChunk);
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
stream.on("error", (err: Error) => {
|
|
133
|
+
passThrough.destroy(err);
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
stream.on("end", () => {
|
|
137
|
+
passThrough.end();
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
return passThrough;
|
|
141
|
+
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
3
4
|
import { Buffer } from "buffer";
|
|
4
5
|
import { BarcodeStampOptions, BarcodeType, ChangeTrackingModes, ChromePdfRenderOptions, DigitalSignature, HtmlAffix, HtmlFilePath, HtmlStampOptions, HtmlString, HttpLoginCredentials, ImageBuffer, ImageFilePath, ImageStampOptions, ImageToPdfOptions, ImageType, PageInfo, PageRotation, PdfInput, PdfPageSelection, PdfPaperSize, PdfPassword, PdfPermission, SaveOptions, TextAffix, TextStampOptions } from "./types";
|
|
6
|
+
import { Readable } from "stream";
|
|
5
7
|
import { PdfAVersions, PdfUAVersions } from "../internal/grpc_layer/pdfium/pdfa";
|
|
6
8
|
import { NaturalLanguages } from "./naturalLanguages";
|
|
7
9
|
/**
|
|
@@ -165,6 +167,21 @@ export declare class PdfDocument {
|
|
|
165
167
|
* Removing the "structure tree" of a complicated document can negatively impact text selection.
|
|
166
168
|
*/
|
|
167
169
|
compressStructTree(): Promise<void>;
|
|
170
|
+
/**
|
|
171
|
+
* Compress the PDF and return the result as a Buffer (byte array).
|
|
172
|
+
* Uses QPdf compression which can significantly reduce file size.
|
|
173
|
+
* @param imageQuality Optional JPEG quality (1-100) for image compression. If omitted, default compression is applied.
|
|
174
|
+
* @returns A Promise resolving to a Buffer containing the compressed PDF bytes.
|
|
175
|
+
*/
|
|
176
|
+
compressPdfToBytes(imageQuality?: number): Promise<Buffer>;
|
|
177
|
+
/**
|
|
178
|
+
* Compress the PDF and return the result as a Readable stream.
|
|
179
|
+
* Uses QPdf compression which can significantly reduce file size.
|
|
180
|
+
* Useful for piping directly to file streams or HTTP responses without buffering the entire PDF in memory.
|
|
181
|
+
* @param imageQuality Optional JPEG quality (1-100) for image compression. If omitted, default compression is applied.
|
|
182
|
+
* @returns A Promise resolving to a Readable stream of the compressed PDF bytes.
|
|
183
|
+
*/
|
|
184
|
+
compressPdfToStream(imageQuality?: number): Promise<Readable>;
|
|
168
185
|
/**
|
|
169
186
|
* Gets information of all pages in the PdfDocument
|
|
170
187
|
*/
|
|
@@ -555,6 +572,19 @@ export declare class PdfDocument {
|
|
|
555
572
|
* Removing the "structure tree" of a complicated document can negatively impact text selection.
|
|
556
573
|
*/
|
|
557
574
|
private internal_compressStructTree;
|
|
575
|
+
/**
|
|
576
|
+
* Compress the PDF and return the result as a Buffer (byte array).
|
|
577
|
+
* Uses QPdf compression which can significantly reduce file size.
|
|
578
|
+
* @param imageQuality Optional JPEG quality (1-100) for image compression. If omitted, default compression is applied.
|
|
579
|
+
*/
|
|
580
|
+
private internal_compressPdfToBytes;
|
|
581
|
+
/**
|
|
582
|
+
* Compress the PDF and return the result as a Readable stream.
|
|
583
|
+
* Uses QPdf compression which can significantly reduce file size.
|
|
584
|
+
* Useful for piping directly to file streams or HTTP responses without buffering the entire PDF in memory.
|
|
585
|
+
* @param imageQuality Optional JPEG quality (1-100) for image compression. If omitted, default compression is applied.
|
|
586
|
+
*/
|
|
587
|
+
private internal_compressPdfToStream;
|
|
558
588
|
/**
|
|
559
589
|
* Gets information of all pages in the PdfDocument
|
|
560
590
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pdfDocument.d.ts","sourceRoot":"","sources":["pdfDocument.ts"],"names":[],"mappings":"
|
|
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,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;AA0CjB,OAAO,E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G;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"}
|
|
@@ -241,6 +241,35 @@ class PdfDocument {
|
|
|
241
241
|
return this.internal_compressStructTree();
|
|
242
242
|
});
|
|
243
243
|
}
|
|
244
|
+
/**
|
|
245
|
+
* Compress the PDF and return the result as a Buffer (byte array).
|
|
246
|
+
* Uses QPdf compression which can significantly reduce file size.
|
|
247
|
+
* @param imageQuality Optional JPEG quality (1-100) for image compression. If omitted, default compression is applied.
|
|
248
|
+
* @returns A Promise resolving to a Buffer containing the compressed PDF bytes.
|
|
249
|
+
*/
|
|
250
|
+
compressPdfToBytes(imageQuality) {
|
|
251
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
252
|
+
return yield zod_1.z.function()
|
|
253
|
+
.args(typeSchema_1.numberSchema.optional())
|
|
254
|
+
.returns(zod_1.z.promise(zod_1.z.instanceof(buffer_1.Buffer)))
|
|
255
|
+
.implement(this.internal_compressPdfToBytes.bind(this))(imageQuality);
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Compress the PDF and return the result as a Readable stream.
|
|
260
|
+
* Uses QPdf compression which can significantly reduce file size.
|
|
261
|
+
* Useful for piping directly to file streams or HTTP responses without buffering the entire PDF in memory.
|
|
262
|
+
* @param imageQuality Optional JPEG quality (1-100) for image compression. If omitted, default compression is applied.
|
|
263
|
+
* @returns A Promise resolving to a Readable stream of the compressed PDF bytes.
|
|
264
|
+
*/
|
|
265
|
+
compressPdfToStream(imageQuality) {
|
|
266
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
267
|
+
return yield zod_1.z.function()
|
|
268
|
+
.args(typeSchema_1.numberSchema.optional())
|
|
269
|
+
.returns(zod_1.z.promise(zod_1.z.any()))
|
|
270
|
+
.implement(this.internal_compressPdfToStream.bind(this))(imageQuality);
|
|
271
|
+
});
|
|
272
|
+
}
|
|
244
273
|
//#endregion
|
|
245
274
|
//#region page
|
|
246
275
|
/**
|
|
@@ -1054,6 +1083,31 @@ class PdfDocument {
|
|
|
1054
1083
|
return yield (0, compress_1.compressStructTree)(yield this.internal_getId());
|
|
1055
1084
|
});
|
|
1056
1085
|
}
|
|
1086
|
+
/**
|
|
1087
|
+
* Compress the PDF and return the result as a Buffer (byte array).
|
|
1088
|
+
* Uses QPdf compression which can significantly reduce file size.
|
|
1089
|
+
* @param imageQuality Optional JPEG quality (1-100) for image compression. If omitted, default compression is applied.
|
|
1090
|
+
*/
|
|
1091
|
+
internal_compressPdfToBytes(imageQuality) {
|
|
1092
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1093
|
+
if (imageQuality !== undefined && (imageQuality < 1 || imageQuality > 100))
|
|
1094
|
+
throw new Error(`Invalid quality specifier (${imageQuality}) when compressing PDF. Quality must be between 1 and 100.`);
|
|
1095
|
+
return yield (0, compress_1.compressInMemory)(yield this.internal_getId(), imageQuality);
|
|
1096
|
+
});
|
|
1097
|
+
}
|
|
1098
|
+
/**
|
|
1099
|
+
* Compress the PDF and return the result as a Readable stream.
|
|
1100
|
+
* Uses QPdf compression which can significantly reduce file size.
|
|
1101
|
+
* Useful for piping directly to file streams or HTTP responses without buffering the entire PDF in memory.
|
|
1102
|
+
* @param imageQuality Optional JPEG quality (1-100) for image compression. If omitted, default compression is applied.
|
|
1103
|
+
*/
|
|
1104
|
+
internal_compressPdfToStream(imageQuality) {
|
|
1105
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1106
|
+
if (imageQuality !== undefined && (imageQuality < 1 || imageQuality > 100))
|
|
1107
|
+
throw new Error(`Invalid quality specifier (${imageQuality}) when compressing PDF. Quality must be between 1 and 100.`);
|
|
1108
|
+
return yield (0, compress_1.compressInMemoryStream)(yield this.internal_getId(), imageQuality);
|
|
1109
|
+
});
|
|
1110
|
+
}
|
|
1057
1111
|
//#endregion
|
|
1058
1112
|
//#region page
|
|
1059
1113
|
/**
|