@c9up/vellum 0.1.0
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/LICENSE +21 -0
- package/README.md +473 -0
- package/dist/Vellum.d.ts +460 -0
- package/dist/Vellum.d.ts.map +1 -0
- package/dist/Vellum.js +479 -0
- package/dist/Vellum.js.map +1 -0
- package/dist/VellumProvider.d.ts +28 -0
- package/dist/VellumProvider.d.ts.map +1 -0
- package/dist/VellumProvider.js +33 -0
- package/dist/VellumProvider.js.map +1 -0
- package/dist/augmentations.d.ts +22 -0
- package/dist/augmentations.d.ts.map +1 -0
- package/dist/augmentations.js +16 -0
- package/dist/augmentations.js.map +1 -0
- package/dist/config.d.ts +33 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +31 -0
- package/dist/config.js.map +1 -0
- package/dist/configure.d.ts +17 -0
- package/dist/configure.d.ts.map +1 -0
- package/dist/configure.js +78 -0
- package/dist/configure.js.map +1 -0
- package/dist/errors.d.ts +9 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +19 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +44 -0
- package/dist/index.js.map +1 -0
- package/dist/native/generated.d.ts +255 -0
- package/dist/native/generated.d.ts.map +1 -0
- package/dist/native/generated.js +7 -0
- package/dist/native/generated.js.map +1 -0
- package/dist/native.d.ts +50 -0
- package/dist/native.d.ts.map +1 -0
- package/dist/native.js +194 -0
- package/dist/native.js.map +1 -0
- package/dist/responder.d.ts +29 -0
- package/dist/responder.d.ts.map +1 -0
- package/dist/responder.js +101 -0
- package/dist/responder.js.map +1 -0
- package/dist/services/main.d.ts +15 -0
- package/dist/services/main.d.ts.map +1 -0
- package/dist/services/main.js +39 -0
- package/dist/services/main.js.map +1 -0
- package/dist/signers.d.ts +81 -0
- package/dist/signers.d.ts.map +1 -0
- package/dist/signers.js +98 -0
- package/dist/signers.js.map +1 -0
- package/index.darwin-arm64.node +0 -0
- package/index.darwin-x64.node +0 -0
- package/index.linux-arm64-gnu.node +0 -0
- package/index.linux-x64-gnu.node +0 -0
- package/index.win32-x64-msvc.node +0 -0
- package/package.json +67 -0
- package/scripts/build-napi-types.mjs +69 -0
- package/scripts/copy-napi.mjs +48 -0
- package/scripts/generate-metrics.py +150 -0
- package/scripts/generate-napi-types.mjs +156 -0
- package/src/Vellum.ts +829 -0
- package/src/VellumProvider.ts +51 -0
- package/src/augmentations.ts +25 -0
- package/src/config.ts +47 -0
- package/src/configure.ts +92 -0
- package/src/errors.ts +20 -0
- package/src/index.ts +74 -0
- package/src/native/generated.ts +375 -0
- package/src/native.ts +358 -0
- package/src/responder.ts +116 -0
- package/src/services/main.ts +48 -0
- package/src/signers.ts +149 -0
package/dist/config.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Define the rendering defaults, in `config/vellum.ts`.
|
|
3
|
+
*
|
|
4
|
+
* ```ts
|
|
5
|
+
* import { defineConfig } from '@c9up/vellum'
|
|
6
|
+
*
|
|
7
|
+
* export default defineConfig({
|
|
8
|
+
* format: 'jpeg',
|
|
9
|
+
* quality: 82,
|
|
10
|
+
* width: 1200,
|
|
11
|
+
* })
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* Named deviation: there is no `default` + service list here, because there is
|
|
15
|
+
* one rendering engine rather than several. Should a second one ever exist,
|
|
16
|
+
* that is when the manager gains `use()` — not before, when it would only be
|
|
17
|
+
* an indirection over a single implementation.
|
|
18
|
+
*/
|
|
19
|
+
export function defineConfig(config) {
|
|
20
|
+
const { format, ...rest } = config;
|
|
21
|
+
if (format === undefined)
|
|
22
|
+
return rest;
|
|
23
|
+
if (format !== "png" && format !== "jpeg") {
|
|
24
|
+
// Named at boot, with the value, rather than at the first render of a
|
|
25
|
+
// document nobody was looking at.
|
|
26
|
+
throw new Error(`[vellum] config/vellum.ts asks for format ${JSON.stringify(format)}; ` +
|
|
27
|
+
'it is "png" or "jpeg".');
|
|
28
|
+
}
|
|
29
|
+
return { ...rest, format: format };
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAcA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,YAAY,CAAC,MAAyB;IACrD,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;IACnC,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACtC,IAAI,MAAM,KAAK,KAAK,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;QAC3C,sEAAsE;QACtE,kCAAkC;QAClC,MAAM,IAAI,KAAK,CACd,6CAA6C,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI;YACtE,wBAAwB,CACzB,CAAC;IACH,CAAC;IACD,OAAO,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,MAAqB,EAAE,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ream configure @c9up/vellum` — wire PDF rendering in one command.
|
|
3
|
+
*
|
|
4
|
+
* The provider alone is not enough: it reads `config/vellum.ts`, and a package
|
|
5
|
+
* registered without one renders with defaults the application never chose.
|
|
6
|
+
* Writing both together is what makes `ream add` mean installed AND working.
|
|
7
|
+
*/
|
|
8
|
+
interface Codemods {
|
|
9
|
+
addProvider(importPath: string): Promise<void>;
|
|
10
|
+
addEnvVars(vars: Record<string, string>): Promise<void>;
|
|
11
|
+
writeFile(filePath: string, content: string, options?: {
|
|
12
|
+
force?: boolean;
|
|
13
|
+
}): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
export declare function configure(codemods: Codemods): Promise<void>;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=configure.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configure.d.ts","sourceRoot":"","sources":["../src/configure.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,UAAU,QAAQ;IACjB,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/C,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,SAAS,CACR,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,GAC3B,OAAO,CAAC,IAAI,CAAC,CAAC;CACjB;AAED,wBAAsB,SAAS,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAyEjE"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ream configure @c9up/vellum` — wire PDF rendering in one command.
|
|
3
|
+
*
|
|
4
|
+
* The provider alone is not enough: it reads `config/vellum.ts`, and a package
|
|
5
|
+
* registered without one renders with defaults the application never chose.
|
|
6
|
+
* Writing both together is what makes `ream add` mean installed AND working.
|
|
7
|
+
*/
|
|
8
|
+
export async function configure(codemods) {
|
|
9
|
+
// The config below reads these, so they are declared here. Writing the file
|
|
10
|
+
// without them leaves an application whose config asks the environment for
|
|
11
|
+
// something nothing ever put there.
|
|
12
|
+
await codemods.addEnvVars({
|
|
13
|
+
VELLUM_FORMAT: "png",
|
|
14
|
+
});
|
|
15
|
+
await codemods.addProvider("@c9up/vellum/provider");
|
|
16
|
+
await codemods.writeFile("config/vellum.ts", `import { defineConfig } from '@c9up/vellum'
|
|
17
|
+
import env from '#start/env'
|
|
18
|
+
|
|
19
|
+
export default defineConfig({
|
|
20
|
+
// Defaults for every render. Any call can override them.
|
|
21
|
+
format: env.get('VELLUM_FORMAT', 'png'),
|
|
22
|
+
|
|
23
|
+
// 1 is 72 DPI — the page's natural size. Raise it for print, or set
|
|
24
|
+
// \`width\` instead when what matters is the pixel width of a preview.
|
|
25
|
+
scale: 1,
|
|
26
|
+
|
|
27
|
+
// Only read when the format is 'jpeg'.
|
|
28
|
+
quality: 82,
|
|
29
|
+
|
|
30
|
+
// A PDF paints no background of its own, so rendering it transparent
|
|
31
|
+
// makes black text invisible over a dark viewer.
|
|
32
|
+
background: '#ffffff',
|
|
33
|
+
|
|
34
|
+
// Fonts to write text with, by the name you ask for them by. A font
|
|
35
|
+
// declared here is embedded in the document, subsetted to the characters
|
|
36
|
+
// written, which lifts the WinAnsi limit of the standard fonts.
|
|
37
|
+
//
|
|
38
|
+
// fonts: {
|
|
39
|
+
// body: app.makePath('resources/fonts/Inter-Regular.ttf'),
|
|
40
|
+
// },
|
|
41
|
+
|
|
42
|
+
// Who may sign a document. A signer is handed the digest of what the
|
|
43
|
+
// signature covers and returns the CMS to embed — it never sees the
|
|
44
|
+
// document, which is what makes a key you hold and a key held by a
|
|
45
|
+
// certified provider the same interface.
|
|
46
|
+
//
|
|
47
|
+
// Wrap a signer in timestamped() to add a trusted timestamp, without which
|
|
48
|
+
// a signature stops being verifiable once its certificate expires.
|
|
49
|
+
//
|
|
50
|
+
// signers: {
|
|
51
|
+
// internal: pkcs8Signer({
|
|
52
|
+
// key: readFileSync(app.makePath('storage/signing.key.der')),
|
|
53
|
+
// certificate: readFileSync(app.makePath('storage/signing.crt.der')),
|
|
54
|
+
// }),
|
|
55
|
+
// stamped: timestamped(pkcs8Signer({ ... }), {
|
|
56
|
+
// url: 'https://freetsa.org/tsr',
|
|
57
|
+
// }),
|
|
58
|
+
// qualified: myProviderAdapter({ ... }),
|
|
59
|
+
// },
|
|
60
|
+
|
|
61
|
+
// Certificates to trust when CHECKING a signature — typically the roots
|
|
62
|
+
// your jurisdiction's supervisory body publishes as a trusted list. With
|
|
63
|
+
// none, every signature comes back untrusted, which is the honest answer.
|
|
64
|
+
//
|
|
65
|
+
// trustedAnchors: [
|
|
66
|
+
// readFileSync(app.makePath('storage/anchors/authority.pem')),
|
|
67
|
+
// ],
|
|
68
|
+
|
|
69
|
+
// Which revocation responders may be contacted when checkRevocation is
|
|
70
|
+
// asked for. The address comes out of the certificate inside the document
|
|
71
|
+
// being checked, so by default only public hosts are asked — a document
|
|
72
|
+
// does not get to point this server at your own network. Name yours here
|
|
73
|
+
// when your authority answers somewhere that rule excludes.
|
|
74
|
+
//
|
|
75
|
+
// allowedResponders: ['ocsp.internal.example'],
|
|
76
|
+
})`);
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=configure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configure.js","sourceRoot":"","sources":["../src/configure.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAYH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,QAAkB;IACjD,4EAA4E;IAC5E,2EAA2E;IAC3E,oCAAoC;IACpC,MAAM,QAAQ,CAAC,UAAU,CAAC;QACzB,aAAa,EAAE,KAAK;KACpB,CAAC,CAAC;IAEH,MAAM,QAAQ,CAAC,WAAW,CAAC,uBAAuB,CAAC,CAAC;IACpD,MAAM,QAAQ,CAAC,SAAS,CACvB,kBAAkB,EAClB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DC,CACD,CAAC;AACH,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VellumError — structured error for PDF operations.
|
|
3
|
+
*/
|
|
4
|
+
export declare class VellumError extends Error {
|
|
5
|
+
readonly code: string;
|
|
6
|
+
constructor(code: string, message: string, options?: ErrorOptions);
|
|
7
|
+
toString(): string;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,WAAY,SAAQ,KAAK;IACrC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEV,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;IAUxD,QAAQ,IAAI,MAAM;CAG3B"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VellumError — structured error for PDF operations.
|
|
3
|
+
*/
|
|
4
|
+
export class VellumError extends Error {
|
|
5
|
+
code;
|
|
6
|
+
constructor(code, message, options) {
|
|
7
|
+
super(message, options);
|
|
8
|
+
this.name = "VellumError";
|
|
9
|
+
// One namespace, one prefix. `E_` is what every framework code carries,
|
|
10
|
+
// and the package name after it says which package raised it. A code
|
|
11
|
+
// that already starts with `E_` passes through untouched, so a shared
|
|
12
|
+
// identifier keeps its exact spelling.
|
|
13
|
+
this.code = code.startsWith("E_") ? code : `E_VELLUM_${code}`;
|
|
14
|
+
}
|
|
15
|
+
toString() {
|
|
16
|
+
return `${this.name} [${this.code}]: ${this.message}`;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,KAAK;IAC5B,IAAI,CAAS;IAEtB,YAAY,IAAY,EAAE,OAAe,EAAE,OAAsB;QAChE,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,wEAAwE;QACxE,qEAAqE;QACrE,sEAAsE;QACtE,uCAAuC;QACvC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,IAAI,EAAE,CAAC;IAC/D,CAAC;IAEQ,QAAQ;QAChB,OAAO,GAAG,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;IACvD,CAAC;CACD"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @c9up/vellum — PDF toolkit.
|
|
3
|
+
*
|
|
4
|
+
* Rendering pages to images, reading text and metadata, reshaping documents,
|
|
5
|
+
* stamping them, filling and flattening their forms, and signing them. The
|
|
6
|
+
* engine is Rust behind NAPI, because PDF has no adequate JavaScript
|
|
7
|
+
* implementation — a capability the platform lacks, not an optimisation.
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* import vellum from '@c9up/vellum/services/main'
|
|
11
|
+
*
|
|
12
|
+
* const preview = await vellum.render(pdf, { page: 1, width: 1200 })
|
|
13
|
+
* const pages = await vellum.renderAll(pdf, { format: 'jpeg' })
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
import "./augmentations.js";
|
|
17
|
+
export { defineConfig } from "./config.js";
|
|
18
|
+
export { VellumError } from "./errors.js";
|
|
19
|
+
export type { DocumentInfo, DocumentMetadata, FormField, PageDimensions, PageSize, RevocationAnswer, SignatureReport, } from "./native.js";
|
|
20
|
+
export { isNativeAvailable, VellumNativeRequiredError } from "./native.js";
|
|
21
|
+
export type { ResponderPolicy } from "./responder.js";
|
|
22
|
+
export type { Pkcs8SignerOptions, TimestampOptions } from "./signers.js";
|
|
23
|
+
export { pkcs8Signer, timestamped } from "./signers.js";
|
|
24
|
+
export type { CheckedSignature, ImageFormat, PageOptions, RenderOptions, Signer, SignOptions, StampOptions, StandardFont, TextStampOptions, VellumConfig, VerifyOptions, } from "./Vellum.js";
|
|
25
|
+
export { Vellum } from "./Vellum.js";
|
|
26
|
+
import type { DocumentInfo, PageSize } from "./native.js";
|
|
27
|
+
/**
|
|
28
|
+
* Report the shape of a PDF: how many pages it has, which version of the
|
|
29
|
+
* format it claims, and whether it is encrypted.
|
|
30
|
+
*
|
|
31
|
+
* The `/Info` strings are read by {@link Vellum.metadata} instead, which has
|
|
32
|
+
* the decoder they need: they are stored in UTF-16BE, UTF-8 or
|
|
33
|
+
* PDFDocEncoding, and guessing between them mangles every accent.
|
|
34
|
+
*/
|
|
35
|
+
export declare function inspect(pdf: Buffer): DocumentInfo;
|
|
36
|
+
/**
|
|
37
|
+
* Author a document of blank pages, sized in points (72 per inch).
|
|
38
|
+
*
|
|
39
|
+
* Draw onto them with {@link Vellum.stamp} and {@link Vellum.stampText}.
|
|
40
|
+
*/
|
|
41
|
+
export declare function createBlank(pages: ReadonlyArray<PageSize>): Buffer;
|
|
42
|
+
/** A4 in points, the size every document here starts from. */
|
|
43
|
+
export declare const A4: PageSize;
|
|
44
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,oBAAoB,CAAC;AAE5B,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,YAAY,EACX,YAAY,EACZ,gBAAgB,EAChB,SAAS,EACT,cAAc,EACd,QAAQ,EACR,gBAAgB,EAChB,eAAe,GACf,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAC3E,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtD,YAAY,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACxD,YAAY,EACX,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,aAAa,EACb,MAAM,EACN,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,aAAa,GACb,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAG1D;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,CAEjD;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,aAAa,CAAC,QAAQ,CAAC,GAAG,MAAM,CAElE;AAED,8DAA8D;AAC9D,eAAO,MAAM,EAAE,EAAE,QAA4C,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @c9up/vellum — PDF toolkit.
|
|
3
|
+
*
|
|
4
|
+
* Rendering pages to images, reading text and metadata, reshaping documents,
|
|
5
|
+
* stamping them, filling and flattening their forms, and signing them. The
|
|
6
|
+
* engine is Rust behind NAPI, because PDF has no adequate JavaScript
|
|
7
|
+
* implementation — a capability the platform lacks, not an optimisation.
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* import vellum from '@c9up/vellum/services/main'
|
|
11
|
+
*
|
|
12
|
+
* const preview = await vellum.render(pdf, { page: 1, width: 1200 })
|
|
13
|
+
* const pages = await vellum.renderAll(pdf, { format: 'jpeg' })
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
import "./augmentations.js";
|
|
17
|
+
export { defineConfig } from "./config.js";
|
|
18
|
+
export { VellumError } from "./errors.js";
|
|
19
|
+
export { isNativeAvailable, VellumNativeRequiredError } from "./native.js";
|
|
20
|
+
export { pkcs8Signer, timestamped } from "./signers.js";
|
|
21
|
+
export { Vellum } from "./Vellum.js";
|
|
22
|
+
import { createBlankNative, inspectNative } from "./native.js";
|
|
23
|
+
/**
|
|
24
|
+
* Report the shape of a PDF: how many pages it has, which version of the
|
|
25
|
+
* format it claims, and whether it is encrypted.
|
|
26
|
+
*
|
|
27
|
+
* The `/Info` strings are read by {@link Vellum.metadata} instead, which has
|
|
28
|
+
* the decoder they need: they are stored in UTF-16BE, UTF-8 or
|
|
29
|
+
* PDFDocEncoding, and guessing between them mangles every accent.
|
|
30
|
+
*/
|
|
31
|
+
export function inspect(pdf) {
|
|
32
|
+
return inspectNative(pdf);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Author a document of blank pages, sized in points (72 per inch).
|
|
36
|
+
*
|
|
37
|
+
* Draw onto them with {@link Vellum.stamp} and {@link Vellum.stampText}.
|
|
38
|
+
*/
|
|
39
|
+
export function createBlank(pages) {
|
|
40
|
+
return createBlankNative(pages);
|
|
41
|
+
}
|
|
42
|
+
/** A4 in points, the size every document here starts from. */
|
|
43
|
+
export const A4 = { width: 595.28, height: 841.89 };
|
|
44
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,oBAAoB,CAAC;AAE5B,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAU1C,OAAO,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAG3E,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAcxD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE/D;;;;;;;GAOG;AACH,MAAM,UAAU,OAAO,CAAC,GAAW;IAClC,OAAO,aAAa,CAAC,GAAG,CAAC,CAAC;AAC3B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,KAA8B;IACzD,OAAO,iBAAiB,CAAC,KAAK,CAAC,CAAC;AACjC,CAAC;AAED,8DAA8D;AAC9D,MAAM,CAAC,MAAM,EAAE,GAAa,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
export interface DocumentInfo {
|
|
2
|
+
pageCount: number;
|
|
3
|
+
version: string;
|
|
4
|
+
encrypted: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface PageSize {
|
|
7
|
+
/** Width in points (72 per inch). A4 is 595.28. */
|
|
8
|
+
width: number;
|
|
9
|
+
/** Height in points. A4 is 841.89. */
|
|
10
|
+
height: number;
|
|
11
|
+
}
|
|
12
|
+
/** Rasterising options, as a plain JavaScript object. */
|
|
13
|
+
export interface RenderOptions {
|
|
14
|
+
/**
|
|
15
|
+
* Multiplier over the page's natural size, 1 being 72 DPI. Default 1.
|
|
16
|
+
* Ignored when `width` is given.
|
|
17
|
+
*/
|
|
18
|
+
scale?: number;
|
|
19
|
+
/** Target width in pixels. Wins over `scale`. */
|
|
20
|
+
width?: number;
|
|
21
|
+
/** `"png"` (default) or `"jpeg"`. */
|
|
22
|
+
format?: string;
|
|
23
|
+
/** JPEG quality, 1-100. Only valid alongside `format: "jpeg"`. */
|
|
24
|
+
quality?: number;
|
|
25
|
+
/** `#rgb`, `#rrggbb`, `#rrggbbaa` or `"transparent"`. Default opaque white. */
|
|
26
|
+
background?: string;
|
|
27
|
+
/**
|
|
28
|
+
* The most pixels one page may rasterise to. 50 million by default —
|
|
29
|
+
* room for A4 at 600 DPI. A page declares its own size, so without a
|
|
30
|
+
* ceiling a document alone could ask for gigabytes.
|
|
31
|
+
*/
|
|
32
|
+
maxPixels?: number;
|
|
33
|
+
}
|
|
34
|
+
export interface PageDimensions {
|
|
35
|
+
/** Width in points, before scaling. */
|
|
36
|
+
width: number;
|
|
37
|
+
/** Height in points, before scaling. */
|
|
38
|
+
height: number;
|
|
39
|
+
}
|
|
40
|
+
/** What the `/Info` dictionary says about a document. */
|
|
41
|
+
export interface DocumentMetadata {
|
|
42
|
+
title?: string;
|
|
43
|
+
author?: string;
|
|
44
|
+
subject?: string;
|
|
45
|
+
keywords?: string;
|
|
46
|
+
/** The application that authored the content. */
|
|
47
|
+
creator?: string;
|
|
48
|
+
/** The application that wrote the PDF. */
|
|
49
|
+
producer?: string;
|
|
50
|
+
/**
|
|
51
|
+
* ISO 8601 when the producer wrote a conforming date, otherwise the raw
|
|
52
|
+
* string it did write.
|
|
53
|
+
*/
|
|
54
|
+
createdAt?: string;
|
|
55
|
+
modifiedAt?: string;
|
|
56
|
+
}
|
|
57
|
+
/** Where and how an image is laid onto a page. */
|
|
58
|
+
export interface StampOptions {
|
|
59
|
+
/** Which page, counting from zero. Absent stamps every page. */
|
|
60
|
+
page?: number;
|
|
61
|
+
/** Points from the left edge. Default 0. */
|
|
62
|
+
x?: number;
|
|
63
|
+
/** Points from the TOP edge. Default 0. */
|
|
64
|
+
y?: number;
|
|
65
|
+
/** Drawn width in points. With `height` absent, the ratio is kept. */
|
|
66
|
+
width?: number;
|
|
67
|
+
/** Drawn height in points. With `width` absent, the ratio is kept. */
|
|
68
|
+
height?: number;
|
|
69
|
+
/** 0 is invisible, 1 is opaque. Default 1. */
|
|
70
|
+
opacity?: number;
|
|
71
|
+
}
|
|
72
|
+
/** Where and how a line of text is written onto a page. */
|
|
73
|
+
export interface TextStampOptions {
|
|
74
|
+
/** Which page, counting from zero. Absent writes on every page. */
|
|
75
|
+
page?: number;
|
|
76
|
+
/** Points from the left edge. Default 0. */
|
|
77
|
+
x?: number;
|
|
78
|
+
/** Points from the TOP edge, to the text's baseline. Default 0. */
|
|
79
|
+
y?: number;
|
|
80
|
+
/** Type size in points. Default 12. */
|
|
81
|
+
size?: number;
|
|
82
|
+
/**
|
|
83
|
+
* One of the 14 standard fonts, e.g. `"Helvetica"`, `"Times-Roman"`.
|
|
84
|
+
* Ignored when `fontData` is given.
|
|
85
|
+
*/
|
|
86
|
+
font?: string;
|
|
87
|
+
/**
|
|
88
|
+
* A TrueType or OpenType file to embed, subsetted to the text. Lifts the
|
|
89
|
+
* WinAnsi limit of the standard fonts, at the cost of carrying the glyphs
|
|
90
|
+
* in the document.
|
|
91
|
+
*/
|
|
92
|
+
fontData?: Buffer;
|
|
93
|
+
/** `#rgb` or `#rrggbb`. Default black. */
|
|
94
|
+
color?: string;
|
|
95
|
+
/** 0 is invisible, 1 is opaque. Default 1. */
|
|
96
|
+
opacity?: number;
|
|
97
|
+
}
|
|
98
|
+
/** One interactive field of a document's form. */
|
|
99
|
+
export interface FormField {
|
|
100
|
+
/**
|
|
101
|
+
* The fully qualified name — every ancestor's partial name joined with
|
|
102
|
+
* dots. This is the name used to fill the field in.
|
|
103
|
+
*/
|
|
104
|
+
name: string;
|
|
105
|
+
/**
|
|
106
|
+
* `"text"`, `"checkbox"`, `"radio"`, `"pushButton"`, `"dropdown"`,
|
|
107
|
+
* `"listBox"` or `"signature"`.
|
|
108
|
+
*/
|
|
109
|
+
kind: string;
|
|
110
|
+
value?: string;
|
|
111
|
+
/**
|
|
112
|
+
* What a choice field offers, or the states a checkbox and radio accept.
|
|
113
|
+
* A checkbox's "on" state is chosen by the document, so ticking it means
|
|
114
|
+
* writing one of these.
|
|
115
|
+
*/
|
|
116
|
+
options: Array<string>;
|
|
117
|
+
readOnly: boolean;
|
|
118
|
+
required: boolean;
|
|
119
|
+
multiline: boolean;
|
|
120
|
+
password: boolean;
|
|
121
|
+
maxLength?: number;
|
|
122
|
+
}
|
|
123
|
+
/** What the signature says about itself. */
|
|
124
|
+
export interface SignatureOptions {
|
|
125
|
+
/** Why the document was signed. */
|
|
126
|
+
reason?: string;
|
|
127
|
+
/** Where it was signed. */
|
|
128
|
+
location?: string;
|
|
129
|
+
/** How to reach the signatory. */
|
|
130
|
+
contact?: string;
|
|
131
|
+
/** Who signed, as it should be displayed. */
|
|
132
|
+
name?: string;
|
|
133
|
+
/** When, as an ISO 8601 instant. */
|
|
134
|
+
signedAt?: string;
|
|
135
|
+
/** Bytes reserved for the signature value. Default 16384. */
|
|
136
|
+
capacity?: number;
|
|
137
|
+
}
|
|
138
|
+
/** A document with room for a signature, and the digest to sign. */
|
|
139
|
+
export interface PreparedSignature {
|
|
140
|
+
document: Buffer;
|
|
141
|
+
/** SHA-256 of everything the signature covers. */
|
|
142
|
+
digest: Buffer;
|
|
143
|
+
}
|
|
144
|
+
/** A query for a timestamp authority, and the nonce it has to echo back. */
|
|
145
|
+
export interface TimestampQuery {
|
|
146
|
+
/** The DER to post to the authority. */
|
|
147
|
+
query: Buffer;
|
|
148
|
+
/** Opaque: hand it back to `attachTimestamp` unchanged. */
|
|
149
|
+
nonce: Buffer;
|
|
150
|
+
}
|
|
151
|
+
/** What one signature on a document turns out to be. */
|
|
152
|
+
export interface SignatureReport {
|
|
153
|
+
/** The field the signature sits in. */
|
|
154
|
+
field: string;
|
|
155
|
+
/** The signed range runs to the last byte, so nothing was appended after. */
|
|
156
|
+
coversWholeDocument: boolean;
|
|
157
|
+
/** The document's bytes hash to what the signature committed to. */
|
|
158
|
+
digestMatches: boolean;
|
|
159
|
+
/** The signature verifies against the certificate it carries. */
|
|
160
|
+
signatureVerifies: boolean;
|
|
161
|
+
/** Who the certificate says signed. */
|
|
162
|
+
signer?: string;
|
|
163
|
+
/** When the signature says it was made. */
|
|
164
|
+
signedAt?: string;
|
|
165
|
+
/** An authority has vouched for when, so it outlives the certificate. */
|
|
166
|
+
timestamped: boolean;
|
|
167
|
+
/** A path was found from the signer's certificate to a trusted anchor. */
|
|
168
|
+
trusted: boolean;
|
|
169
|
+
/** That path, the signer first and the anchor last. */
|
|
170
|
+
chain: Array<string>;
|
|
171
|
+
/**
|
|
172
|
+
* Where the instant used to judge the path came from: `"timestamp"`,
|
|
173
|
+
* `"claimed"` or `"unknown"`.
|
|
174
|
+
*/
|
|
175
|
+
moment: string;
|
|
176
|
+
/** That instant, in seconds since the epoch. */
|
|
177
|
+
momentAt?: number;
|
|
178
|
+
/** The certificate that signed, DER. */
|
|
179
|
+
signerCertificate?: Buffer;
|
|
180
|
+
/** The certificate that issued it, DER — who answers about revocation. */
|
|
181
|
+
issuerCertificate?: Buffer;
|
|
182
|
+
/** Everything that could not be checked, or checked out wrong. */
|
|
183
|
+
problems: Array<string>;
|
|
184
|
+
}
|
|
185
|
+
/** What a caller is willing to believe. */
|
|
186
|
+
export interface TrustOptions {
|
|
187
|
+
/**
|
|
188
|
+
* Certificates to trust as roots, DER or PEM. Without them nothing can be
|
|
189
|
+
* trusted, which is what the report will say.
|
|
190
|
+
*/
|
|
191
|
+
anchors?: Array<Buffer>;
|
|
192
|
+
}
|
|
193
|
+
/** What a responder's answer says. */
|
|
194
|
+
export interface RevocationAnswer {
|
|
195
|
+
/** `"good"`, `"revoked"` or `"unknown"`. */
|
|
196
|
+
status: string;
|
|
197
|
+
/** When it was withdrawn, or why nobody could be believed. */
|
|
198
|
+
detail?: string;
|
|
199
|
+
}
|
|
200
|
+
export declare function inspect(bytes: Buffer): DocumentInfo;
|
|
201
|
+
export declare function createBlank(pages: Array<PageSize>): Buffer;
|
|
202
|
+
export declare function renderPage(bytes: Buffer, pageIndex: number, options?: RenderOptions | undefined | null): Promise<Buffer>;
|
|
203
|
+
export declare function renderAll(bytes: Buffer, options?: RenderOptions | undefined | null): Promise<Buffer[]>;
|
|
204
|
+
export declare function pageDimensions(bytes: Buffer): Array<PageDimensions>;
|
|
205
|
+
export declare function metadata(bytes: Buffer): DocumentMetadata;
|
|
206
|
+
export declare function extractText(bytes: Buffer, pageIndex: number): Promise<string>;
|
|
207
|
+
export declare function extractTextAll(bytes: Buffer): Promise<string[]>;
|
|
208
|
+
export declare function merge(documents: Array<Buffer>): Promise<Buffer>;
|
|
209
|
+
export declare function selectPages(bytes: Buffer, pages: Array<number>): Promise<Buffer>;
|
|
210
|
+
export declare function split(bytes: Buffer): Promise<Buffer[]>;
|
|
211
|
+
export declare function rotate(bytes: Buffer, degrees: number, pages?: Array<number> | undefined | null): Promise<Buffer>;
|
|
212
|
+
export declare function stamp(pdf: Buffer, image: Buffer, options?: StampOptions | undefined | null): Promise<Buffer>;
|
|
213
|
+
export declare function stampText(pdf: Buffer, text: string, options?: TextStampOptions | undefined | null): Promise<Buffer>;
|
|
214
|
+
export declare function formFields(bytes: Buffer): Array<FormField>;
|
|
215
|
+
/**
|
|
216
|
+
* Fill the named fields. Keys are the fully qualified names `formFields`
|
|
217
|
+
* reports.
|
|
218
|
+
*/
|
|
219
|
+
export declare function fillForm(pdf: Buffer, values: Record<string, string>): Promise<Buffer>;
|
|
220
|
+
/** Paint every field into the page and drop the interactive layer. */
|
|
221
|
+
export declare function flattenForm(pdf: Buffer): Promise<Buffer>;
|
|
222
|
+
/** Write a document with room for a signature, and say what has to be signed. */
|
|
223
|
+
export declare function prepareSignature(pdf: Buffer, options?: SignatureOptions | undefined | null): Promise<PreparedSignature>;
|
|
224
|
+
/** Put the signature value into the space that was reserved for it. */
|
|
225
|
+
export declare function embedSignature(prepared: Buffer, value: Buffer): Promise<Buffer>;
|
|
226
|
+
/**
|
|
227
|
+
* Turn a digest into the CMS a PDF signature carries, with a key we hold.
|
|
228
|
+
*
|
|
229
|
+
* The key is PKCS#8 DER and the certificates are DER, the signer's first.
|
|
230
|
+
*/
|
|
231
|
+
export declare function signCms(digest: Buffer, key: Buffer, certificates: Array<Buffer>, signedAt: string): Promise<Buffer>;
|
|
232
|
+
/** Build the query to post to a timestamp authority. */
|
|
233
|
+
export declare function timestampQuery(cms: Buffer): TimestampQuery;
|
|
234
|
+
/** Attach the authority's answer to the signature. */
|
|
235
|
+
export declare function attachTimestamp(cms: Buffer, response: Buffer, nonce: Buffer): Buffer;
|
|
236
|
+
/**
|
|
237
|
+
* Report on every signature the document carries.
|
|
238
|
+
*
|
|
239
|
+
* This establishes integrity and authorship, not trust: it does not ask
|
|
240
|
+
* whether the certificate comes from an authority you accept, nor whether it
|
|
241
|
+
* has been revoked.
|
|
242
|
+
*/
|
|
243
|
+
export declare function verifySignatures(pdf: Buffer, trust?: TrustOptions | undefined | null): Promise<SignatureReport[]>;
|
|
244
|
+
/** The responder a certificate names, if it names one. */
|
|
245
|
+
export declare function responderUrl(certificate: Buffer): string | null;
|
|
246
|
+
/** Build the question to post to a revocation responder. */
|
|
247
|
+
export declare function revocationQuery(certificate: Buffer, issuer: Buffer): Buffer;
|
|
248
|
+
/**
|
|
249
|
+
* Read a responder's answer about a certificate.
|
|
250
|
+
*
|
|
251
|
+
* `at` is the instant the document was signed: a certificate withdrawn after
|
|
252
|
+
* that does not taint what it signed before.
|
|
253
|
+
*/
|
|
254
|
+
export declare function readRevocation(response: Buffer, certificate: Buffer, issuer: Buffer, at?: number | undefined | null): RevocationAnswer;
|
|
255
|
+
//# sourceMappingURL=generated.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated.d.ts","sourceRoot":"","sources":["../../src/native/generated.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,YAAY;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,QAAQ;IACxB,mDAAmD;IACnD,KAAK,EAAE,MAAM,CAAC;IACd,sCAAsC;IACtC,MAAM,EAAE,MAAM,CAAC;CACf;AAED,yDAAyD;AAEzD,MAAM,WAAW,aAAa;IAC7B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iDAAiD;IACjD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qCAAqC;IACrC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kEAAkE;IAClE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,+EAA+E;IAC/E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,SAAS,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AO,UAAU,eAAe,CACtC,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,GACX,MAAM,CAAC;AAEV;;;;;;GAMG;AAEH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CACvC,GAAG,EAAE,MAAM,EACX,KAAK,CAAC,EAAE,YAAY,GAAG,SAAS,GAAG,IAAI,GACrC,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;AAE9B,0DAA0D;AAE1D,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;AAEzE,4DAA4D;AAE5D,MAAM,CAAC,OAAO,UAAU,eAAe,CACtC,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,GACZ,MAAM,CAAC;AAEV;;;;;GAKG;AAEH,MAAM,CAAC,OAAO,UAAU,cAAc,CACrC,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,EACd,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAC5B,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// GENERATED FROM THE RUST — do not edit.
|
|
2
|
+
//
|
|
3
|
+
// Produced by scripts/generate-napi-types.mjs from napi-derive's type-def
|
|
4
|
+
// output. Editing this file by hand puts it back where it started: a
|
|
5
|
+
// description that can disagree with the code it describes.
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=generated.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated.js","sourceRoot":"","sources":["../../src/native/generated.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,0EAA0E;AAC1E,qEAAqE;AACrE,4DAA4D"}
|
package/dist/native.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loader for the Rust PDF engine.
|
|
3
|
+
*
|
|
4
|
+
* The engine is not optional. Parsing, authoring and rendering PDF have no
|
|
5
|
+
* JavaScript implementation in this package, so a missing binary is a hard
|
|
6
|
+
* failure with an actionable message — never a silent degradation that lets
|
|
7
|
+
* one deployment behave differently from another.
|
|
8
|
+
*/
|
|
9
|
+
import { VellumError } from "./errors.js";
|
|
10
|
+
import type { DocumentInfo, DocumentMetadata, FormField, SignatureOptions as NativeSignatureOptions, StampOptions as NativeStampOptions, TextStampOptions as NativeTextStampOptions, TrustOptions as NativeTrustOptions, PageDimensions, PageSize, PreparedSignature, RenderOptions, RevocationAnswer, SignatureReport, TimestampQuery } from "./native/generated.js";
|
|
11
|
+
export type { DocumentInfo, DocumentMetadata, FormField, PageDimensions, PageSize, PreparedSignature, RevocationAnswer, SignatureReport, } from "./native/generated.js";
|
|
12
|
+
export declare function isNativeAvailable(): boolean;
|
|
13
|
+
/** Raised when an operation needs the Rust engine and it is not there. */
|
|
14
|
+
export declare class VellumNativeRequiredError extends VellumError {
|
|
15
|
+
constructor();
|
|
16
|
+
}
|
|
17
|
+
export declare function inspectNative(pdf: Buffer): DocumentInfo;
|
|
18
|
+
export declare function createBlankNative(pages: ReadonlyArray<PageSize>): Buffer;
|
|
19
|
+
/**
|
|
20
|
+
* Rasterise one page, addressed from zero.
|
|
21
|
+
*
|
|
22
|
+
* The engine hands this to the libuv thread pool, so the returned promise
|
|
23
|
+
* settles without the calling thread ever blocking.
|
|
24
|
+
*/
|
|
25
|
+
export declare function renderPageNative(pdf: Buffer, pageIndex: number, options: RenderOptions): Promise<Buffer>;
|
|
26
|
+
/** Rasterise every page, in document order. */
|
|
27
|
+
export declare function renderAllNative(pdf: Buffer, options: RenderOptions): Promise<Buffer[]>;
|
|
28
|
+
export declare function pageDimensionsNative(pdf: Buffer): PageDimensions[];
|
|
29
|
+
export declare function metadataNative(pdf: Buffer): DocumentMetadata;
|
|
30
|
+
export declare function extractTextNative(pdf: Buffer, pageIndex: number): Promise<string>;
|
|
31
|
+
export declare function extractTextAllNative(pdf: Buffer): Promise<string[]>;
|
|
32
|
+
export declare function mergeNative(documents: ReadonlyArray<Buffer>): Promise<Buffer>;
|
|
33
|
+
export declare function selectPagesNative(pdf: Buffer, pageIndexes: ReadonlyArray<number>): Promise<Buffer>;
|
|
34
|
+
export declare function splitNative(pdf: Buffer): Promise<Buffer[]>;
|
|
35
|
+
export declare function rotateNative(pdf: Buffer, degrees: number, pageIndexes?: ReadonlyArray<number>): Promise<Buffer>;
|
|
36
|
+
export declare function stampNative(pdf: Buffer, image: Buffer, options: NativeStampOptions): Promise<Buffer>;
|
|
37
|
+
export declare function stampTextNative(pdf: Buffer, text: string, options: NativeTextStampOptions): Promise<Buffer>;
|
|
38
|
+
export declare function formFieldsNative(pdf: Buffer): FormField[];
|
|
39
|
+
export declare function fillFormNative(pdf: Buffer, values: Record<string, string>): Promise<Buffer>;
|
|
40
|
+
export declare function flattenFormNative(pdf: Buffer): Promise<Buffer>;
|
|
41
|
+
export declare function prepareSignatureNative(pdf: Buffer, options: NativeSignatureOptions): Promise<PreparedSignature>;
|
|
42
|
+
export declare function embedSignatureNative(prepared: Buffer, value: Buffer): Promise<Buffer>;
|
|
43
|
+
export declare function signCmsNative(digest: Buffer, key: Buffer, certificates: ReadonlyArray<Buffer>, signedAt: string): Promise<Buffer>;
|
|
44
|
+
export declare function timestampQueryNative(cms: Buffer): TimestampQuery;
|
|
45
|
+
export declare function attachTimestampNative(cms: Buffer, response: Buffer, nonce: Buffer): Buffer;
|
|
46
|
+
export declare function verifySignaturesNative(pdf: Buffer, trust: NativeTrustOptions): Promise<SignatureReport[]>;
|
|
47
|
+
export declare function responderUrlNative(certificate: Buffer): string | null;
|
|
48
|
+
export declare function revocationQueryNative(certificate: Buffer, issuer: Buffer): Buffer;
|
|
49
|
+
export declare function readRevocationNative(response: Buffer, certificate: Buffer, issuer: Buffer, at: number | null): RevocationAnswer;
|
|
50
|
+
//# sourceMappingURL=native.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
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