ngx-extended-pdf-viewer
Version:
Embedding PDF files in your Angular application. Highly configurable viewer including the toolbar, sidebar, and all the features you're used to.
146 lines (145 loc) • 4.78 kB
TypeScript
export declare enum AnnotationMode {
DISABLE = 0,
ENABLE = 1,
ENABLE_FORMS = 2,
ENABLE_STORAGE = 3
}
export declare enum AnnotationEditorType {
DISABLE = -1,
NONE = 0,
FREETEXT = 3,
HIGHLIGHT = 9,
STAMP = 13,
INK = 15,
POPUP = 16,
SIGNATURE = 101,
COMMENT = 102
}
export declare const AnnotationEditorParamsType: {
RESIZE: number;
CREATE: number;
FREETEXT_SIZE: number;
FREETEXT_COLOR: number;
FREETEXT_OPACITY: number;
INK_COLOR: number;
INK_THICKNESS: number;
INK_OPACITY: number;
HIGHLIGHT_COLOR: number;
HIGHLIGHT_THICKNESS: number;
HIGHLIGHT_FREE: number;
HIGHLIGHT_SHOW_ALL: number;
HIGHLIGHT_DEFAULT_COLOR: number;
DRAW_STEP: number;
};
export type AnnotationEditorTypeValue = -1 | 0 | 3 | 9 | 13 | 15 | 16;
/**
* #3237 The comment (a.k.a. popup) attached to an annotation. Every editor type can carry one:
* `getSerializedAnnotations()` returns it, and `addEditorAnnotation()` restores it.
*/
export type AnnotationPopup = {
/** the text of the comment */
contents: string;
/** `true` if the user deleted the comment of an annotation that already was in the PDF file */
deleted?: boolean;
/** the position of the popup, in PDF user space: [left, bottom, right, top] */
rect?: Array<number>;
/** the time the comment was written, as an ISO string; restored unchanged, so a round-trip keeps the original timestamp */
date?: string;
};
/**
* #3236 Where an annotation ends up: `rect` and `rotation`.
*
* `rect` is the box the annotation occupies, `[left, bottom, right, top]`, measured from the
* bottom left corner of the page. Drawings are the exception - a drawing sits where its points
* are, so its `rect` is ignored (which is why an empty one seems to work until you add an
* annotation of any other type).
*
* **`rotation` does not turn the annotation by N degrees.** It says which way up the page was when
* you measured the coordinates you are passing in - counting both the rotation stored in the
* document and the rotation the user applied with the rotate buttons. Pass the wrong value and the
* annotation lands in the wrong *place*, often off the page, rather than tilted.
*
* You don't have to think about any of this to save your users' annotations and load them back:
* `getSerializedAnnotations()` and `addEditorAnnotation()` agree with each other, rotated pages
* included. It matters when you calculate annotations yourself, and `rotation: 0` covers you as
* long as your pages are upright and nobody rotates them.
*
* Scanned documents are where it bites, because many are stored sideways and turned upright by the
* file itself - so the page you see is not the page your coordinates are measured on. If one
* misbehaves, draw an annotation on it by hand, export it, and match what you see there.
*/
export type InkPaths = {
lines: Array<Array<number>>;
points: Array<Array<number>>;
};
export type InkEditorAnnotation = {
annotationType: 15;
color: Array<number>;
thickness: number;
opacity: number;
paths: InkPaths;
pageIndex: number;
rect: Array<number>;
rotation: 0 | 90 | 180 | 270;
isCopy?: boolean;
id?: string;
customId?: string;
popup?: AnnotationPopup;
};
export type FreeTextEditorAnnotation = {
annotationType: 3;
color: Array<number>;
fontSize: number;
value: string;
pageIndex: number;
rect: Array<number>;
rotation: 0 | 90 | 180 | 270;
isCopy?: boolean;
id?: string;
customId?: string;
popup?: AnnotationPopup;
};
export type StampEditorAnnotation = {
annotationType: 13;
pageIndex: number;
bitmapUrl: string | Blob;
rect: Array<number>;
rotation: 0 | 90 | 180 | 270;
isCopy?: boolean;
id?: string;
customId?: string;
popup?: AnnotationPopup;
};
export type HighlightEditorAnnotation = {
annotationType: 9;
color: Array<number>;
opacity: number;
thickness: number;
boxes?: Array<{
x: number;
y: number;
width: number;
height: number;
}>;
quadPoints?: any;
outlines?: Array<Array<number>>;
pageIndex: number;
rect: Array<number>;
rotation: 0 | 90 | 180 | 270;
isCopy?: boolean;
id?: string;
customId?: string;
popup?: AnnotationPopup;
};
export type PopupEditorAnnotation = {
annotationType: 16;
content: string;
pageIndex: number;
rect: Array<number>;
rotation: 0 | 90 | 180 | 270;
isCopy?: boolean;
id?: string;
customId?: string;
popup?: AnnotationPopup;
};
export type EditorAnnotation = InkEditorAnnotation | FreeTextEditorAnnotation | StampEditorAnnotation | HighlightEditorAnnotation | PopupEditorAnnotation;