pdfcedar 0.1.0-beta.0 → 0.1.1-beta.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/README.md +238 -223
- package/bin/pdfcedar-assets.mjs +0 -0
- package/dist/chunks/{errors-Bd8CCmBG.js → errors-Cq5TPos_.js} +3 -3
- package/dist/chunks/pdf-Bt7uz0Yc.js +18800 -0
- package/dist/chunks/{src-xAKLPCPU.js → src-CyL6Tva1.js} +2 -2
- package/dist/index.d.cts +4 -0
- package/dist/index.js +978 -19693
- package/dist/index.umd.cjs +120 -85
- package/dist/pdfcedar.umd.js +1026 -0
- package/dist/types/core/annotation-geometry.d.cts +36 -0
- package/dist/types/core/annotation-manager.d.cts +97 -0
- package/dist/types/core/annotations.d.cts +106 -0
- package/dist/types/core/errors.d.cts +11 -0
- package/dist/types/core/errors.d.ts +5 -2
- package/dist/types/core/events.d.cts +10 -0
- package/dist/types/core/forms.d.cts +109 -0
- package/dist/types/core/index.d.cts +9 -0
- package/dist/types/core/types.d.cts +103 -0
- package/dist/types/core/types.d.ts +9 -0
- package/dist/types/core/undo.d.cts +47 -0
- package/dist/types/core/validate.d.cts +22 -0
- package/dist/viewer.d.cts +96 -0
- package/dist/viewer.d.ts +1 -1
- package/package.json +21 -17
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { type AnnotationInput, type AnnotationJSON, type AnnotationPatch, type ImportOptions, type ListFilter, type FitMode, type FormValues, type Handler, type Rect, type Rotation, type SearchResult, type ViewerEvents, type ViewerOptions } from './types/core/index.cjs';
|
|
2
|
+
export declare const VERSION = "0.1.1-beta.0";
|
|
3
|
+
export interface AnnotationsApi {
|
|
4
|
+
/** Validates, fills defaults (id, author from `user`, timestamps, colors) and returns the stored annotation. */
|
|
5
|
+
add(annotation: AnnotationInput): AnnotationJSON;
|
|
6
|
+
update(id: string, patch: AnnotationPatch): AnnotationJSON;
|
|
7
|
+
/** Also removes the annotation's reply thread. */
|
|
8
|
+
remove(id: string): void;
|
|
9
|
+
/** In z-order (last is on top). Optionally only one page and/or type. */
|
|
10
|
+
list(filter?: ListFilter): AnnotationJSON[];
|
|
11
|
+
export(): AnnotationJSON[];
|
|
12
|
+
/** All-or-nothing: if any entry is invalid, nothing changes. One undo step. */
|
|
13
|
+
import(json: AnnotationJSON[], options?: ImportOptions): void;
|
|
14
|
+
}
|
|
15
|
+
export interface PagesApi {
|
|
16
|
+
/** Rotates a page clockwise. Annotations on it turn with it. One undo step. */
|
|
17
|
+
rotate(page: number, degrees: Rotation): void;
|
|
18
|
+
/** Deletes a page and its annotations; later annotations move up a page. The last page can't be deleted. */
|
|
19
|
+
delete(page: number): void;
|
|
20
|
+
/** Moves page `from` so it becomes page `to` (1-based); annotations move with it. */
|
|
21
|
+
move(from: number, to: number): void;
|
|
22
|
+
/** Appends every page of another PDF. */
|
|
23
|
+
merge(file: ViewerOptions['document']): Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
export interface FormsApi {
|
|
26
|
+
/**
|
|
27
|
+
* Every field's value by fully qualified name: text → string, checkbox → boolean, radio group → the chosen
|
|
28
|
+
* button's export value ('' for none), dropdown → string, list box → string (string[] if multi-select).
|
|
29
|
+
* Empty until `documentLoaded`, and after flatten().
|
|
30
|
+
*/
|
|
31
|
+
getValues(): FormValues;
|
|
32
|
+
/** Validates every entry first (throws FormValueError, changing nothing), then applies them as one undo step. */
|
|
33
|
+
setValues(values: FormValues): void;
|
|
34
|
+
/** On save, draws every field into its page and removes the form. Undoable until saved. */
|
|
35
|
+
flatten(): void;
|
|
36
|
+
}
|
|
37
|
+
export interface SignaturesApi {
|
|
38
|
+
/**
|
|
39
|
+
* Places a signature image (data URL, image URL or Blob; PNG, JPEG, WebP, SVG…) in `rect` on `page`.
|
|
40
|
+
* Resolves once the image is read and converted. It's an annotation of type 'signature' until saved,
|
|
41
|
+
* when it's drawn into the page. Fires `signatureAdded` (and `annotationAdded`).
|
|
42
|
+
*/
|
|
43
|
+
add(signature: {
|
|
44
|
+
page: number;
|
|
45
|
+
rect: Rect;
|
|
46
|
+
image: string | Blob;
|
|
47
|
+
}): Promise<AnnotationJSON>;
|
|
48
|
+
}
|
|
49
|
+
export interface RedactionApi {
|
|
50
|
+
/** Marks an area for redaction: an editable, undoable annotation of type 'redaction' until applied. */
|
|
51
|
+
mark(region: {
|
|
52
|
+
page: number;
|
|
53
|
+
rect: Rect;
|
|
54
|
+
}): AnnotationJSON;
|
|
55
|
+
/**
|
|
56
|
+
* Applies every mark. This is final: the marks turn black, what's under them can no longer be selected,
|
|
57
|
+
* copied or found, annotations and form fields under them are deleted, and the undo history is cleared.
|
|
58
|
+
* Saving (save, download, print) removes the content itself from the file.
|
|
59
|
+
*/
|
|
60
|
+
apply(): Promise<void>;
|
|
61
|
+
}
|
|
62
|
+
export interface Viewer {
|
|
63
|
+
on<K extends keyof ViewerEvents>(event: K, handler: Handler<ViewerEvents[K]>): void;
|
|
64
|
+
off<K extends keyof ViewerEvents>(event: K, handler: Handler<ViewerEvents[K]>): void;
|
|
65
|
+
goToPage(page: number): void;
|
|
66
|
+
setZoom(zoom: number): void;
|
|
67
|
+
fit(mode: FitMode): void;
|
|
68
|
+
search(text: string): Promise<SearchResult[]>;
|
|
69
|
+
readonly annotations: AnnotationsApi;
|
|
70
|
+
undo(): void;
|
|
71
|
+
redo(): void;
|
|
72
|
+
readonly pages: PagesApi;
|
|
73
|
+
readonly forms: FormsApi;
|
|
74
|
+
readonly signatures: SignaturesApi;
|
|
75
|
+
readonly redaction: RedactionApi;
|
|
76
|
+
/** The PDF with all annotations written as standard PDF annotations. Fires `saved`. */
|
|
77
|
+
save(): Promise<Uint8Array>;
|
|
78
|
+
/** Saves and offers the file as a download; the name defaults to the original file's. Fires `saved`. */
|
|
79
|
+
download(fileName?: string): Promise<void>;
|
|
80
|
+
/** Prints the document with its annotations. Resolves when the print dialog closes. */
|
|
81
|
+
print(): Promise<void>;
|
|
82
|
+
destroy(): void;
|
|
83
|
+
}
|
|
84
|
+
/** A sensible download name from the original source: the File's name or the URL's last segment. */
|
|
85
|
+
export declare function defaultFileName(source: ViewerOptions['document']): string;
|
|
86
|
+
/**
|
|
87
|
+
* Mounts a viewer and resolves once the document has opened and its first pages are laid out,
|
|
88
|
+
* so navigation methods work right after `await`. Rejects (and unmounts) if the document can't be opened.
|
|
89
|
+
* `documentLoaded` fires later, once the file's own annotations have been loaded as editable annotations,
|
|
90
|
+
* so handlers attached right after `await` still receive it and see the complete annotation list.
|
|
91
|
+
*
|
|
92
|
+
* A container holds one viewer. Calling createViewer again on the same container destroys the previous
|
|
93
|
+
* viewer; if that one was still loading, its promise rejects with an `AbortError` DOMException. This makes
|
|
94
|
+
* framework remounts (React StrictMode, a changed file) safe without any bookkeeping in the app.
|
|
95
|
+
*/
|
|
96
|
+
export declare function createViewer(options: ViewerOptions): Promise<Viewer>;
|
package/dist/viewer.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type AnnotationInput, type AnnotationJSON, type AnnotationPatch, type ImportOptions, type ListFilter, type FitMode, type FormValues, type Handler, type Rect, type Rotation, type SearchResult, type ViewerEvents, type ViewerOptions } from './types/core/index.js';
|
|
2
|
-
export declare const VERSION = "0.1.
|
|
2
|
+
export declare const VERSION = "0.1.1-beta.0";
|
|
3
3
|
export interface AnnotationsApi {
|
|
4
4
|
/** Validates, fills defaults (id, author from `user`, timestamps, colors) and returns the stored annotation. */
|
|
5
5
|
add(annotation: AnnotationInput): AnnotationJSON;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pdfcedar",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1-beta.0",
|
|
4
4
|
"description": "Embeddable PDF viewer SDK for the web: view, annotate, edit pages and save PDFs in React, Vue, Angular or plain HTML",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"author": "Waseem Ahmad Dar",
|
|
@@ -11,12 +11,19 @@
|
|
|
11
11
|
"keywords": [
|
|
12
12
|
"pdf",
|
|
13
13
|
"pdf-viewer",
|
|
14
|
+
"pdf-editor",
|
|
15
|
+
"pdf-sdk",
|
|
14
16
|
"pdf-annotation",
|
|
17
|
+
"pdf-signature",
|
|
18
|
+
"e-signature",
|
|
19
|
+
"pdf-form",
|
|
20
|
+
"redaction",
|
|
15
21
|
"pdfjs",
|
|
16
22
|
"web-components",
|
|
17
23
|
"react",
|
|
18
24
|
"vue",
|
|
19
|
-
"angular"
|
|
25
|
+
"angular",
|
|
26
|
+
"typescript"
|
|
20
27
|
],
|
|
21
28
|
"type": "module",
|
|
22
29
|
"main": "./dist/index.umd.cjs",
|
|
@@ -24,12 +31,19 @@
|
|
|
24
31
|
"types": "./dist/index.d.ts",
|
|
25
32
|
"exports": {
|
|
26
33
|
".": {
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
34
|
+
"import": {
|
|
35
|
+
"types": "./dist/index.d.ts",
|
|
36
|
+
"default": "./dist/index.js"
|
|
37
|
+
},
|
|
38
|
+
"require": {
|
|
39
|
+
"types": "./dist/index.d.cts",
|
|
40
|
+
"default": "./dist/index.umd.cjs"
|
|
41
|
+
}
|
|
30
42
|
},
|
|
31
43
|
"./package.json": "./package.json"
|
|
32
44
|
},
|
|
45
|
+
"unpkg": "./dist/pdfcedar.umd.js",
|
|
46
|
+
"jsdelivr": "./dist/pdfcedar.umd.js",
|
|
33
47
|
"bin": {
|
|
34
48
|
"pdfcedar-assets": "./bin/pdfcedar-assets.mjs"
|
|
35
49
|
},
|
|
@@ -39,15 +53,5 @@
|
|
|
39
53
|
"bin",
|
|
40
54
|
"LICENSE",
|
|
41
55
|
"README.md"
|
|
42
|
-
]
|
|
43
|
-
|
|
44
|
-
"@pdfcedar/core": "0.0.0",
|
|
45
|
-
"@pdfcedar/writer": "0.0.0",
|
|
46
|
-
"@pdfcedar/renderer": "0.0.0",
|
|
47
|
-
"@pdfcedar/ui": "0.0.0",
|
|
48
|
-
"@pdfcedar/collab": "0.0.0"
|
|
49
|
-
},
|
|
50
|
-
"scripts": {
|
|
51
|
-
"build": "vite build && vite build --mode umd && node ../../scripts/build-types.mjs && node ../../scripts/third-party-notices.mjs"
|
|
52
|
-
}
|
|
53
|
-
}
|
|
56
|
+
]
|
|
57
|
+
}
|