@ironsoftware/ironpdf 2024.2.1 → 2024.4.2
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 +4 -3
- package/src/internal/IronPdfEngine.ProtoFiles/chrome_render.proto +2 -1
- package/src/internal/IronPdfEngine.ProtoFiles/iron_pdf_service.proto +1 -0
- package/src/internal/IronPdfEngine.ProtoFiles/pdfium_signature.proto +1 -0
- package/src/internal/IronPdfEngine.ProtoFiles/pdfium_text.proto +7 -0
- package/src/internal/generated_proto/iron_pdf_service.d.ts +1 -0
- package/src/internal/generated_proto/iron_pdf_service.d.ts.map +1 -1
- package/src/internal/generated_proto/iron_pdf_service.ts +1 -0
- package/src/internal/generated_proto/ironpdfengineproto/ChromeTextHeaderFooterP.d.ts +3 -3
- package/src/internal/generated_proto/ironpdfengineproto/ChromeTextHeaderFooterP.d.ts.map +1 -1
- package/src/internal/generated_proto/ironpdfengineproto/ChromeTextHeaderFooterP.ts +3 -3
- package/src/internal/generated_proto/ironpdfengineproto/IronPdfService.d.ts +11 -0
- package/src/internal/generated_proto/ironpdfengineproto/IronPdfService.d.ts.map +1 -1
- package/src/internal/generated_proto/ironpdfengineproto/IronPdfService.ts +13 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumRedactTextRequestP.d.ts +14 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumRedactTextRequestP.d.ts.map +1 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumRedactTextRequestP.js +4 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumRedactTextRequestP.js.map +1 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumRedactTextRequestP.ts +17 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumSignRequestStreamP.d.ts +3 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumSignRequestStreamP.d.ts.map +1 -1
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumSignRequestStreamP.ts +3 -0
- package/src/internal/grpc_layer/chrome/stamp.d.ts +3 -3
- package/src/internal/grpc_layer/chrome/stamp.d.ts.map +1 -1
- package/src/internal/grpc_layer/chrome/stamp.js +3 -3
- package/src/internal/grpc_layer/chrome/stamp.js.map +1 -1
- package/src/internal/grpc_layer/chrome/stamp.ts +6 -6
- package/src/internal/grpc_layer/pdfium/page.d.ts +1 -1
- package/src/internal/grpc_layer/pdfium/page.d.ts.map +1 -1
- package/src/internal/grpc_layer/pdfium/page.js +1 -1
- package/src/internal/grpc_layer/pdfium/page.js.map +1 -1
- package/src/internal/grpc_layer/pdfium/page.ts +2 -3
- package/src/internal/zod/affixSchema.d.ts +6 -0
- package/src/internal/zod/affixSchema.d.ts.map +1 -0
- package/src/internal/zod/affixSchema.js +36 -0
- package/src/internal/zod/affixSchema.js.map +1 -0
- package/src/internal/zod/affixSchema.ts +35 -0
- package/src/internal/zod/imageSchema.d.ts +6 -0
- package/src/internal/zod/imageSchema.d.ts.map +1 -0
- package/src/internal/zod/imageSchema.js +13 -0
- package/src/internal/zod/imageSchema.js.map +1 -0
- package/src/internal/zod/imageSchema.ts +18 -0
- package/src/internal/zod/ironpdfglobalconfigSchema.d.ts +4 -0
- package/src/internal/zod/ironpdfglobalconfigSchema.d.ts.map +1 -0
- package/src/internal/zod/ironpdfglobalconfigSchema.js +34 -0
- package/src/internal/zod/ironpdfglobalconfigSchema.js.map +1 -0
- package/src/internal/zod/ironpdfglobalconfigSchema.ts +32 -0
- package/src/internal/zod/pageSchema.d.ts +5 -0
- package/src/internal/zod/pageSchema.d.ts.map +1 -0
- package/src/internal/zod/pageSchema.js +18 -0
- package/src/internal/zod/pageSchema.js.map +1 -0
- package/src/internal/zod/pageSchema.ts +17 -0
- package/src/internal/zod/paperSchema.d.ts +8 -0
- package/src/internal/zod/paperSchema.d.ts.map +1 -0
- package/src/internal/zod/paperSchema.js +18 -0
- package/src/internal/zod/paperSchema.js.map +1 -0
- package/src/internal/zod/paperSchema.ts +22 -0
- package/src/internal/zod/pdfDocumentSchema.d.ts +4 -0
- package/src/internal/zod/pdfDocumentSchema.d.ts.map +1 -0
- package/src/internal/zod/pdfDocumentSchema.js +7 -0
- package/src/internal/zod/pdfDocumentSchema.js.map +1 -0
- package/src/internal/zod/pdfDocumentSchema.ts +6 -0
- package/src/internal/zod/renderSchema.d.ts +14 -0
- package/src/internal/zod/renderSchema.d.ts.map +1 -0
- package/src/internal/zod/renderSchema.js +88 -0
- package/src/internal/zod/renderSchema.js.map +1 -0
- package/src/internal/zod/renderSchema.ts +107 -0
- package/src/internal/zod/securitySchema.d.ts +4 -0
- package/src/internal/zod/securitySchema.d.ts.map +1 -0
- package/src/internal/zod/securitySchema.js +17 -0
- package/src/internal/zod/securitySchema.js.map +1 -0
- package/src/internal/zod/securitySchema.ts +15 -0
- package/src/internal/zod/signatureSchema.d.ts +5 -0
- package/src/internal/zod/signatureSchema.d.ts.map +1 -0
- package/src/internal/zod/signatureSchema.js +22 -0
- package/src/internal/zod/signatureSchema.js.map +1 -0
- package/src/internal/zod/signatureSchema.ts +22 -0
- package/src/internal/zod/stampSchema.d.ts +155 -0
- package/src/internal/zod/stampSchema.d.ts.map +1 -0
- package/src/internal/zod/stampSchema.js +79 -0
- package/src/internal/zod/stampSchema.js.map +1 -0
- package/src/internal/zod/stampSchema.ts +87 -0
- package/src/internal/zod/typeSchema.d.ts +38 -0
- package/src/internal/zod/typeSchema.d.ts.map +1 -0
- package/src/internal/zod/typeSchema.js +74 -0
- package/src/internal/zod/typeSchema.js.map +1 -0
- package/src/internal/zod/typeSchema.ts +120 -0
- package/src/public/affix.d.ts +5 -5
- package/src/public/affix.ts +5 -5
- package/src/public/image.d.ts +1 -9
- package/src/public/image.d.ts.map +1 -1
- package/src/public/image.js.map +1 -1
- package/src/public/image.ts +1 -9
- package/src/public/ironpdfglobalconfig.d.ts +8 -8
- package/src/public/ironpdfglobalconfig.ts +8 -8
- package/src/public/pdfDocument.d.ts +354 -43
- package/src/public/pdfDocument.d.ts.map +1 -1
- package/src/public/pdfDocument.js +835 -150
- package/src/public/pdfDocument.js.map +1 -1
- package/src/public/pdfDocument.ts +1125 -197
- package/src/public/pdfGenerator.d.ts +4 -4
- package/src/public/pdfGenerator.ts +4 -4
- package/src/public/render.d.ts +5 -5
- package/src/public/render.ts +5 -5
- package/src/public/stamp.d.ts +10 -10
- package/src/public/stamp.ts +11 -11
- package/src/public/types.d.ts +7 -7
- package/src/public/types.d.ts.map +1 -1
- package/src/public/types.js.map +1 -1
- package/src/public/types.ts +7 -8
|
@@ -1,27 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -38,36 +15,742 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
38
15
|
exports.PdfDocument = void 0;
|
|
39
16
|
const buffer_1 = require("buffer");
|
|
40
17
|
const types_1 = require("./types");
|
|
41
|
-
const
|
|
18
|
+
const typeSchema_1 = require("../internal/zod/typeSchema");
|
|
19
|
+
const zod_1 = require("zod");
|
|
20
|
+
const securitySchema_1 = require("../internal/zod/securitySchema");
|
|
21
|
+
const pdfDocumentSchema_1 = require("../internal/zod/pdfDocumentSchema");
|
|
22
|
+
const stampSchema_1 = require("../internal/zod/stampSchema");
|
|
23
|
+
const affixSchema_1 = require("../internal/zod/affixSchema");
|
|
24
|
+
const signatureSchema_1 = require("../internal/zod/signatureSchema");
|
|
25
|
+
const imageSchema_1 = require("../internal/zod/imageSchema");
|
|
26
|
+
const paperSchema_1 = require("../internal/zod/paperSchema");
|
|
27
|
+
const pageSchema_1 = require("../internal/zod/pageSchema");
|
|
28
|
+
const renderSchema_1 = require("../internal/zod/renderSchema");
|
|
42
29
|
const util_1 = require("../internal/grpc_layer/util");
|
|
43
|
-
const
|
|
30
|
+
const fs_1 = __importDefault(require("fs"));
|
|
44
31
|
const render_1 = require("../internal/grpc_layer/chrome/render");
|
|
32
|
+
const io_1 = require("../internal/grpc_layer/pdfium/io");
|
|
33
|
+
const access_1 = require("../internal/access");
|
|
45
34
|
const image_1 = require("../internal/grpc_layer/chrome/image");
|
|
35
|
+
const compress_1 = require("../internal/grpc_layer/pdfium/compress");
|
|
36
|
+
const page_1 = require("../internal/grpc_layer/pdfium/page");
|
|
46
37
|
const image_2 = require("../internal/grpc_layer/pdfium/image");
|
|
47
38
|
const jimp_1 = __importDefault(require("jimp"));
|
|
48
|
-
const
|
|
49
|
-
const security_1 = require("../internal/grpc_layer/pdfium/security");
|
|
50
|
-
const stamp_1 = require("../internal/grpc_layer/chrome/stamp");
|
|
39
|
+
const text_1 = require("../internal/grpc_layer/pdfium/text");
|
|
51
40
|
const pdfa_1 = require("../internal/grpc_layer/pdfium/pdfa");
|
|
52
|
-
const
|
|
41
|
+
const metadata_1 = require("../internal/grpc_layer/pdfium/metadata");
|
|
53
42
|
const signing_1 = require("../internal/grpc_layer/pdfium/signing");
|
|
54
43
|
const headerFooter_1 = require("../internal/grpc_layer/pdfium/headerFooter");
|
|
44
|
+
const stamp_1 = require("../internal/grpc_layer/chrome/stamp");
|
|
55
45
|
const BackgroundForeground_1 = require("../internal/grpc_layer/pdfium/BackgroundForeground");
|
|
56
|
-
const
|
|
57
|
-
const metadata_1 = require("../internal/grpc_layer/pdfium/metadata");
|
|
58
|
-
const access_1 = require("../internal/access");
|
|
46
|
+
const security_1 = require("../internal/grpc_layer/pdfium/security");
|
|
59
47
|
/**
|
|
60
48
|
* Represents a PDF document. Allows: loading, editing, manipulating, merging, signing printing and saving PDFs.
|
|
61
49
|
*
|
|
62
50
|
* @remark Make sure that you call {@link PdfDocument.close} or {@link cleanUp} to free the memory, when you stop using the PdfDocument object.
|
|
63
51
|
*/
|
|
64
52
|
class PdfDocument {
|
|
53
|
+
//#region io
|
|
54
|
+
/**
|
|
55
|
+
* Open or Create a PdfDocument from a {@link PdfInput}
|
|
56
|
+
* @param pdfInput {@link PdfInput}
|
|
57
|
+
* @param options including {@link PdfPassword} {@link ChromePdfRenderOptions} {@link HttpLoginCredentials} mainHtmlFile
|
|
58
|
+
*/
|
|
59
|
+
static open(pdfInput, options) {
|
|
60
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
return zod_1.z.function()
|
|
62
|
+
.args(typeSchema_1.pdfInputSchema, zod_1.z.object({
|
|
63
|
+
password: typeSchema_1.pdfPasswordSchema.optional(),
|
|
64
|
+
renderOptions: renderSchema_1.chromePdfRenderOptionsSchema.optional(),
|
|
65
|
+
httpLoginCredentials: renderSchema_1.httpLoginCredentialsSchema.optional(),
|
|
66
|
+
mainHtmlFile: typeSchema_1.stringSchema.optional(),
|
|
67
|
+
trackChanges: typeSchema_1.changeTrackingModesSchema.optional(),
|
|
68
|
+
}).optional())
|
|
69
|
+
.returns(zod_1.z.promise(pdfDocumentSchema_1.pdfDocumentSchema))
|
|
70
|
+
.implement(this.internal_open.bind(this))(pdfInput, options);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Open a PdfDocument from .pdf file
|
|
75
|
+
* @param pdfFilePath A path to .pdf file
|
|
76
|
+
* @param Optionally track changes to the document (for use with incremental saves)
|
|
77
|
+
*/
|
|
78
|
+
static fromFile(pdfFilePath, trackChanges) {
|
|
79
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
+
return zod_1.z.function()
|
|
81
|
+
.args(typeSchema_1.pdfFilePathSchema, typeSchema_1.changeTrackingModesSchema.optional())
|
|
82
|
+
.returns(zod_1.z.promise(pdfDocumentSchema_1.pdfDocumentSchema))
|
|
83
|
+
.implement(this.internal_fromFile.bind(this))(pdfFilePath, trackChanges);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Create a PdfDocument from an Url
|
|
88
|
+
* @param url A website Url
|
|
89
|
+
* @param options including {@link ChromePdfRenderOptions}
|
|
90
|
+
*/
|
|
91
|
+
static fromUrl(url, options) {
|
|
92
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
+
return zod_1.z.function()
|
|
94
|
+
.args(zod_1.z.union([typeSchema_1.urlSchema, typeSchema_1.stringSchema]), zod_1.z.object({
|
|
95
|
+
renderOptions: renderSchema_1.chromePdfRenderOptionsSchema.optional(),
|
|
96
|
+
}).optional())
|
|
97
|
+
.returns(zod_1.z.promise(pdfDocumentSchema_1.pdfDocumentSchema))
|
|
98
|
+
.implement(this.internal_fromUrl.bind(this))(url, options);
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Creates a PDF file from a local Zip file, and returns it as a {@link PdfDocument}.
|
|
103
|
+
* IronPDF is a W3C standards compliant HTML rendering based on Google's Chromium browser.
|
|
104
|
+
* If your output PDF does not look as expected:
|
|
105
|
+
*
|
|
106
|
+
* - Validate your HTML file using https://validator.w3.org/ & CSS https://jigsaw.w3.org/css-validator/
|
|
107
|
+
*
|
|
108
|
+
* - To debug HTML, view the file in Chrome web browser's print preview which will work almost exactly as IronPDF.
|
|
109
|
+
*
|
|
110
|
+
* - Read our detailed documentation on pixel perfect HTML to PDF: https://ironpdf.com/tutorials/pixel-perfect-html-to-pdf/
|
|
111
|
+
*
|
|
112
|
+
* @param zipFilePath Path to a Zip to be rendered as a PDF.
|
|
113
|
+
* @param options including {@link ChromePdfRenderOptions} and `mainHtmlFile` a main .html file default: `index.html`
|
|
114
|
+
*/
|
|
115
|
+
static fromZip(zipFilePath, options) {
|
|
116
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
117
|
+
return zod_1.z.function()
|
|
118
|
+
.args(typeSchema_1.stringSchema, zod_1.z.object({
|
|
119
|
+
renderOptions: renderSchema_1.chromePdfRenderOptionsSchema.optional(),
|
|
120
|
+
mainHtmlFile: typeSchema_1.stringSchema.optional()
|
|
121
|
+
}).optional())
|
|
122
|
+
.returns(zod_1.z.promise(pdfDocumentSchema_1.pdfDocumentSchema))
|
|
123
|
+
.implement(this.internal_fromZip.bind(this))(zipFilePath, options);
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Creates a PDF file from a Html string, and returns it as an {@link PdfDocument} object which can be edited and saved to disk or served on a website.
|
|
128
|
+
* @param htmlStringOrHtmlFilePath The Html to be rendered as a PDF.
|
|
129
|
+
* @param options including {@link ChromePdfRenderOptions}
|
|
130
|
+
*/
|
|
131
|
+
static fromHtml(htmlStringOrHtmlFilePath, options) {
|
|
132
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
133
|
+
return zod_1.z.function()
|
|
134
|
+
.args(typeSchema_1.stringSchema, zod_1.z.object({
|
|
135
|
+
renderOptions: renderSchema_1.chromePdfRenderOptionsSchema.optional(),
|
|
136
|
+
}).optional())
|
|
137
|
+
.returns(zod_1.z.promise(pdfDocumentSchema_1.pdfDocumentSchema))
|
|
138
|
+
.implement(this.internal_fromHtml.bind(this))(htmlStringOrHtmlFilePath, options);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Converts multiple image files to a PDF document. Each image creates 1 page which matches the image
|
|
143
|
+
* dimensions. The default PaperSize is A4. You can set it via ImageToPdfConverter.PaperSize.
|
|
144
|
+
* Note: Imaging.ImageBehavior.CropPage will set PaperSize equal to ImageSize.
|
|
145
|
+
* @param images The image file path name(s) or {@link ImageBuffer} object(s)
|
|
146
|
+
* @param options including {@link ImageToPdfOptions}
|
|
147
|
+
*/
|
|
148
|
+
static fromImage(images, options) {
|
|
149
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
150
|
+
return zod_1.z.function()
|
|
151
|
+
.args(zod_1.z.union([typeSchema_1.imageFilePathSchema, zod_1.z.array(typeSchema_1.imageFilePathSchema), typeSchema_1.imageBufferSchema, zod_1.z.array(typeSchema_1.imageBufferSchema)]), zod_1.z.object({
|
|
152
|
+
imageToPdfOptions: imageSchema_1.imageToPdfOptionsSchema.optional(),
|
|
153
|
+
}).optional())
|
|
154
|
+
.returns(zod_1.z.promise(pdfDocumentSchema_1.pdfDocumentSchema))
|
|
155
|
+
.implement(this.internal_fromImage.bind(this))(images, options);
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Static method that joins (concatenates) multiple PDF documents together into one compiled PDF document.
|
|
160
|
+
* If the PDF contains form fields the form field in the resulting PDF's name will be appended with '_{index}' e.g. 'Name' will be 'Name_0'
|
|
161
|
+
* @param pdfs array of PDF
|
|
162
|
+
*/
|
|
163
|
+
static mergePdf(pdfs) {
|
|
164
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
165
|
+
return zod_1.z.function()
|
|
166
|
+
.args(zod_1.z.array(typeSchema_1.pdfInputSchema))
|
|
167
|
+
.returns(zod_1.z.promise(pdfDocumentSchema_1.pdfDocumentSchema))
|
|
168
|
+
.implement(this.internal_mergePdf.bind(this))(pdfs);
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Saves the PdfDocument to a file.
|
|
173
|
+
* @param filePath Target file path
|
|
174
|
+
* @param saveOptions see {@link SaveOptions}
|
|
175
|
+
*/
|
|
176
|
+
saveAs(filePath, saveOptions) {
|
|
177
|
+
return zod_1.z.function()
|
|
178
|
+
.args(typeSchema_1.stringSchema, typeSchema_1.saveOptionsSchema.optional())
|
|
179
|
+
.returns(zod_1.z.promise(zod_1.z.void()))
|
|
180
|
+
.implement(this.internal_saveAs.bind(this))(filePath, saveOptions);
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Saves the PdfDocument to a binary (Buffer)
|
|
184
|
+
* @param saveOptions see {@link SaveOptions}
|
|
185
|
+
*/
|
|
186
|
+
saveAsBuffer(saveOptions) {
|
|
187
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
188
|
+
return zod_1.z.function()
|
|
189
|
+
.args(typeSchema_1.saveOptionsSchema.optional())
|
|
190
|
+
.returns(zod_1.z.promise(typeSchema_1.bufferSchema))
|
|
191
|
+
.implement(this.internal_saveAsBuffer.bind(this))(saveOptions);
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
//#endregion
|
|
195
|
+
//#region compress
|
|
196
|
+
/**
|
|
197
|
+
* Compress existing PDF images using JPG encoding and the specified settings
|
|
198
|
+
* @param imageQuality Quality (1 - 100) to use during compression
|
|
199
|
+
* @param scaleToVisibleSize Scale down the image resolution according to its visible size in the PDF document
|
|
200
|
+
*/
|
|
201
|
+
compressSize(imageQuality, scaleToVisibleSize = false) {
|
|
202
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
203
|
+
return yield zod_1.z.function()
|
|
204
|
+
.args(typeSchema_1.numberSchema, typeSchema_1.booleanSchema.optional())
|
|
205
|
+
.returns(zod_1.z.promise(zod_1.z.void()))
|
|
206
|
+
.implement(this.internal_compressSize.bind(this))(imageQuality, scaleToVisibleSize);
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Remove document struct tree information which describes the logical layout of the document.
|
|
211
|
+
* Removing the "structure tree" can significantly reduce the disk space used by the document.
|
|
212
|
+
* Removing the "structure tree" of a complicated document can negatively impact text selection.
|
|
213
|
+
*/
|
|
214
|
+
compressStructTree() {
|
|
215
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
216
|
+
return this.internal_compressStructTree();
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
//#endregion
|
|
220
|
+
//#region page
|
|
221
|
+
/**
|
|
222
|
+
* Gets information of all pages in the PdfDocument
|
|
223
|
+
*/
|
|
224
|
+
getPagesInfo() {
|
|
225
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
226
|
+
return this.internal_getPagesInfo();
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Gets the number of pages in the PdfDocument.
|
|
231
|
+
*/
|
|
232
|
+
getPageCount() {
|
|
233
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
234
|
+
return this.internal_getPageCount();
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Set the page orientation.
|
|
239
|
+
* @param pageRotation see {@link PageRotation}
|
|
240
|
+
* @param options including {@link PdfPageSelection}
|
|
241
|
+
*/
|
|
242
|
+
setRotation(pageRotation, options) {
|
|
243
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
244
|
+
return zod_1.z.function()
|
|
245
|
+
.args(pageSchema_1.pageRotationSchema, zod_1.z.object({ pdfPageSelection: typeSchema_1.pdfPageSelectionSchema.optional() }).optional())
|
|
246
|
+
.returns(zod_1.z.promise(zod_1.z.void()))
|
|
247
|
+
.implement(this.internal_setRotation.bind(this))(pageRotation, options);
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Resize a page to the specified dimensions
|
|
252
|
+
* @param newSize {@link PdfPaperSize}
|
|
253
|
+
* @param options including {@link PdfPageSelection}
|
|
254
|
+
*/
|
|
255
|
+
resize(newSize, options) {
|
|
256
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
257
|
+
return zod_1.z.function()
|
|
258
|
+
.args(paperSchema_1.pdfPaperSizeSchema, zod_1.z.object({ pdfPageSelection: typeSchema_1.pdfPageSelectionSchema.optional() }).optional())
|
|
259
|
+
.returns(zod_1.z.promise(zod_1.z.void()))
|
|
260
|
+
.implement(this.internal_resize.bind(this))(newSize, options);
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Adds another PDF to the beginning of the current PdfDocument
|
|
265
|
+
* If AnotherPdfFile contains form fields, those fields will be appended with '_' in the resulting PDF. e.g. 'Name' will be 'Name_'
|
|
266
|
+
* @param fromPdfDocument PdfDocument to prepend
|
|
267
|
+
*/
|
|
268
|
+
prependAnotherPdf(fromPdfDocument) {
|
|
269
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
270
|
+
return zod_1.z.function()
|
|
271
|
+
.args(pdfDocumentSchema_1.pdfDocumentSchema)
|
|
272
|
+
.returns(zod_1.z.promise(zod_1.z.void()))
|
|
273
|
+
.implement(this.internal_prependAnotherPdf.bind(this))(fromPdfDocument);
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Appends another PDF to the end of the current <see cref="PdfDocument"/>
|
|
278
|
+
* If AnotherPdfFile contains form fields, those fields will be appended with '_' in the resulting PDF. e.g. 'Name' will be 'Name_'
|
|
279
|
+
* @param fromPdfDocument PdfDocument to Append
|
|
280
|
+
*/
|
|
281
|
+
appendAnotherPdf(fromPdfDocument) {
|
|
282
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
283
|
+
return zod_1.z.function()
|
|
284
|
+
.args(pdfDocumentSchema_1.pdfDocumentSchema)
|
|
285
|
+
.returns(zod_1.z.promise(zod_1.z.void()))
|
|
286
|
+
.implement(this.internal_appendAnotherPdf.bind(this))(fromPdfDocument);
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Inserts another PDF into the current PdfDocument, starting at a given Page Index.
|
|
291
|
+
* If AnotherPdfFile contains form fields, those fields will be appended with '_' in the resulting PDF. e.g. 'Name' will be 'Name_'
|
|
292
|
+
* @param fromPdfDocument Another PdfDocument
|
|
293
|
+
* @param insertAtPageIndex Index at which to insert the new content. Note: Page 1 has index 0...
|
|
294
|
+
*/
|
|
295
|
+
insertPagesFromAnotherPdf(fromPdfDocument, insertAtPageIndex) {
|
|
296
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
297
|
+
return zod_1.z.function()
|
|
298
|
+
.args(pdfDocumentSchema_1.pdfDocumentSchema, typeSchema_1.numberSchema.describe("insertAtPageIndex: number"))
|
|
299
|
+
.returns(zod_1.z.promise(zod_1.z.void()))
|
|
300
|
+
.implement(this.internal_insertPagesFromAnotherPdf.bind(this))(fromPdfDocument, insertAtPageIndex);
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Removes a range of pages from the PDF
|
|
305
|
+
* @param pages pages to remove
|
|
306
|
+
*/
|
|
307
|
+
removePage(pages) {
|
|
308
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
309
|
+
return zod_1.z.function()
|
|
310
|
+
.args(typeSchema_1.pdfPageSelectionSchema)
|
|
311
|
+
.returns(zod_1.z.promise(zod_1.z.void()))
|
|
312
|
+
.implement(this.internal_removePage.bind(this))(pages);
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Creates a new PDF by copying a range of pages from this {@link PdfDocument}.
|
|
317
|
+
* @param pages pages to copy (default "all")
|
|
318
|
+
*/
|
|
319
|
+
duplicate(pages = "all") {
|
|
320
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
321
|
+
return zod_1.z.function()
|
|
322
|
+
.args(typeSchema_1.pdfPageSelectionSchema)
|
|
323
|
+
.returns(zod_1.z.promise(pdfDocumentSchema_1.pdfDocumentSchema))
|
|
324
|
+
.implement(this.internal_duplicate.bind(this))(pages);
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
//#endregion
|
|
328
|
+
//#region image
|
|
329
|
+
/**
|
|
330
|
+
* Finds all embedded Images from within a specified pages in the PDF and returns them as Buffer
|
|
331
|
+
* @param options including {@link PdfPageSelection}
|
|
332
|
+
*/
|
|
333
|
+
extractRawImages(options) {
|
|
334
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
335
|
+
return zod_1.z.function()
|
|
336
|
+
.args(zod_1.z.object({ fromPages: typeSchema_1.pdfPageSelectionSchema.optional() }).optional())
|
|
337
|
+
.returns(zod_1.z.promise(typeSchema_1.bufferArraySchema))
|
|
338
|
+
.implement(this.internal_extractRawImages.bind(this))(options);
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Renders the PDF and exports image Files in convenient formats. 1 image file is created for each
|
|
343
|
+
* page.
|
|
344
|
+
*
|
|
345
|
+
* @param options including {@link PdfPageSelection} {@link ImageType}
|
|
346
|
+
*
|
|
347
|
+
* @return array of images as Buffer[]
|
|
348
|
+
*/
|
|
349
|
+
rasterizeToImageBuffers(options) {
|
|
350
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
351
|
+
return zod_1.z.function()
|
|
352
|
+
.args(zod_1.z.object({
|
|
353
|
+
fromPages: typeSchema_1.pdfPageSelectionSchema.optional(),
|
|
354
|
+
imageType: imageSchema_1.imageTypeSchema.optional()
|
|
355
|
+
}).optional())
|
|
356
|
+
.returns(zod_1.z.promise(typeSchema_1.bufferArraySchema))
|
|
357
|
+
.implement(this.internal_rasterizeToImageBuffers.bind(this))(options);
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Renders the PDF and exports image Files in convenient formats. 1 image file is created for each
|
|
362
|
+
* page. Running number will append output file path.
|
|
363
|
+
*
|
|
364
|
+
* @param filePath output file path.
|
|
365
|
+
* @param options including {@link PdfPageSelection} {@link ImageType}
|
|
366
|
+
*
|
|
367
|
+
* @return array of images file name as string[]
|
|
368
|
+
*/
|
|
369
|
+
rasterizeToImageFiles(filePath, options) {
|
|
370
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
371
|
+
return zod_1.z.function()
|
|
372
|
+
.args(typeSchema_1.filePathSchema, zod_1.z.object({
|
|
373
|
+
fromPages: typeSchema_1.pdfPageSelectionSchema.optional(),
|
|
374
|
+
type: imageSchema_1.imageTypeSchema.optional()
|
|
375
|
+
}).optional())
|
|
376
|
+
.returns(zod_1.z.promise(typeSchema_1.stringArraySchema))
|
|
377
|
+
.implement(this.internal_rasterizeToImageFiles.bind(this))(filePath, options);
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
//#endregion
|
|
381
|
+
//#region text
|
|
382
|
+
/**
|
|
383
|
+
* Replace the specified old text with new text on a given page
|
|
384
|
+
* @param oldText Old text to remove
|
|
385
|
+
* @param newText New text to add
|
|
386
|
+
* @param onPages Page index to search for old text to replace (default "all")
|
|
387
|
+
*/
|
|
388
|
+
replaceText(oldText, newText, onPages) {
|
|
389
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
390
|
+
return zod_1.z.function()
|
|
391
|
+
.args(zod_1.z.string({ description: "oldText: string" }), zod_1.z.string({ description: "newText: string" }), typeSchema_1.pdfPageSelectionSchema.optional())
|
|
392
|
+
.returns(zod_1.z.promise(zod_1.z.void()))
|
|
393
|
+
.implement(this.internal_replaceText.bind(this))(oldText, newText, onPages);
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
extractText(onPages) {
|
|
397
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
398
|
+
return zod_1.z.function()
|
|
399
|
+
.args(typeSchema_1.pdfPageSelectionSchema.optional())
|
|
400
|
+
.returns(zod_1.z.promise(zod_1.z.string()))
|
|
401
|
+
.implement(this.internal_extractText.bind(this))(onPages);
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
//#endregion
|
|
405
|
+
//#region pdfA
|
|
406
|
+
/**
|
|
407
|
+
* Convert the current document into the specified PDF-A standard format
|
|
408
|
+
* @param customICC (Optional) Custom color profile file path
|
|
409
|
+
*/
|
|
410
|
+
convertToPdfA(customICC) {
|
|
411
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
412
|
+
return zod_1.z.function()
|
|
413
|
+
.args(zod_1.z.string({ description: "customICC: string" }).optional())
|
|
414
|
+
.returns(zod_1.z.promise(zod_1.z.void()))
|
|
415
|
+
.implement(this.internal_convertToPdfA.bind(this))(customICC);
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Convert the current document into the specified PDF/UA standard format
|
|
420
|
+
*/
|
|
421
|
+
convertToPdfUA() {
|
|
422
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
423
|
+
return this.internal_convertToPdfUA();
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
//#endregion
|
|
427
|
+
//#region metadata
|
|
428
|
+
/**
|
|
429
|
+
* Gets a Map<string, string> of metadata properties
|
|
430
|
+
*/
|
|
431
|
+
getMetadata() {
|
|
432
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
433
|
+
return this.internal_getMetadata();
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Add or Update a single metadata property
|
|
438
|
+
* @param key
|
|
439
|
+
* @param value
|
|
440
|
+
*/
|
|
441
|
+
addOrUpdateMetadata(key, value) {
|
|
442
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
443
|
+
return zod_1.z.function()
|
|
444
|
+
.args(zod_1.z.string({ description: "key: string" }), zod_1.z.string({ description: "value: string" }))
|
|
445
|
+
.returns(zod_1.z.promise(zod_1.z.void()))
|
|
446
|
+
.implement(this.internal_addOrUpdateMetadata.bind(this))(key, value);
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Remove a single metadata property
|
|
451
|
+
* @param key
|
|
452
|
+
*/
|
|
453
|
+
removeMetadata(key) {
|
|
454
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
455
|
+
return zod_1.z.function()
|
|
456
|
+
.args(zod_1.z.string({ description: "key: string" }))
|
|
457
|
+
.returns(zod_1.z.promise(zod_1.z.void()))
|
|
458
|
+
.implement(this.internal_removeMetadata.bind(this))(key);
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* Sets a whole metadata properties Map<string, string> (override all the metadata property)
|
|
463
|
+
* @param newMetadataDictionary new metadata properties Map<string, string>
|
|
464
|
+
*/
|
|
465
|
+
overrideMetadata(newMetadataDictionary) {
|
|
466
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
467
|
+
return zod_1.z.function()
|
|
468
|
+
.args(typeSchema_1.mapStringSchema)
|
|
469
|
+
.returns(zod_1.z.promise(zod_1.z.void()))
|
|
470
|
+
.implement(this.internal_overrideMetadata.bind(this))(newMetadataDictionary);
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
//#endregion
|
|
474
|
+
//#region signing
|
|
475
|
+
/**
|
|
476
|
+
* Sign PDF with digital signature certificate.
|
|
477
|
+
* Note that the PDF will not be fully signed until Saved
|
|
478
|
+
* using {@link saveAs} or {@link saveAsBuffer}
|
|
479
|
+
*
|
|
480
|
+
* Multiple certificates may be used.
|
|
481
|
+
* @param signature see {@link DigitalSignature}
|
|
482
|
+
*/
|
|
483
|
+
signDigitalSignature(signature) {
|
|
484
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
485
|
+
return zod_1.z.function()
|
|
486
|
+
.args(signatureSchema_1.digitalSignatureSchema)
|
|
487
|
+
.returns(zod_1.z.promise(zod_1.z.void()))
|
|
488
|
+
.implement(this.internal_signDigitalSignature.bind(this))(signature);
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* Check if PdfDocument was signed or not
|
|
493
|
+
*/
|
|
494
|
+
isSigned() {
|
|
495
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
496
|
+
return this.internal_isSigned();
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* Count the number signature that signed to this PdfDocument
|
|
501
|
+
*/
|
|
502
|
+
signatureCount() {
|
|
503
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
504
|
+
return this.internal_signatureCount();
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
//#endregion
|
|
508
|
+
//#region header/footer (affix)
|
|
509
|
+
/**
|
|
510
|
+
* Apply page header on top of an existing Pdf.
|
|
511
|
+
* @param header {@link TextAffix}
|
|
512
|
+
* @param toPages {@link PdfPageSelection}
|
|
513
|
+
*/
|
|
514
|
+
addTextHeader(header, toPages) {
|
|
515
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
516
|
+
return zod_1.z.function()
|
|
517
|
+
.args(affixSchema_1.textAffixSchema, typeSchema_1.pdfPageSelectionSchema.optional())
|
|
518
|
+
.returns(zod_1.z.promise(zod_1.z.void()))
|
|
519
|
+
.implement(this.internal_addTextHeader.bind(this))(header, toPages);
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
/**
|
|
523
|
+
* Apply page footer on top of an existing Pdf.
|
|
524
|
+
* @param footer {@link TextAffix}
|
|
525
|
+
* @param toPages {@link PdfPageSelection}
|
|
526
|
+
*/
|
|
527
|
+
addTextFooter(footer, toPages) {
|
|
528
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
529
|
+
return zod_1.z.function()
|
|
530
|
+
.args(affixSchema_1.textAffixSchema, typeSchema_1.pdfPageSelectionSchema.optional())
|
|
531
|
+
.returns(zod_1.z.promise(zod_1.z.void()))
|
|
532
|
+
.implement(this.internal_addTextFooter.bind(this))(footer, toPages);
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
/**
|
|
536
|
+
* Apply HTML header on top of an existing Pdf.
|
|
537
|
+
* @param header {@link HtmlAffix}
|
|
538
|
+
* @param toPages {@link PdfPageSelection}
|
|
539
|
+
*/
|
|
540
|
+
addHtmlHeader(header, toPages) {
|
|
541
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
542
|
+
return zod_1.z.function()
|
|
543
|
+
.args(affixSchema_1.htmlAffixSchema, typeSchema_1.pdfPageSelectionSchema.optional())
|
|
544
|
+
.returns(zod_1.z.promise(zod_1.z.void()))
|
|
545
|
+
.implement(this.internal_addHtmlHeader.bind(this))(header, toPages);
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
/**
|
|
549
|
+
* Apply HTML footer on top of an existing Pdf.
|
|
550
|
+
* @param footer {@link HtmlAffix}
|
|
551
|
+
* @param toPages {@link PdfPageSelection}
|
|
552
|
+
*/
|
|
553
|
+
addHtmlFooter(footer, toPages) {
|
|
554
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
555
|
+
return zod_1.z.function()
|
|
556
|
+
.args(affixSchema_1.htmlAffixSchema, typeSchema_1.pdfPageSelectionSchema.optional())
|
|
557
|
+
.returns(zod_1.z.promise(zod_1.z.void()))
|
|
558
|
+
.implement(this.internal_addHtmlFooter.bind(this))(footer, toPages);
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
//#endregion
|
|
562
|
+
//#region stamp
|
|
563
|
+
/**
|
|
564
|
+
* Edits the PDF by applying the HTML's rendered to only selected page(s).
|
|
565
|
+
* @param htmlStringOrHtmlFilePath
|
|
566
|
+
* @param options including {@link HtmlStampOptions} {@link PdfPageSelection}
|
|
567
|
+
*/
|
|
568
|
+
stampHtml(htmlStringOrHtmlFilePath, options) {
|
|
569
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
570
|
+
return zod_1.z.function()
|
|
571
|
+
.args(zod_1.z.union([typeSchema_1.htmlFilePathSchema, typeSchema_1.htmlStringSchema]), zod_1.z.object({
|
|
572
|
+
htmlStampOptions: stampSchema_1.htmlStampOptionsSchema.optional(),
|
|
573
|
+
toPages: typeSchema_1.pdfPageSelectionSchema.optional()
|
|
574
|
+
}).optional())
|
|
575
|
+
.returns(zod_1.z.promise(zod_1.z.void()))
|
|
576
|
+
.implement(this.internal_stampHtml.bind(this))(htmlStringOrHtmlFilePath, options);
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
/**
|
|
580
|
+
* Edits the PDF by applying the image to only selected page(s).
|
|
581
|
+
* @param image image file path or image buffer
|
|
582
|
+
* @param options including {@link ImageStampOptions} {@link PdfPageSelection}
|
|
583
|
+
*/
|
|
584
|
+
stampImage(image, options) {
|
|
585
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
586
|
+
return zod_1.z.function()
|
|
587
|
+
.args(zod_1.z.union([typeSchema_1.imageFilePathSchema, typeSchema_1.imageBufferSchema]), zod_1.z.object({
|
|
588
|
+
imageStampOptions: stampSchema_1.imageStampOptionsSchema.optional(),
|
|
589
|
+
toPages: typeSchema_1.pdfPageSelectionSchema.optional()
|
|
590
|
+
}).optional())
|
|
591
|
+
.returns(zod_1.z.promise(zod_1.z.void()))
|
|
592
|
+
.implement(this.internal_stampImage.bind(this))(image, options);
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* Edits the PDF by applying the text to only selected page(s).
|
|
597
|
+
* @param text text to stamp
|
|
598
|
+
* @param options including {@link TextStampOptions} {@link PdfPageSelection}
|
|
599
|
+
*/
|
|
600
|
+
stampText(text, options) {
|
|
601
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
602
|
+
return zod_1.z.function()
|
|
603
|
+
.args(typeSchema_1.stringSchema, zod_1.z.object({
|
|
604
|
+
textStampOptions: stampSchema_1.textStampOptionsSchema.optional(),
|
|
605
|
+
toPages: typeSchema_1.pdfPageSelectionSchema.optional()
|
|
606
|
+
}).optional())
|
|
607
|
+
.returns(zod_1.z.promise(zod_1.z.void()))
|
|
608
|
+
.implement(this.internal_stampText.bind(this))(text, options);
|
|
609
|
+
});
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
* Edits the PDF by applying the barcode to only selected page(s).
|
|
613
|
+
* @param barcodeValue barcode
|
|
614
|
+
* @param options including {@link BarcodeType} {@link BarcodeStampOptions} {@link PdfPageSelection}
|
|
615
|
+
*/
|
|
616
|
+
stampBarcode(barcodeValue, options) {
|
|
617
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
618
|
+
return zod_1.z.function()
|
|
619
|
+
.args(typeSchema_1.stringSchema, zod_1.z.object({
|
|
620
|
+
barcodeEncoding: typeSchema_1.barcodeTypeSchema,
|
|
621
|
+
barcodeStampOptions: stampSchema_1.barcodeStampOptionsSchema.optional(),
|
|
622
|
+
toPages: typeSchema_1.pdfPageSelectionSchema.optional()
|
|
623
|
+
}).optional())
|
|
624
|
+
.returns(zod_1.z.promise(zod_1.z.void()))
|
|
625
|
+
.implement(this.internal_stampBarcode.bind(this))(barcodeValue, options);
|
|
626
|
+
});
|
|
627
|
+
}
|
|
628
|
+
//#endregion
|
|
629
|
+
//#region background/foreground
|
|
630
|
+
/**
|
|
631
|
+
* Adds a background to each page of this PDF. The background is copied from a first page in the
|
|
632
|
+
* backgroundPdf document.
|
|
633
|
+
*
|
|
634
|
+
* @param fromPdf background PDF document
|
|
635
|
+
* @param sourcePageIndex Index (zero-based page number) of the page to copy from the Background/Foreground PDF. Default is 0.
|
|
636
|
+
* @param applyToPages PageSelection to which the background/foreground will be added. Default is "all"
|
|
637
|
+
*/
|
|
638
|
+
addBackgroundFromAnotherPdf(fromPdf, sourcePageIndex = 0, applyToPages) {
|
|
639
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
640
|
+
return zod_1.z.function()
|
|
641
|
+
.args(pdfDocumentSchema_1.pdfDocumentSchema, typeSchema_1.numberSchema, typeSchema_1.pdfPageSelectionSchema.optional())
|
|
642
|
+
.returns(zod_1.z.promise(zod_1.z.void()))
|
|
643
|
+
.implement(this.internal_addBackgroundFromAnotherPdf.bind(this))(fromPdf, sourcePageIndex, applyToPages);
|
|
644
|
+
});
|
|
645
|
+
}
|
|
646
|
+
/**
|
|
647
|
+
* Adds a foreground to each page of this PDF. The background is copied from a first page in the
|
|
648
|
+
* backgroundPdf document.
|
|
649
|
+
*
|
|
650
|
+
* @param fromPdf foreground PDF document
|
|
651
|
+
* @param sourcePageIndex Index (zero-based page number) of the page to copy from the Background/Foreground PDF. Default is 0.
|
|
652
|
+
* @param applyToPages PageSelection to which the background/foreground will be added. Default is "all"
|
|
653
|
+
*/
|
|
654
|
+
addForegroundFromAnotherPdf(fromPdf, sourcePageIndex = 0, applyToPages) {
|
|
655
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
656
|
+
return zod_1.z.function()
|
|
657
|
+
.args(pdfDocumentSchema_1.pdfDocumentSchema, typeSchema_1.numberSchema, typeSchema_1.pdfPageSelectionSchema.optional())
|
|
658
|
+
.returns(zod_1.z.promise(zod_1.z.void()))
|
|
659
|
+
.implement(this.internal_addForegroundFromAnotherPdf.bind(this))(fromPdf, sourcePageIndex, applyToPages);
|
|
660
|
+
});
|
|
661
|
+
}
|
|
662
|
+
//#endregion
|
|
663
|
+
//#region security
|
|
664
|
+
/**
|
|
665
|
+
* Removes all user and owner password security for a PDF document. Also disables content
|
|
666
|
+
* encryption.
|
|
667
|
+
* If content is encrypted at 128 bit, copy and paste of content, annotations and form editing may be disabled.
|
|
668
|
+
*/
|
|
669
|
+
removePasswordsAndEncryption() {
|
|
670
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
671
|
+
return this.internal_removePasswordsAndEncryption();
|
|
672
|
+
});
|
|
673
|
+
}
|
|
674
|
+
/**
|
|
675
|
+
* Sets the user password and enables 128Bit encryption of PDF content.
|
|
676
|
+
* A user password is a password that each user must enter to open or print the PDF document.
|
|
677
|
+
*/
|
|
678
|
+
setUserPassword(userPassword) {
|
|
679
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
680
|
+
return zod_1.z.function()
|
|
681
|
+
.args(zod_1.z.string({ description: "userPassword: string" }))
|
|
682
|
+
.returns(zod_1.z.promise(zod_1.z.void()))
|
|
683
|
+
.implement(this.internal_setUserPassword.bind(this))(userPassword);
|
|
684
|
+
});
|
|
685
|
+
}
|
|
686
|
+
/**
|
|
687
|
+
* Sets the owner password and enables 128Bit encryption of PDF content. An owner password is one used to
|
|
688
|
+
* enable and disable all other security settings. <para>OwnerPassword must be set to a non-empty string
|
|
689
|
+
* value for {@link PdfPermission.AllowAccessibilityExtractContent} , {@link PdfPermission.AllowAnnotations} ,
|
|
690
|
+
* {@link PdfPermission.AllowFillForms}, {@link PdfPermission.AllowPrint}, {@link PdfPermission.AllowModify} to be
|
|
691
|
+
* restricted.
|
|
692
|
+
*/
|
|
693
|
+
setOwnerPassword(ownerPassword) {
|
|
694
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
695
|
+
return zod_1.z.function()
|
|
696
|
+
.args(zod_1.z.string({ description: "ownerPassword: string" }))
|
|
697
|
+
.returns(zod_1.z.promise(zod_1.z.void()))
|
|
698
|
+
.implement(this.internal_setOwnerPassword.bind(this))(ownerPassword);
|
|
699
|
+
});
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* Sets the permissions of this PdfDocument
|
|
703
|
+
* @param permissions see {@link PdfPermission}
|
|
704
|
+
*/
|
|
705
|
+
setPermission(permissions) {
|
|
706
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
707
|
+
return zod_1.z.function()
|
|
708
|
+
.args(securitySchema_1.pdfPermissionSchema)
|
|
709
|
+
.returns(zod_1.z.promise(zod_1.z.void()))
|
|
710
|
+
.implement(this.internal_setPermission.bind(this))(permissions);
|
|
711
|
+
});
|
|
712
|
+
}
|
|
713
|
+
/**
|
|
714
|
+
* Gets the current permissions of this PdfDocument
|
|
715
|
+
* @return {@link PdfPermission}
|
|
716
|
+
*/
|
|
717
|
+
getPermission() {
|
|
718
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
719
|
+
return this.internal_getPermission();
|
|
720
|
+
});
|
|
721
|
+
}
|
|
722
|
+
/**
|
|
723
|
+
* Makes this PDF document read only such that: Content is encrypted at 128 bit. Copy and paste of
|
|
724
|
+
* content is disallowed. Annotations and form editing are disabled.
|
|
725
|
+
* @param ownerPassword The owner password for the PDF. A string for owner password is required to enable PDF encryption and
|
|
726
|
+
* all document security options.
|
|
727
|
+
*/
|
|
728
|
+
makePdfDocumentReadOnly(ownerPassword) {
|
|
729
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
730
|
+
return zod_1.z.function()
|
|
731
|
+
.args(zod_1.z.string({ description: "ownerPassword: string" }))
|
|
732
|
+
.returns(zod_1.z.promise(zod_1.z.void()))
|
|
733
|
+
.implement(this.internal_makePdfDocumentReadOnly.bind(this))(ownerPassword);
|
|
734
|
+
});
|
|
735
|
+
}
|
|
736
|
+
//#endregion
|
|
737
|
+
//#region close
|
|
738
|
+
/**
|
|
739
|
+
* Dispose this PdfDocument object (clean up the resource)
|
|
740
|
+
* This is necessary to free the memory used by PdfDocument. See {@link cleanUp}
|
|
741
|
+
* Once this method was called this PdfDocument object no longer usable.
|
|
742
|
+
*/
|
|
743
|
+
close() {
|
|
744
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
745
|
+
return this.internal_close();
|
|
746
|
+
});
|
|
747
|
+
}
|
|
65
748
|
/**
|
|
66
749
|
* Create a PdfDocument object from a {@link PdfInput}
|
|
67
|
-
* For more specific way to create/open
|
|
750
|
+
* For more specific way to create/open PdfDocument see {@link fromUrl} {@link fromZip} {@link fromHtml} {@link fromImage} {@link open}
|
|
68
751
|
*
|
|
69
752
|
* @param pdfInput see {@link PdfInput} (required)
|
|
70
|
-
* @param password a password to open the PDF required if PDF file was
|
|
753
|
+
* @param password a password to open the PDF required if PDF file was private (pdfInput is {@link PdfFilePath} or {@link Buffer})
|
|
71
754
|
* @param trackChanges Optionally track changes to the document (for use with incremental saves)
|
|
72
755
|
*/
|
|
73
756
|
constructor(pdfInput, password, trackChanges) {
|
|
@@ -77,7 +760,7 @@ class PdfDocument {
|
|
|
77
760
|
const input = (0, util_1.separatePdfInput)(pdfInput);
|
|
78
761
|
switch (input.type) {
|
|
79
762
|
case "htmlFile":
|
|
80
|
-
const htmlString =
|
|
763
|
+
const htmlString = fs_1.default
|
|
81
764
|
.readFileSync(input.htmlFile)
|
|
82
765
|
.toString();
|
|
83
766
|
this.promiseDocumentId = (0, render_1.renderHtmlToPdf)(htmlString);
|
|
@@ -93,7 +776,7 @@ class PdfDocument {
|
|
|
93
776
|
break;
|
|
94
777
|
case "pdfFile":
|
|
95
778
|
this.pdfPassword = password;
|
|
96
|
-
this.promiseDocumentId = (0, io_1.openPdfFileBuffer)(
|
|
779
|
+
this.promiseDocumentId = (0, io_1.openPdfFileBuffer)(fs_1.default.readFileSync(input.pdfFile), password);
|
|
97
780
|
break;
|
|
98
781
|
case "url":
|
|
99
782
|
this.promiseDocumentId = (0, render_1.renderUrlToPdf)(input.url);
|
|
@@ -115,22 +798,22 @@ class PdfDocument {
|
|
|
115
798
|
* This is necessary to free the memory used by PdfDocument. See {@link cleanUp}
|
|
116
799
|
* Once this method was called this PdfDocument object no longer usable.
|
|
117
800
|
*/
|
|
118
|
-
|
|
801
|
+
internal_close() {
|
|
119
802
|
return __awaiter(this, void 0, void 0, function* () {
|
|
120
|
-
yield (0, io_1.disposePdf)(yield this.
|
|
803
|
+
yield (0, io_1.disposePdf)(yield this.internal_getId());
|
|
121
804
|
});
|
|
122
805
|
}
|
|
123
806
|
/**
|
|
124
807
|
* @private
|
|
125
808
|
*/
|
|
126
|
-
|
|
809
|
+
internal_getId() {
|
|
127
810
|
return __awaiter(this, void 0, void 0, function* () {
|
|
128
811
|
if (this.pdfDocumentId) {
|
|
129
|
-
return this.pdfDocumentId;
|
|
812
|
+
return Promise.resolve(this.pdfDocumentId);
|
|
130
813
|
}
|
|
131
814
|
else if (this.promiseDocumentId) {
|
|
132
815
|
this.pdfDocumentId = yield this.promiseDocumentId;
|
|
133
|
-
return this.pdfDocumentId;
|
|
816
|
+
return Promise.resolve(this.pdfDocumentId);
|
|
134
817
|
}
|
|
135
818
|
else {
|
|
136
819
|
throw new Error("Cannot Get PdfDocumentId");
|
|
@@ -143,14 +826,14 @@ class PdfDocument {
|
|
|
143
826
|
* @param pdfInput {@link PdfInput}
|
|
144
827
|
* @param options including {@link PdfPassword} {@link ChromePdfRenderOptions} {@link HttpLoginCredentials} mainHtmlFile
|
|
145
828
|
*/
|
|
146
|
-
static
|
|
829
|
+
static internal_open(pdfInput, options) {
|
|
147
830
|
var _a, _b, _c, _d;
|
|
148
831
|
return __awaiter(this, void 0, void 0, function* () {
|
|
149
832
|
if (pdfInput) {
|
|
150
833
|
const input = (0, util_1.separatePdfInput)(pdfInput);
|
|
151
834
|
switch (input.type) {
|
|
152
835
|
case "htmlFile":
|
|
153
|
-
const htmlString =
|
|
836
|
+
const htmlString = fs_1.default
|
|
154
837
|
.readFileSync(input.htmlFile)
|
|
155
838
|
.toString();
|
|
156
839
|
const newHtmlFilePdf = new PdfDocument();
|
|
@@ -174,7 +857,7 @@ class PdfDocument {
|
|
|
174
857
|
return newBufferPdf;
|
|
175
858
|
case "pdfFile":
|
|
176
859
|
const newPdfFilePdf = new PdfDocument(undefined, options === null || options === void 0 ? void 0 : options.password);
|
|
177
|
-
newPdfFilePdf.pdfDocumentId = yield (0, io_1.openPdfFileBuffer)(
|
|
860
|
+
newPdfFilePdf.pdfDocumentId = yield (0, io_1.openPdfFileBuffer)(fs_1.default.readFileSync(input.pdfFile), {
|
|
178
861
|
userPassword: (_c = options === null || options === void 0 ? void 0 : options.password) === null || _c === void 0 ? void 0 : _c.userPassword,
|
|
179
862
|
ownerPassword: (_d = options === null || options === void 0 ? void 0 : options.password) === null || _d === void 0 ? void 0 : _d.ownerPassword,
|
|
180
863
|
trackChanges: options === null || options === void 0 ? void 0 : options.trackChanges
|
|
@@ -199,9 +882,9 @@ class PdfDocument {
|
|
|
199
882
|
* @param pdfFilePath A path to .pdf file
|
|
200
883
|
* @param Optionally track changes to the document (for use with incremental saves)
|
|
201
884
|
*/
|
|
202
|
-
static
|
|
885
|
+
static internal_fromFile(pdfFilePath, trackChanges) {
|
|
203
886
|
return __awaiter(this, void 0, void 0, function* () {
|
|
204
|
-
return this.
|
|
887
|
+
return this.internal_open(pdfFilePath, { trackChanges: trackChanges });
|
|
205
888
|
});
|
|
206
889
|
}
|
|
207
890
|
/**
|
|
@@ -209,9 +892,9 @@ class PdfDocument {
|
|
|
209
892
|
* @param url A website Url
|
|
210
893
|
* @param options including {@link ChromePdfRenderOptions}
|
|
211
894
|
*/
|
|
212
|
-
static
|
|
895
|
+
static internal_fromUrl(url, options) {
|
|
213
896
|
return __awaiter(this, void 0, void 0, function* () {
|
|
214
|
-
return this.
|
|
897
|
+
return this.internal_open(url, options);
|
|
215
898
|
});
|
|
216
899
|
}
|
|
217
900
|
/**
|
|
@@ -228,9 +911,9 @@ class PdfDocument {
|
|
|
228
911
|
* @param zipFilePath Path to a Zip to be rendered as a PDF.
|
|
229
912
|
* @param options including {@link ChromePdfRenderOptions} and `mainHtmlFile` a main .html file default: `index.html`
|
|
230
913
|
*/
|
|
231
|
-
static
|
|
914
|
+
static internal_fromZip(zipFilePath, options) {
|
|
232
915
|
return __awaiter(this, void 0, void 0, function* () {
|
|
233
|
-
return this.
|
|
916
|
+
return this.internal_open(zipFilePath, options);
|
|
234
917
|
});
|
|
235
918
|
}
|
|
236
919
|
/**
|
|
@@ -238,9 +921,9 @@ class PdfDocument {
|
|
|
238
921
|
* @param htmlStringOrHtmlFilePath The Html to be rendered as a PDF.
|
|
239
922
|
* @param options including {@link ChromePdfRenderOptions}
|
|
240
923
|
*/
|
|
241
|
-
static
|
|
924
|
+
static internal_fromHtml(htmlStringOrHtmlFilePath, options) {
|
|
242
925
|
return __awaiter(this, void 0, void 0, function* () {
|
|
243
|
-
return this.
|
|
926
|
+
return this.internal_open(htmlStringOrHtmlFilePath, options);
|
|
244
927
|
});
|
|
245
928
|
}
|
|
246
929
|
/**
|
|
@@ -250,7 +933,7 @@ class PdfDocument {
|
|
|
250
933
|
* @param images The image file path name(s) or {@link ImageBuffer} object(s)
|
|
251
934
|
* @param options including {@link ImageToPdfOptions}
|
|
252
935
|
*/
|
|
253
|
-
static
|
|
936
|
+
static internal_fromImage(images, options) {
|
|
254
937
|
return __awaiter(this, void 0, void 0, function* () {
|
|
255
938
|
let temp;
|
|
256
939
|
if (Array.isArray(images)) {
|
|
@@ -292,9 +975,9 @@ class PdfDocument {
|
|
|
292
975
|
* If the PDF contains form fields the form field in the resulting PDF's name will be appended with '_{index}' e.g. 'Name' will be 'Name_0'
|
|
293
976
|
* @param pdfs array of PDF
|
|
294
977
|
*/
|
|
295
|
-
static
|
|
978
|
+
static internal_mergePdf(pdfs) {
|
|
296
979
|
return __awaiter(this, void 0, void 0, function* () {
|
|
297
|
-
const ids = yield Promise.all(pdfs.map((x) => __awaiter(this, void 0, void 0, function* () { return (yield PdfDocument.open(x)).
|
|
980
|
+
const ids = yield Promise.all(pdfs.map((x) => __awaiter(this, void 0, void 0, function* () { return (yield PdfDocument.open(x)).internal_getId(); })));
|
|
298
981
|
const newDocId = (0, render_1.mergePdfs)(ids);
|
|
299
982
|
const newUrlPdf = new PdfDocument();
|
|
300
983
|
newUrlPdf.pdfDocumentId = yield newDocId;
|
|
@@ -306,11 +989,13 @@ class PdfDocument {
|
|
|
306
989
|
* @param filePath Target file path
|
|
307
990
|
* @param saveOptions see {@link SaveOptions}
|
|
308
991
|
*/
|
|
309
|
-
|
|
310
|
-
return this
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
992
|
+
internal_saveAs(filePath, saveOptions) {
|
|
993
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
994
|
+
return this.internal_saveAsBuffer(saveOptions).then((pdfFileBuffer) => {
|
|
995
|
+
fs_1.default.writeFile(filePath, pdfFileBuffer, "binary", (err) => {
|
|
996
|
+
if (err)
|
|
997
|
+
throw err;
|
|
998
|
+
});
|
|
314
999
|
});
|
|
315
1000
|
});
|
|
316
1001
|
}
|
|
@@ -318,9 +1003,9 @@ class PdfDocument {
|
|
|
318
1003
|
* Saves the PdfDocument to a binary (Buffer)
|
|
319
1004
|
* @param saveOptions see {@link SaveOptions}
|
|
320
1005
|
*/
|
|
321
|
-
|
|
1006
|
+
internal_saveAsBuffer(saveOptions) {
|
|
322
1007
|
return __awaiter(this, void 0, void 0, function* () {
|
|
323
|
-
return (0, io_1.getBinaryData)(yield this.
|
|
1008
|
+
return (0, io_1.getBinaryData)(yield this.internal_getId(), saveOptions);
|
|
324
1009
|
});
|
|
325
1010
|
}
|
|
326
1011
|
//#endregion
|
|
@@ -330,11 +1015,11 @@ class PdfDocument {
|
|
|
330
1015
|
* @param imageQuality Quality (1 - 100) to use during compression
|
|
331
1016
|
* @param scaleToVisibleSize Scale down the image resolution according to its visible size in the PDF document
|
|
332
1017
|
*/
|
|
333
|
-
|
|
1018
|
+
internal_compressSize(imageQuality, scaleToVisibleSize = false) {
|
|
334
1019
|
return __awaiter(this, void 0, void 0, function* () {
|
|
335
1020
|
if (imageQuality < 1 || imageQuality > 100)
|
|
336
1021
|
throw new Error(`Invalid quality specifier (${imageQuality}) when compressing images. Quality must be between 1 and 100.`);
|
|
337
|
-
return yield (0, compress_1.compressImage)(yield this.
|
|
1022
|
+
return yield (0, compress_1.compressImage)(yield this.internal_getId(), imageQuality, scaleToVisibleSize);
|
|
338
1023
|
});
|
|
339
1024
|
}
|
|
340
1025
|
/**
|
|
@@ -342,9 +1027,9 @@ class PdfDocument {
|
|
|
342
1027
|
* Removing the "structure tree" can significantly reduce the disk space used by the document.
|
|
343
1028
|
* Removing the "structure tree" of a complicated document can negatively impact text selection.
|
|
344
1029
|
*/
|
|
345
|
-
|
|
1030
|
+
internal_compressStructTree() {
|
|
346
1031
|
return __awaiter(this, void 0, void 0, function* () {
|
|
347
|
-
return yield (0, compress_1.compressStructTree)(yield this.
|
|
1032
|
+
return yield (0, compress_1.compressStructTree)(yield this.internal_getId());
|
|
348
1033
|
});
|
|
349
1034
|
}
|
|
350
1035
|
//#endregion
|
|
@@ -352,17 +1037,17 @@ class PdfDocument {
|
|
|
352
1037
|
/**
|
|
353
1038
|
* Gets information of all pages in the PdfDocument
|
|
354
1039
|
*/
|
|
355
|
-
|
|
1040
|
+
internal_getPagesInfo() {
|
|
356
1041
|
return __awaiter(this, void 0, void 0, function* () {
|
|
357
|
-
return yield (0, page_1.getPageInfo)(yield this.
|
|
1042
|
+
return yield (0, page_1.getPageInfo)(yield this.internal_getId());
|
|
358
1043
|
});
|
|
359
1044
|
}
|
|
360
1045
|
/**
|
|
361
1046
|
* Gets the number of pages in the PdfDocument.
|
|
362
1047
|
*/
|
|
363
|
-
|
|
1048
|
+
internal_getPageCount() {
|
|
364
1049
|
return __awaiter(this, void 0, void 0, function* () {
|
|
365
|
-
return (yield this.
|
|
1050
|
+
return (yield this.internal_getPagesInfo()).length;
|
|
366
1051
|
});
|
|
367
1052
|
}
|
|
368
1053
|
/**
|
|
@@ -370,9 +1055,9 @@ class PdfDocument {
|
|
|
370
1055
|
* @param pageRotation see {@link PageRotation}
|
|
371
1056
|
* @param options including {@link PdfPageSelection}
|
|
372
1057
|
*/
|
|
373
|
-
|
|
1058
|
+
internal_setRotation(pageRotation, options) {
|
|
374
1059
|
return __awaiter(this, void 0, void 0, function* () {
|
|
375
|
-
return yield (0, page_1.setPageRotation)(yield this.
|
|
1060
|
+
return yield (0, page_1.setPageRotation)(yield this.internal_getId(), pageRotation, options);
|
|
376
1061
|
});
|
|
377
1062
|
}
|
|
378
1063
|
/**
|
|
@@ -380,9 +1065,9 @@ class PdfDocument {
|
|
|
380
1065
|
* @param newSize {@link PdfPaperSize}
|
|
381
1066
|
* @param options including {@link PdfPageSelection}
|
|
382
1067
|
*/
|
|
383
|
-
|
|
1068
|
+
internal_resize(newSize, options) {
|
|
384
1069
|
return __awaiter(this, void 0, void 0, function* () {
|
|
385
|
-
return yield (0, page_1.resizePage)(yield this.
|
|
1070
|
+
return yield (0, page_1.resizePage)(yield this.internal_getId(), newSize, options);
|
|
386
1071
|
});
|
|
387
1072
|
}
|
|
388
1073
|
/**
|
|
@@ -390,9 +1075,9 @@ class PdfDocument {
|
|
|
390
1075
|
* If AnotherPdfFile contains form fields, those fields will be appended with '_' in the resulting PDF. e.g. 'Name' will be 'Name_'
|
|
391
1076
|
* @param fromPdfDocument PdfDocument to prepend
|
|
392
1077
|
*/
|
|
393
|
-
|
|
1078
|
+
internal_prependAnotherPdf(fromPdfDocument) {
|
|
394
1079
|
return __awaiter(this, void 0, void 0, function* () {
|
|
395
|
-
yield this.
|
|
1080
|
+
yield this.internal_insertPagesFromAnotherPdf(fromPdfDocument, 0);
|
|
396
1081
|
});
|
|
397
1082
|
}
|
|
398
1083
|
/**
|
|
@@ -400,9 +1085,9 @@ class PdfDocument {
|
|
|
400
1085
|
* If AnotherPdfFile contains form fields, those fields will be appended with '_' in the resulting PDF. e.g. 'Name' will be 'Name_'
|
|
401
1086
|
* @param fromPdfDocument PdfDocument to Append
|
|
402
1087
|
*/
|
|
403
|
-
|
|
1088
|
+
internal_appendAnotherPdf(fromPdfDocument) {
|
|
404
1089
|
return __awaiter(this, void 0, void 0, function* () {
|
|
405
|
-
yield this.
|
|
1090
|
+
yield this.internal_insertPagesFromAnotherPdf(fromPdfDocument, (yield this.internal_getPageCount()) - 1);
|
|
406
1091
|
});
|
|
407
1092
|
}
|
|
408
1093
|
/**
|
|
@@ -411,28 +1096,28 @@ class PdfDocument {
|
|
|
411
1096
|
* @param fromPdfDocument Another PdfDocument
|
|
412
1097
|
* @param insertAtPageIndex Index at which to insert the new content. Note: Page 1 has index 0...
|
|
413
1098
|
*/
|
|
414
|
-
|
|
1099
|
+
internal_insertPagesFromAnotherPdf(fromPdfDocument, insertAtPageIndex) {
|
|
415
1100
|
return __awaiter(this, void 0, void 0, function* () {
|
|
416
|
-
yield (0, page_1.insertPdf)(yield this.
|
|
1101
|
+
yield (0, page_1.insertPdf)(yield this.internal_getId(), yield fromPdfDocument.internal_getId(), insertAtPageIndex);
|
|
417
1102
|
});
|
|
418
1103
|
}
|
|
419
1104
|
/**
|
|
420
1105
|
* Removes a range of pages from the PDF
|
|
421
1106
|
* @param pages pages to remove
|
|
422
1107
|
*/
|
|
423
|
-
|
|
1108
|
+
internal_removePage(pages) {
|
|
424
1109
|
return __awaiter(this, void 0, void 0, function* () {
|
|
425
|
-
yield (0, page_1.removePage)(yield this.
|
|
1110
|
+
yield (0, page_1.removePage)(yield this.internal_getId(), { PdfPageSelection: pages });
|
|
426
1111
|
});
|
|
427
1112
|
}
|
|
428
1113
|
/**
|
|
429
1114
|
* Creates a new PDF by copying a range of pages from this {@link PdfDocument}.
|
|
430
1115
|
* @param pages pages to copy (default "all")
|
|
431
1116
|
*/
|
|
432
|
-
|
|
1117
|
+
internal_duplicate(pages = "all") {
|
|
433
1118
|
return __awaiter(this, void 0, void 0, function* () {
|
|
434
1119
|
const newPdf = new PdfDocument();
|
|
435
|
-
newPdf.pdfDocumentId = yield (0, page_1.duplicate)(yield this.
|
|
1120
|
+
newPdf.pdfDocumentId = yield (0, page_1.duplicate)(yield this.internal_getId(), {
|
|
436
1121
|
PdfPageSelection: pages,
|
|
437
1122
|
});
|
|
438
1123
|
return newPdf;
|
|
@@ -444,10 +1129,10 @@ class PdfDocument {
|
|
|
444
1129
|
* Finds all embedded Images from within a specified pages in the PDF and returns them as Buffer
|
|
445
1130
|
* @param options including {@link PdfPageSelection}
|
|
446
1131
|
*/
|
|
447
|
-
|
|
1132
|
+
internal_extractRawImages(options) {
|
|
448
1133
|
var _a;
|
|
449
1134
|
return __awaiter(this, void 0, void 0, function* () {
|
|
450
|
-
return (0, image_2.extractRawImages)(yield this.
|
|
1135
|
+
return (0, image_2.extractRawImages)(yield this.internal_getId(), (_a = options === null || options === void 0 ? void 0 : options.fromPages) !== null && _a !== void 0 ? _a : "all");
|
|
451
1136
|
});
|
|
452
1137
|
}
|
|
453
1138
|
/**
|
|
@@ -458,10 +1143,10 @@ class PdfDocument {
|
|
|
458
1143
|
*
|
|
459
1144
|
* @return array of images as Buffer[]
|
|
460
1145
|
*/
|
|
461
|
-
|
|
1146
|
+
internal_rasterizeToImageBuffers(options) {
|
|
462
1147
|
var _a;
|
|
463
1148
|
return __awaiter(this, void 0, void 0, function* () {
|
|
464
|
-
const images = yield (0, image_2.rasterizeToImageBuffers)(yield this.
|
|
1149
|
+
const images = yield (0, image_2.rasterizeToImageBuffers)(yield this.internal_getId(), (_a = options === null || options === void 0 ? void 0 : options.fromPages) !== null && _a !== void 0 ? _a : "all");
|
|
465
1150
|
const jimpImageType = (() => {
|
|
466
1151
|
switch (options === null || options === void 0 ? void 0 : options.imageType) {
|
|
467
1152
|
case types_1.ImageType.BMP:
|
|
@@ -490,10 +1175,10 @@ class PdfDocument {
|
|
|
490
1175
|
*
|
|
491
1176
|
* @return array of images file name as string[]
|
|
492
1177
|
*/
|
|
493
|
-
|
|
1178
|
+
internal_rasterizeToImageFiles(filePath, options) {
|
|
494
1179
|
var _a;
|
|
495
1180
|
return __awaiter(this, void 0, void 0, function* () {
|
|
496
|
-
const images = yield (0, image_2.rasterizeToImageBuffers)(yield this.
|
|
1181
|
+
const images = yield (0, image_2.rasterizeToImageBuffers)(yield this.internal_getId(), (_a = options === null || options === void 0 ? void 0 : options.fromPages) !== null && _a !== void 0 ? _a : "all");
|
|
497
1182
|
const filesName = (0, util_1.getFileNames)(filePath, images.length, (0, util_1.getImageExtType)(options === null || options === void 0 ? void 0 : options.type), "image");
|
|
498
1183
|
const promises = images.map((imageBuffer, index) => __awaiter(this, void 0, void 0, function* () {
|
|
499
1184
|
yield jimp_1.default.read(imageBuffer).then((value) => value.write(filesName[index]));
|
|
@@ -510,14 +1195,14 @@ class PdfDocument {
|
|
|
510
1195
|
* @param newText New text to add
|
|
511
1196
|
* @param onPages Page index to search for old text to replace (default "all")
|
|
512
1197
|
*/
|
|
513
|
-
|
|
1198
|
+
internal_replaceText(oldText, newText, onPages) {
|
|
514
1199
|
return __awaiter(this, void 0, void 0, function* () {
|
|
515
|
-
return (0, text_1.replaceText)(yield this.
|
|
1200
|
+
return (0, text_1.replaceText)(yield this.internal_getId(), oldText, newText, onPages);
|
|
516
1201
|
});
|
|
517
1202
|
}
|
|
518
|
-
|
|
1203
|
+
internal_extractText(onPages) {
|
|
519
1204
|
return __awaiter(this, void 0, void 0, function* () {
|
|
520
|
-
return (0, text_1.extractAllText)(yield this.
|
|
1205
|
+
return (0, text_1.extractAllText)(yield this.internal_getId(), onPages);
|
|
521
1206
|
});
|
|
522
1207
|
}
|
|
523
1208
|
//#endregion
|
|
@@ -526,17 +1211,17 @@ class PdfDocument {
|
|
|
526
1211
|
* Convert the current document into the specified PDF-A standard format
|
|
527
1212
|
* @param customICC (Optional) Custom color profile file path
|
|
528
1213
|
*/
|
|
529
|
-
|
|
1214
|
+
internal_convertToPdfA(customICC) {
|
|
530
1215
|
return __awaiter(this, void 0, void 0, function* () {
|
|
531
|
-
return yield (0, pdfa_1.toPdfA)(yield this.
|
|
1216
|
+
return yield (0, pdfa_1.toPdfA)(yield this.internal_getId(), customICC);
|
|
532
1217
|
});
|
|
533
1218
|
}
|
|
534
1219
|
/**
|
|
535
1220
|
* Convert the current document into the specified PDF/UA standard format
|
|
536
1221
|
*/
|
|
537
|
-
|
|
1222
|
+
internal_convertToPdfUA() {
|
|
538
1223
|
return __awaiter(this, void 0, void 0, function* () {
|
|
539
|
-
return yield (0, pdfa_1.toPdfUA)(yield this.
|
|
1224
|
+
return yield (0, pdfa_1.toPdfUA)(yield this.internal_getId());
|
|
540
1225
|
});
|
|
541
1226
|
}
|
|
542
1227
|
//#endregion
|
|
@@ -544,9 +1229,9 @@ class PdfDocument {
|
|
|
544
1229
|
/**
|
|
545
1230
|
* Gets a Map<string, string> of metadata properties
|
|
546
1231
|
*/
|
|
547
|
-
|
|
1232
|
+
internal_getMetadata() {
|
|
548
1233
|
return __awaiter(this, void 0, void 0, function* () {
|
|
549
|
-
return (0, metadata_1.getMetadataDict)(yield this.
|
|
1234
|
+
return (0, metadata_1.getMetadataDict)(yield this.internal_getId());
|
|
550
1235
|
});
|
|
551
1236
|
}
|
|
552
1237
|
/**
|
|
@@ -554,27 +1239,27 @@ class PdfDocument {
|
|
|
554
1239
|
* @param key
|
|
555
1240
|
* @param value
|
|
556
1241
|
*/
|
|
557
|
-
|
|
1242
|
+
internal_addOrUpdateMetadata(key, value) {
|
|
558
1243
|
return __awaiter(this, void 0, void 0, function* () {
|
|
559
|
-
return (0, metadata_1.setMetadata)(yield this.
|
|
1244
|
+
return (0, metadata_1.setMetadata)(yield this.internal_getId(), key, value);
|
|
560
1245
|
});
|
|
561
1246
|
}
|
|
562
1247
|
/**
|
|
563
1248
|
* Remove a single metadata property
|
|
564
1249
|
* @param key
|
|
565
1250
|
*/
|
|
566
|
-
|
|
1251
|
+
internal_removeMetadata(key) {
|
|
567
1252
|
return __awaiter(this, void 0, void 0, function* () {
|
|
568
|
-
return (0, metadata_1.removeMetadata)(yield this.
|
|
1253
|
+
return (0, metadata_1.removeMetadata)(yield this.internal_getId(), key);
|
|
569
1254
|
});
|
|
570
1255
|
}
|
|
571
1256
|
/**
|
|
572
1257
|
* Sets a whole metadata properties Map<string, string> (override all the metadata property)
|
|
573
1258
|
* @param newMetadataDictionary new metadata properties Map<string, string>
|
|
574
1259
|
*/
|
|
575
|
-
|
|
1260
|
+
internal_overrideMetadata(newMetadataDictionary) {
|
|
576
1261
|
return __awaiter(this, void 0, void 0, function* () {
|
|
577
|
-
return (0, metadata_1.setMetadataDict)(yield this.
|
|
1262
|
+
return (0, metadata_1.setMetadataDict)(yield this.internal_getId(), newMetadataDictionary);
|
|
578
1263
|
});
|
|
579
1264
|
}
|
|
580
1265
|
//#endregion
|
|
@@ -587,26 +1272,26 @@ class PdfDocument {
|
|
|
587
1272
|
* Multiple certificates may be used.
|
|
588
1273
|
* @param signature see {@link DigitalSignature}
|
|
589
1274
|
*/
|
|
590
|
-
|
|
1275
|
+
internal_signDigitalSignature(signature) {
|
|
591
1276
|
return __awaiter(this, void 0, void 0, function* () {
|
|
592
|
-
return yield (0, signing_1.signPdf)(yield this.
|
|
1277
|
+
return yield (0, signing_1.signPdf)(yield this.internal_getId(), signature);
|
|
593
1278
|
});
|
|
594
1279
|
}
|
|
595
1280
|
/**
|
|
596
1281
|
* Check if PdfDocument was signed or not
|
|
597
1282
|
*/
|
|
598
|
-
|
|
1283
|
+
internal_isSigned() {
|
|
599
1284
|
return __awaiter(this, void 0, void 0, function* () {
|
|
600
|
-
const signatureCount = yield (0, signing_1.getSignatureCount)(yield this.
|
|
1285
|
+
const signatureCount = yield (0, signing_1.getSignatureCount)(yield this.internal_getId());
|
|
601
1286
|
return signatureCount > 0;
|
|
602
1287
|
});
|
|
603
1288
|
}
|
|
604
1289
|
/**
|
|
605
1290
|
* Count the number signature that signed to this PdfDocument
|
|
606
1291
|
*/
|
|
607
|
-
|
|
1292
|
+
internal_signatureCount() {
|
|
608
1293
|
return __awaiter(this, void 0, void 0, function* () {
|
|
609
|
-
return yield (0, signing_1.getSignatureCount)(yield this.
|
|
1294
|
+
return yield (0, signing_1.getSignatureCount)(yield this.internal_getId());
|
|
610
1295
|
});
|
|
611
1296
|
}
|
|
612
1297
|
//#endregion
|
|
@@ -616,9 +1301,9 @@ class PdfDocument {
|
|
|
616
1301
|
* @param header {@link TextAffix}
|
|
617
1302
|
* @param toPages {@link PdfPageSelection}
|
|
618
1303
|
*/
|
|
619
|
-
|
|
1304
|
+
internal_addTextHeader(header, toPages) {
|
|
620
1305
|
return __awaiter(this, void 0, void 0, function* () {
|
|
621
|
-
yield (0, headerFooter_1.addTextAffix)(yield this.
|
|
1306
|
+
yield (0, headerFooter_1.addTextAffix)(yield this.internal_getId(), toPages, header, true);
|
|
622
1307
|
});
|
|
623
1308
|
}
|
|
624
1309
|
/**
|
|
@@ -626,9 +1311,9 @@ class PdfDocument {
|
|
|
626
1311
|
* @param footer {@link TextAffix}
|
|
627
1312
|
* @param toPages {@link PdfPageSelection}
|
|
628
1313
|
*/
|
|
629
|
-
|
|
1314
|
+
internal_addTextFooter(footer, toPages) {
|
|
630
1315
|
return __awaiter(this, void 0, void 0, function* () {
|
|
631
|
-
yield (0, headerFooter_1.addTextAffix)(yield this.
|
|
1316
|
+
yield (0, headerFooter_1.addTextAffix)(yield this.internal_getId(), toPages, footer, false);
|
|
632
1317
|
});
|
|
633
1318
|
}
|
|
634
1319
|
/**
|
|
@@ -636,9 +1321,9 @@ class PdfDocument {
|
|
|
636
1321
|
* @param header {@link HtmlAffix}
|
|
637
1322
|
* @param toPages {@link PdfPageSelection}
|
|
638
1323
|
*/
|
|
639
|
-
|
|
1324
|
+
internal_addHtmlHeader(header, toPages) {
|
|
640
1325
|
return __awaiter(this, void 0, void 0, function* () {
|
|
641
|
-
yield (0, headerFooter_1.addHtmlAffix)(yield this.
|
|
1326
|
+
yield (0, headerFooter_1.addHtmlAffix)(yield this.internal_getId(), toPages, header, true);
|
|
642
1327
|
});
|
|
643
1328
|
}
|
|
644
1329
|
/**
|
|
@@ -646,9 +1331,9 @@ class PdfDocument {
|
|
|
646
1331
|
* @param footer {@link HtmlAffix}
|
|
647
1332
|
* @param toPages {@link PdfPageSelection}
|
|
648
1333
|
*/
|
|
649
|
-
|
|
1334
|
+
internal_addHtmlFooter(footer, toPages) {
|
|
650
1335
|
return __awaiter(this, void 0, void 0, function* () {
|
|
651
|
-
yield (0, headerFooter_1.addHtmlAffix)(yield this.
|
|
1336
|
+
yield (0, headerFooter_1.addHtmlAffix)(yield this.internal_getId(), toPages, footer, false);
|
|
652
1337
|
});
|
|
653
1338
|
}
|
|
654
1339
|
//#endregion
|
|
@@ -658,13 +1343,13 @@ class PdfDocument {
|
|
|
658
1343
|
* @param htmlStringOrHtmlFilePath
|
|
659
1344
|
* @param options including {@link HtmlStampOptions} {@link PdfPageSelection}
|
|
660
1345
|
*/
|
|
661
|
-
|
|
1346
|
+
internal_stampHtml(htmlStringOrHtmlFilePath, options) {
|
|
662
1347
|
return __awaiter(this, void 0, void 0, function* () {
|
|
663
1348
|
const html = htmlStringOrHtmlFilePath.endsWith(".html") ||
|
|
664
1349
|
htmlStringOrHtmlFilePath.endsWith(".htm")
|
|
665
|
-
?
|
|
1350
|
+
? fs_1.default.readFileSync(htmlStringOrHtmlFilePath).toString()
|
|
666
1351
|
: htmlStringOrHtmlFilePath;
|
|
667
|
-
yield (0, stamp_1.stampHtml)(yield this.
|
|
1352
|
+
yield (0, stamp_1.stampHtml)(yield this.internal_getId(), html, {
|
|
668
1353
|
password: this.pdfPassword,
|
|
669
1354
|
htmlStampOptions: options === null || options === void 0 ? void 0 : options.htmlStampOptions,
|
|
670
1355
|
pageSelection: options === null || options === void 0 ? void 0 : options.toPages,
|
|
@@ -676,12 +1361,12 @@ class PdfDocument {
|
|
|
676
1361
|
* @param image image file path or image buffer
|
|
677
1362
|
* @param options including {@link ImageStampOptions} {@link PdfPageSelection}
|
|
678
1363
|
*/
|
|
679
|
-
|
|
1364
|
+
internal_stampImage(image, options) {
|
|
680
1365
|
return __awaiter(this, void 0, void 0, function* () {
|
|
681
|
-
const imageBuffer = image instanceof buffer_1.Buffer ? image :
|
|
682
|
-
yield (0, stamp_1.stampImage)(yield this.
|
|
1366
|
+
const imageBuffer = image instanceof buffer_1.Buffer ? image : fs_1.default.readFileSync(image);
|
|
1367
|
+
yield (0, stamp_1.stampImage)(yield this.internal_getId(), imageBuffer, {
|
|
683
1368
|
password: this.pdfPassword,
|
|
684
|
-
|
|
1369
|
+
imageStampOptions: options === null || options === void 0 ? void 0 : options.imageStampOptions,
|
|
685
1370
|
pageSelection: options === null || options === void 0 ? void 0 : options.toPages,
|
|
686
1371
|
});
|
|
687
1372
|
});
|
|
@@ -691,11 +1376,11 @@ class PdfDocument {
|
|
|
691
1376
|
* @param text text to stamp
|
|
692
1377
|
* @param options including {@link TextStampOptions} {@link PdfPageSelection}
|
|
693
1378
|
*/
|
|
694
|
-
|
|
1379
|
+
internal_stampText(text, options) {
|
|
695
1380
|
return __awaiter(this, void 0, void 0, function* () {
|
|
696
|
-
yield (0, stamp_1.stampText)(yield this.
|
|
1381
|
+
yield (0, stamp_1.stampText)(yield this.internal_getId(), text, {
|
|
697
1382
|
password: this.pdfPassword,
|
|
698
|
-
|
|
1383
|
+
textStampOptions: options === null || options === void 0 ? void 0 : options.textStampOptions,
|
|
699
1384
|
pageSelection: options === null || options === void 0 ? void 0 : options.toPages,
|
|
700
1385
|
});
|
|
701
1386
|
});
|
|
@@ -705,11 +1390,11 @@ class PdfDocument {
|
|
|
705
1390
|
* @param barcodeValue barcode
|
|
706
1391
|
* @param options including {@link BarcodeType} {@link BarcodeStampOptions} {@link PdfPageSelection}
|
|
707
1392
|
*/
|
|
708
|
-
|
|
1393
|
+
internal_stampBarcode(barcodeValue, options) {
|
|
709
1394
|
return __awaiter(this, void 0, void 0, function* () {
|
|
710
|
-
yield (0, stamp_1.stampBarcode)(yield this.
|
|
1395
|
+
yield (0, stamp_1.stampBarcode)(yield this.internal_getId(), barcodeValue, {
|
|
711
1396
|
password: this.pdfPassword,
|
|
712
|
-
|
|
1397
|
+
barcodeStampOptions: options === null || options === void 0 ? void 0 : options.barcodeStampOptions,
|
|
713
1398
|
pageSelection: options === null || options === void 0 ? void 0 : options.toPages,
|
|
714
1399
|
});
|
|
715
1400
|
});
|
|
@@ -724,9 +1409,9 @@ class PdfDocument {
|
|
|
724
1409
|
* @param sourcePageIndex Index (zero-based page number) of the page to copy from the Background/Foreground PDF. Default is 0.
|
|
725
1410
|
* @param applyToPages PageSelection to which the background/foreground will be added. Default is "all"
|
|
726
1411
|
*/
|
|
727
|
-
|
|
1412
|
+
internal_addBackgroundFromAnotherPdf(fromPdf, sourcePageIndex = 0, applyToPages) {
|
|
728
1413
|
return __awaiter(this, void 0, void 0, function* () {
|
|
729
|
-
return yield (0, BackgroundForeground_1.addBackgroundForeground)(yield this.
|
|
1414
|
+
return yield (0, BackgroundForeground_1.addBackgroundForeground)(yield this.internal_getId(), yield fromPdf.internal_getId(), sourcePageIndex, true, applyToPages);
|
|
730
1415
|
});
|
|
731
1416
|
}
|
|
732
1417
|
/**
|
|
@@ -737,9 +1422,9 @@ class PdfDocument {
|
|
|
737
1422
|
* @param sourcePageIndex Index (zero-based page number) of the page to copy from the Background/Foreground PDF. Default is 0.
|
|
738
1423
|
* @param applyToPages PageSelection to which the background/foreground will be added. Default is "all"
|
|
739
1424
|
*/
|
|
740
|
-
|
|
1425
|
+
internal_addForegroundFromAnotherPdf(fromPdf, sourcePageIndex = 0, applyToPages) {
|
|
741
1426
|
return __awaiter(this, void 0, void 0, function* () {
|
|
742
|
-
return yield (0, BackgroundForeground_1.addBackgroundForeground)(yield this.
|
|
1427
|
+
return yield (0, BackgroundForeground_1.addBackgroundForeground)(yield this.internal_getId(), yield fromPdf.internal_getId(), sourcePageIndex, false, applyToPages);
|
|
743
1428
|
});
|
|
744
1429
|
}
|
|
745
1430
|
//#endregion
|
|
@@ -749,22 +1434,22 @@ class PdfDocument {
|
|
|
749
1434
|
* encryption.
|
|
750
1435
|
* If content is encrypted at 128 bit, copy and paste of content, annotations and form editing may be disabled.
|
|
751
1436
|
*/
|
|
752
|
-
|
|
1437
|
+
internal_removePasswordsAndEncryption() {
|
|
753
1438
|
return __awaiter(this, void 0, void 0, function* () {
|
|
754
|
-
yield (0, security_1.removePasswordsAndEncryption)(yield this.
|
|
1439
|
+
yield (0, security_1.removePasswordsAndEncryption)(yield this.internal_getId());
|
|
755
1440
|
});
|
|
756
1441
|
}
|
|
757
1442
|
/**
|
|
758
1443
|
* Sets the user password and enables 128Bit encryption of PDF content.
|
|
759
1444
|
* A user password is a password that each user must enter to open or print the PDF document.
|
|
760
1445
|
*/
|
|
761
|
-
|
|
1446
|
+
internal_setUserPassword(userPassword) {
|
|
762
1447
|
return __awaiter(this, void 0, void 0, function* () {
|
|
763
1448
|
if (!this.pdfPassword)
|
|
764
1449
|
this.pdfPassword = { userPassword: userPassword };
|
|
765
1450
|
else
|
|
766
1451
|
this.pdfPassword.userPassword = userPassword;
|
|
767
|
-
this.pdfDocumentId = yield (0, security_1.setUserPasswords)(yield this.
|
|
1452
|
+
this.pdfDocumentId = yield (0, security_1.setUserPasswords)(yield this.internal_getId(), userPassword);
|
|
768
1453
|
});
|
|
769
1454
|
}
|
|
770
1455
|
/**
|
|
@@ -774,31 +1459,31 @@ class PdfDocument {
|
|
|
774
1459
|
* {@link PdfPermission.AllowFillForms}, {@link PdfPermission.AllowPrint}, {@link PdfPermission.AllowModify} to be
|
|
775
1460
|
* restricted.
|
|
776
1461
|
*/
|
|
777
|
-
|
|
1462
|
+
internal_setOwnerPassword(ownerPassword) {
|
|
778
1463
|
return __awaiter(this, void 0, void 0, function* () {
|
|
779
1464
|
if (!this.pdfPassword)
|
|
780
1465
|
this.pdfPassword = { ownerPassword: ownerPassword };
|
|
781
1466
|
else
|
|
782
1467
|
this.pdfPassword.ownerPassword = ownerPassword;
|
|
783
|
-
this.pdfDocumentId = yield (0, security_1.setOwnerPasswords)(yield this.
|
|
1468
|
+
this.pdfDocumentId = yield (0, security_1.setOwnerPasswords)(yield this.internal_getId(), ownerPassword);
|
|
784
1469
|
});
|
|
785
1470
|
}
|
|
786
1471
|
/**
|
|
787
1472
|
* Sets the permissions of this PdfDocument
|
|
788
1473
|
* @param permissions see {@link PdfPermission}
|
|
789
1474
|
*/
|
|
790
|
-
|
|
1475
|
+
internal_setPermission(permissions) {
|
|
791
1476
|
return __awaiter(this, void 0, void 0, function* () {
|
|
792
|
-
this.pdfDocumentId = yield (0, security_1.setSecurity)(yield this.
|
|
1477
|
+
this.pdfDocumentId = yield (0, security_1.setSecurity)(yield this.internal_getId(), permissions);
|
|
793
1478
|
});
|
|
794
1479
|
}
|
|
795
1480
|
/**
|
|
796
1481
|
* Gets the current permissions of this PdfDocument
|
|
797
1482
|
* @return {@link PdfPermission}
|
|
798
1483
|
*/
|
|
799
|
-
|
|
1484
|
+
internal_getPermission() {
|
|
800
1485
|
return __awaiter(this, void 0, void 0, function* () {
|
|
801
|
-
return yield (0, security_1.getPermission)(yield this.
|
|
1486
|
+
return yield (0, security_1.getPermission)(yield this.internal_getId());
|
|
802
1487
|
});
|
|
803
1488
|
}
|
|
804
1489
|
/**
|
|
@@ -807,10 +1492,10 @@ class PdfDocument {
|
|
|
807
1492
|
* @param ownerPassword The owner password for the PDF. A string for owner password is required to enable PDF encryption and
|
|
808
1493
|
* all document security options.
|
|
809
1494
|
*/
|
|
810
|
-
|
|
1495
|
+
internal_makePdfDocumentReadOnly(ownerPassword) {
|
|
811
1496
|
return __awaiter(this, void 0, void 0, function* () {
|
|
812
|
-
yield this.
|
|
813
|
-
yield this.
|
|
1497
|
+
yield this.internal_setOwnerPassword(ownerPassword);
|
|
1498
|
+
yield this.internal_setPermission({
|
|
814
1499
|
AllowExtractContent: false,
|
|
815
1500
|
AllowAccessibilityExtractContent: false,
|
|
816
1501
|
AllowAnnotations: false,
|