Skip to content

Commit 562c15f

Browse files
update to Document-Viewer-Javascript 1.1
1 parent e043b0e commit 562c15f

File tree

11 files changed

+120
-88
lines changed

11 files changed

+120
-88
lines changed

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright © 2003–2023 Dynamsoft. All Rights Reserved.
1+
Copyright © 2003–2024 Dynamsoft. All Rights Reserved.
22

33
The use of this software is governed by the Dynamsoft Terms and Conditions.
44
https://www.dynamsoft.com/company/license-agreement/

README.md

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,19 @@ The SDK requires the following features to work:
3535

3636
- `WebAssembly`, `Blob`, `URL`/`createObjectURL`, `Web Workers`
3737

38+
## Supported Browsers
39+
40+
The following table is a list of supported browsers based on the above requirements:
41+
42+
| Browser Name | PC | Mobile |
43+
| :----------: | :------------------------------: | :---------: |
44+
| Chrome | v75+ | v75+ |
45+
| Firefox | v69+ | v79+ |
46+
| Safari | v14+ | v15+ |
47+
| Edge | v79+ | v92+ |
48+
49+
Apart from the browsers, the operating systems may impose some limitations of their own that could restrict the use of the SDKs.
50+
3851
## License Key
3952

4053
[![](https://img.shields.io/badge/Get-30--day%20FREE%20Trial%20License-blue)](https://www.dynamsoft.com/customer/license/trialLicense/?product=ddv&utm_source=npm)
@@ -57,8 +70,8 @@ Review the complete code:
5770
<meta http-equiv="X-UA-Compatible" content="IE=edge">
5871
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
5972
<title>DDV - HelloWorld</title>
60-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/dynamsoft-document-viewer@latest/dist/ddv.css">
61-
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-document-viewer@latest/dist/ddv.js"></script>
73+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/dynamsoft-document-viewer@1.1.0/dist/ddv.css">
74+
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-document-viewer@1.1.0/dist/ddv.js"></script>
6275
</head>
6376
<style>
6477
html,body {
@@ -80,13 +93,11 @@ Review the complete code:
8093
</body>
8194
<script type="module">
8295
(async () => {
83-
await Dynamsoft.DDV.setConfig({
84-
// Public trial license which is valid for 24 hours
85-
//You can request a 30-day trial key from
86-
//https://www.dynamsoft.com/customer/license/trialLicense/?product=ddv
87-
license: "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9",
88-
engineResourcePath: "https://cdn.jsdelivr.net/npm/dynamsoft-document-viewer@latest/dist/engine",
89-
});
96+
// Public trial license which is valid for 24 hours
97+
// You can request a 30-day trial key from https://www.dynamsoft.com/customer/license/trialLicense/?product=ddv
98+
Dynamsoft.DDV.Core.license = "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9";
99+
Dynamsoft.DDV.Core.engineResourcePath = "https://cdn.jsdelivr.net/npm/dynamsoft-document-viewer@1.1.0/dist/engine";
100+
await Dynamsoft.DDV.Core.init();
90101
Dynamsoft.DDV.setProcessingHandler("imageFilter", new Dynamsoft.DDV.ImageFilter());
91102
const editViewer = new Dynamsoft.DDV.EditViewer({
92103
container: "container",

dist/ddv.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/ddv.es.js

Lines changed: 7 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/ddv.js

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/engine/ddv-imageio.worker.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
-3.08 KB
Binary file not shown.

dist/engine/ddv-imageproc.wasm

-2.72 KB
Binary file not shown.

dist/engine/ddv-pdfreader.wasm

109 Bytes
Binary file not shown.

dist/index.d.ts

Lines changed: 70 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,25 @@ declare class BaseBrowseViewer implements IBrowseViewer {
3030
show(): void;
3131
hide(): void;
3232
getSelectedPageIndices(): number[];
33-
/**
34-
* Select all pages of the activated document.
35-
* @returns A boolean value represent whether the operation is successful.
36-
*/
3733
selectAllPages(): string[];
38-
/**
39-
* Select the pages according the index of pages in the activated document.
40-
* @param indices - The index of pages to be selected.
41-
* @returns A boolean value represent whether the operation is successful.
42-
*/
4334
selectPages(indices: number[]): string[];
4435
setRowAndColumn(row: number, column: number): boolean;
4536
on<K extends keyof BrowseViewerEventMap>(eventName: K, listener: (event: BrowseViewerEventMap[K]) => any): void;
4637
off<K extends keyof BrowseViewerEventMap>(eventName: K, listener?: (event: BrowseViewerEventMap[K]) => any): void;
4738
destroy(): void;
4839
}
40+
declare class Core {
41+
#private;
42+
get versionInfo(): DDVVersionInfo;
43+
set engineResourcePath(path: string);
44+
get engineResourcePath(): string;
45+
set license(license: string);
46+
get license(): string;
47+
set deviceFriendlyName(name: string);
48+
get deviceFriendlyName(): string;
49+
loadWasm(): Promise<void>;
50+
init(): Promise<ConfigResult>;
51+
}
4952
declare class DocumentDetect implements IDocumentDetect {
5053
#private;
5154
constructor();
@@ -66,7 +69,7 @@ declare class DocumentManager {
6669
* @param options - The configuration used to create a document.
6770
* @returns An empty document object.
6871
*/
69-
createDocument(options?: CreateDocumentOptions): IDocument | null;
72+
createDocument(options?: CreateDocumentOptions): IDocument;
7073
/**
7174
* Get the document with the document uid.
7275
* @param docUid - The uid of the target document.
@@ -83,7 +86,7 @@ declare class DocumentManager {
8386
deleteAllDocuments(): boolean;
8487
copyPagesToDocument(sourceDocUid: string, targetDocUid: string, transferOptions?: TransferOptions): boolean;
8588
movePagesToDocument(sourceDocUid: string, targetDocUid: string, transferOptions?: TransferOptions): boolean;
86-
mergeDocuments(docUids: string[], options?: MergeDocumentsOptions): IDocument | null;
89+
mergeDocuments(docUids: string[], options?: MergeDocumentsOptions): IDocument;
8790
on<K extends keyof DocumentManagerEventMap>(eventName: K, listener: (event: DocumentManagerEventMap[K]) => any): void;
8891
off<K extends keyof DocumentManagerEventMap>(eventName: K, listener?: (event: DocumentManagerEventMap[K]) => any): void;
8992
}
@@ -149,7 +152,7 @@ declare class ImageFilterHandler implements IImageFilter {
149152
applyFilter(type: string): Promise<ArrayBuffer>;
150153
queryParams(type: string): any;
151154
get defaultFilterType(): string;
152-
querySupported(): ImageFilterMethod[];
155+
querySupported(): ImageFilterItem[];
153156
destroy(): void;
154157
}
155158
declare class ImageIOWasmEnv {
@@ -166,10 +169,10 @@ declare class ImageIOWasmEnv {
166169
static getLicenseInfo(license: any, isLts: boolean, uuid: string): Promise<any>;
167170
private static Init;
168171
static isResourceDirValid(): Promise<boolean>;
169-
static loadPdfReader(license: any, isLts: boolean, uuid: string): Promise<boolean>;
170-
static loadMain(license: any, isLts: boolean, uuid: string): Promise<boolean>;
172+
static loadPdfReader(license: any, isLts: boolean, uuid: string): Promise<any>;
173+
static loadMain(license: any, isLts: boolean, uuid: string): Promise<any>;
171174
static load(license: any, isLts: boolean, uuid: string): Promise<void>;
172-
static preloadModule(name: WasmModuleName): Promise<void>;
175+
static preloadModule(name: WasmModuleName): Promise<any>;
173176
static unloadMainWorker(): void;
174177
static unloadPdfReaderWorker(): void;
175178
static unloadDocumentDetectorWorker(): void;
@@ -182,7 +185,8 @@ declare const Version: string;
182185
declare enum WorkerName {
183186
core = "ddv-core",
184187
reader = "ddv-reader",
185-
detector = "ddv-detector"
188+
detector = "ddv-detector",
189+
loader = "ddv-loader"
186190
}
187191
export declare class BrowseViewer extends BaseBrowseViewer {
188192
constructor(options: BrowseViewerConstructorOptions);
@@ -455,6 +459,8 @@ export declare class PerspectiveViewer {
455459
export declare const DDV: {
456460
/** The document manager object */
457461
documentManager: DocumentManager;
462+
/** The configuration object */
463+
Core: Core;
458464
Elements: typeof Elements;
459465
DocumentDetect: typeof DocumentDetect;
460466
ImageFilter: typeof ImageFilterHandler;
@@ -463,15 +469,19 @@ export declare const DDV: {
463469
CustomViewer: typeof CustomViewer;
464470
EditViewer: typeof EditViewer;
465471
PerspectiveViewer: typeof PerspectiveViewer;
466-
readonly versionInfo: DDVVersionInfo;
467472
readonly lastError: DDVError;
468473
Experiments: {
469474
get(name: string, params?: any): any;
470475
set(name: string, value: any): any;
471476
};
472-
setConfig(config: Configuration): Promise<ConfigResult>;
473477
getDefaultUiConfig(viewerType: ViewerType): UiConfig | null;
474478
setProcessingHandler<K extends keyof ProcessingHandlerMap>(type: K, handler: ProcessingHandlerMap[K]): void;
479+
/**
480+
* Set a filter parser to the DDV system.
481+
* @param mine - The MIME type of file.
482+
* @param parserClass - The constructor of the file parser.
483+
*/
484+
setFileParser(mine: string, parserClass: FileParserConstructor): void;
475485
unload(): void;
476486
clearLastError(): void;
477487
on<K_1 extends keyof DDVEventMap>(eventName: K_1, listener: (event: DDVEventMap[K_1]) => any): void;
@@ -600,29 +610,6 @@ export interface BrowseViewerConfig {
600610
scrollToLatest?: boolean;
601611
enableDragPage?: boolean;
602612
}
603-
export interface BrowseViewerConfig {
604-
canvasStyle?: CanvasStyle;
605-
currentPageStyle?: BaseStyle;
606-
pageStyle?: BaseStyle;
607-
selectedPageStyle?: BaseStyle;
608-
hoveredPageStyle?: BaseStyle;
609-
placeholderStyle?: BaseStyle;
610-
pageNumberStyle?: PageNumberStyle;
611-
checkboxStyle?: CheckboxStyle;
612-
rows?: number;
613-
columns?: number;
614-
scrollDirection?: "horizontal" | "vertical";
615-
multiselectMode?: boolean;
616-
scrollToLatest?: boolean;
617-
enableDragPage?: boolean;
618-
}
619-
export interface BrowseViewerConstructorOptions {
620-
container?: string | HTMLElement;
621-
viewerConfig?: BrowseViewerConfig;
622-
uiConfig?: UiConfig;
623-
/** The uid of the controller/viewer to be synced */
624-
groupUid?: string;
625-
}
626613
export interface BrowseViewerConstructorOptions {
627614
container?: string | HTMLElement;
628615
viewerConfig?: BrowseViewerConfig;
@@ -700,12 +687,7 @@ export interface CheckboxStyle {
700687
}
701688
export interface ConfigResult {
702689
licenseInfo: string;
703-
deviceId?: string;
704-
}
705-
export interface Configuration {
706-
license: string;
707-
deviceFriendlyName?: string;
708-
engineResourcePath: string;
690+
deviceUuid?: string;
709691
}
710692
export interface CreateDocumentOptions {
711693
name?: string;
@@ -854,6 +836,9 @@ export interface ExtraPageData {
854836
filter?: string;
855837
perspectiveQuad?: Quad;
856838
}
839+
export interface FileParserConstructor {
840+
new (): IFileParser;
841+
}
857842
export interface FitModeChangedEvent {
858843
readonly oldFitMode: FitModeEnum;
859844
readonly newFitMode: FitModeEnum;
@@ -888,7 +873,8 @@ export interface IDocument {
888873
loadSource(fileData: Blob | Blob[], index?: number): Promise<string[]>;
889874
loadSource(sources: Source | Source[], index?: number): Promise<string[]>;
890875
getPageData(pageUid: string): Promise<PageData>;
891-
updatePage(pageUid: string, data: Blob): Promise<boolean>;
876+
insertBlankPage(pageWidth: number, pageHeight: number, insertBeforeIndex?: number): string;
877+
updatePage(pageUid: string, data: Blob, options?: UpdatePageOptions): Promise<boolean>;
892878
setPageCustomData(pageUid: string, data: any): Promise<boolean>;
893879
getPageCustomData(pageUid: string): Promise<any>;
894880
deletePages(indices: number[]): boolean;
@@ -908,8 +894,17 @@ export interface IDocumentDetect {
908894
detect(image: VImageData, config?: DocumentDetectConfig): Promise<DocumentDetectResult>;
909895
destroy(): void;
910896
}
897+
export interface IFileParser {
898+
once: boolean;
899+
getPageCount(file: Blob, options?: any): Promise<number>;
900+
parse(file: Blob, options?: any): Promise<ParsedPage[]>;
901+
parse(file: Blob, indices: number[], options?: any): Promise<ParsedPage[]>;
902+
getPage(index: number, options?: any): Promise<ParsedPage>;
903+
cancelGetPage(index: number): void;
904+
destroy(): void;
905+
}
911906
export interface IImageFilter {
912-
querySupported(): ImageFilterMethod[];
907+
querySupported(): ImageFilterItem[];
913908
get defaultFilterType(): string;
914909
applyFilter(image: VImageData, type: string): Promise<Blob>;
915910
destroy(): void;
@@ -964,7 +959,7 @@ export interface IconComponent {
964959
PrevPage?: string;
965960
ImagePreview?: string;
966961
}
967-
export interface ImageFilterMethod {
962+
export interface ImageFilterItem {
968963
type: string;
969964
label: string;
970965
}
@@ -1039,6 +1034,23 @@ export interface PagesDeletedEvent {
10391034
readonly pageUids: string[];
10401035
readonly indices: number[];
10411036
}
1037+
export interface ParsedAnnotation {
1038+
type: string;
1039+
style: any;
1040+
}
1041+
export interface ParsedPage {
1042+
fileIndex: number;
1043+
data?: Blob;
1044+
width?: number;
1045+
height?: number;
1046+
annotations?: ParsedAnnotation[];
1047+
bitDepth?: number;
1048+
resolutionX?: number;
1049+
resolutionY?: number;
1050+
rotation?: number;
1051+
pageWidth?: number;
1052+
pageHeight?: number;
1053+
}
10421054
export interface PerspectiveViewerConfig {
10431055
canvasStyle?: CanvasStyle;
10441056
pageStyle?: BaseStyle;
@@ -1219,9 +1231,15 @@ export interface UiConfig {
12191231
style?: Partial<CSSStyleDeclaration>;
12201232
className?: string;
12211233
label?: string;
1222-
events?: Record<string, string>;
1234+
events?: Partial<Record<keyof GlobalEventHandlersEventMap, any>>;
12231235
children?: (UiConfig | string)[];
12241236
}
1237+
export interface UpdatePageOptions {
1238+
fileIndex?: number;
1239+
filter?: string;
1240+
rotation?: number;
1241+
perspectiveQuad?: Quad;
1242+
}
12251243
export interface VError {
12261244
code: number;
12271245
message: string;
@@ -1293,6 +1311,6 @@ export type Quad = [
12931311
];
12941312
export type ToolMode = "pan" | "crop";
12951313
export type ViewerType = "editViewer" | "perspectiveViewer" | "captureViewer" | "browseViewer";
1296-
export type WasmModuleName = "core" | "pdf";
1314+
export type WasmModuleName = "core" | "pdf" | "proc";
12971315

12981316
export {};

0 commit comments

Comments
 (0)