Skip to content
This repository was archived by the owner on Feb 19, 2025. It is now read-only.

Commit 6c2de97

Browse files
authored
Merge pull request #6 from PDFTron/2.0.0
2.0.0
2 parents d390a46 + 3050a8e commit 6c2de97

File tree

8 files changed

+243
-162
lines changed

8 files changed

+243
-162
lines changed

package-lock.json

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

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "webviewer",
33
"widgetName": "WebViewer",
4-
"version": "1.5.1",
4+
"version": "2.0.0",
55
"description": "My widget description",
66
"copyright": "2023 Apryse",
77
"author": "Andrey Safonov",
@@ -22,15 +22,15 @@
2222
},
2323
"license": "",
2424
"devDependencies": {
25-
"@mendix/pluggable-widgets-tools": "^9.13.2",
25+
"@mendix/pluggable-widgets-tools": "^9.20.0",
2626
"@types/big.js": "^6.1.4",
2727
"@types/classnames": "^2.2.4",
2828
"@types/lodash": "^4.14.191",
2929
"@types/react": "~18.0.14",
3030
"@types/react-dom": "~18.0.5"
3131
},
3232
"dependencies": {
33-
"@pdftron/webviewer": "^8.12.0-20230302",
33+
"@pdftron/webviewer": "^10.0.0-20230412",
3434
"classnames": "^2.2.6",
3535
"lodash": "^4.17.21"
3636
}

src/WebViewer.xml

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,6 @@
1717
<caption>File</caption>
1818
<description>A FileDocument type of entity.</description>
1919
</property>
20-
<property key="fileUrlAttribute" type="attribute" required="false">
21-
<caption>Attribute (URL)</caption>
22-
<description>Load a file from an entity attribute. WILL BE DEPRECATED IN 2.0. Please use the file parameter.</description>
23-
<attributeTypes>
24-
<attributeType name="String"/>
25-
</attributeTypes>
26-
</property>
27-
<property key="fileIdAttribute" type="attribute" required="false">
28-
<caption>File ID</caption>
29-
<description>The Mendix file identifier. Used with WebViewer module for saving. WILL BE DEPRECATED IN 2.0. Please use the file parameter.</description>
30-
<attributeTypes>
31-
<attributeType name="String"/>
32-
</attributeTypes>
33-
</property>
3420
<property key="enableFilePicker" type="boolean" defaultValue="false">
3521
<caption>Show file picker</caption>
3622
<description>Allow users to load their own local files.</description>
@@ -40,6 +26,16 @@
4026
<description>Converts the loaded document to PDF after loading.</description>
4127
</property>
4228
</propertyGroup>
29+
<propertyGroup caption="Editing">
30+
<property key="enablePdfEditing" type="boolean" defaultValue="false">
31+
<caption>Enable PDF editing</caption>
32+
<description>Enable editing of PDFs in WebViewer.</description>
33+
</property>
34+
<property key="enableOfficeEditing" type="boolean" defaultValue="false">
35+
<caption>Enable Office editing</caption>
36+
<description>Switches WebViewer to Office editing.</description>
37+
</property>
38+
</propertyGroup>
4339
<propertyGroup caption="Other">
4440
<property key="enableFullAPI" type="boolean" defaultValue="false">
4541
<caption>Enable full API</caption>
@@ -97,7 +93,7 @@
9793
</property>
9894
<property key="enableAutoXfdfImport" type="boolean" defaultValue="false">
9995
<caption>Enable Auto XFDF Import</caption>
100-
<description>Enable automatic importing of the annotation XFDF when the document loads.</description>
96+
<description>Enable automatic importing of the annotation XFDF when the document loads. Occurs only once on document load.</description>
10197
</property>
10298
</propertyGroup>
10399
</propertyGroup>
@@ -171,22 +167,30 @@
171167
</property>
172168
</propertyGroup>
173169
<propertyGroup caption="Module">
174-
<property key="enableDocumentUpdates" type="boolean" defaultValue="true">
175-
<caption>Enable document updates</caption>
176-
<description>Adds a button to the header to allow updating the document on the server (annotations, links, widgets). Requires WebViewer module.</description>
177-
</property>
178-
<property key="enableSaveAsButton" type="boolean" defaultValue="true">
179-
<caption>Enable save as</caption>
180-
<description>Adds a button to the header to allow saving a document to the server as a new file. Requires WebViewer module.</description>
181-
</property>
182-
<property key="continueAutoXfdfImport" type="boolean" defaultValue="false">
183-
<caption>Continue Auto XFDF Import</caption>
184-
<description>Continue to import XFDF from the server. This achieves real-time updates at specific intervals. Requires WebViewer module.</description>
185-
</property>
186-
<property key="autoXfdfImportInterval" type="integer" defaultValue="1000">
187-
<caption>Auto Import Interval</caption>
188-
<description>The interval in milliseconds to get XFDF updates from the server for the current file.</description>
189-
</property>
170+
<propertyGroup caption="Document Updates">
171+
<property key="enableDocumentUpdates" type="boolean" defaultValue="true">
172+
<caption>Enable document updates</caption>
173+
<description>Adds a button to the header to allow updating the document on the server (annotations, links, widgets). Requires WebViewer module.</description>
174+
</property>
175+
<property key="enableSaveAsButton" type="boolean" defaultValue="true">
176+
<caption>Enable save as</caption>
177+
<description>Adds a button to the header to allow saving a document to the server as a new file. Requires WebViewer module.</description>
178+
</property>
179+
</propertyGroup>
180+
<propertyGroup caption="Real-Time Annotating">
181+
<property key="enableRealTimeAnnotating" type="boolean" defaultValue="false">
182+
<caption>Enable Real-time Annotating</caption>
183+
<description>Annotate in real-time with other users without an additional server. This will make polling requests.</description>
184+
</property>
185+
<property key="onExportXfdfCommand" type="action" required="false">
186+
<caption>On export XFDF command</caption>
187+
<description>Trigger an action when exporting annotations to XFDF commands. This can occur multiple files.</description>
188+
</property>
189+
<property key="autoXfdfCommandImportInterval" type="integer" defaultValue="1000">
190+
<caption>Auto Import Interval</caption>
191+
<description>The interval in milliseconds to get XFDF updates from the server for the current file.</description>
192+
</property>
193+
</propertyGroup>
190194
</propertyGroup>
191195
<propertyGroup caption="License">
192196
<property key="l" type="string" required="false">

src/clients/WebViewerModuleClient.tsx

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ class WebViewerModuleClient {
33
constructor(mx: any) {
44
this._mx = mx;
55
}
6-
getHeaders(): any {
6+
getHeaders(additionalHeaders: any = {}): any {
77
return {
8-
"X-Csrf-Token": this._mx.session.getConfig("csrftoken")
8+
"X-Csrf-Token": this._mx.session.getConfig("csrftoken"),
9+
...additionalHeaders
910
};
1011
}
1112
async checkForModule(): Promise<boolean> {
@@ -64,6 +65,59 @@ class WebViewerModuleClient {
6465
throw e;
6566
}
6667
}
68+
async getAllXfdfCommands(fileId: string): Promise<any[]> {
69+
if (!fileId) {
70+
console.warn("Empty file ID was provided.");
71+
return [];
72+
}
73+
try {
74+
const res = await fetch(`/rest/documentstore/v1/documents/${fileId}/commands`, {
75+
method: "GET",
76+
headers: this.getHeaders()
77+
});
78+
return await res.json();
79+
} catch (e) {
80+
console.info("[Module] Failed to fetch XFDF commands.", e);
81+
throw e;
82+
}
83+
}
84+
async getLatestXfdfCommands(fileId: string, lastQueryDate: string): Promise<any[]> {
85+
if (!fileId) {
86+
console.warn("Empty file ID was provided.");
87+
return [];
88+
}
89+
try {
90+
const res = await fetch(
91+
`/rest/documentstore/v1/documents/${fileId}/commands?lastQueryDate=${lastQueryDate}`,
92+
{
93+
method: "GET",
94+
headers: this.getHeaders()
95+
}
96+
);
97+
return await res.json();
98+
} catch (e) {
99+
console.info("[Module] Failed to fetch latest XFDF commands.", e);
100+
throw e;
101+
}
102+
}
103+
async createXfdfCommand(fileId: string, command: string): Promise<void> {
104+
if (!fileId) {
105+
console.warn("Empty file ID was provided.");
106+
return;
107+
}
108+
try {
109+
await fetch(`/rest/documentstore/v1/documents/${fileId}/commands`, {
110+
method: "POST",
111+
headers: this.getHeaders({
112+
"Content-Type": "application/json"
113+
}),
114+
body: JSON.stringify({ XFDF: command })
115+
});
116+
} catch (e) {
117+
console.info(`[Module] Failed to add XFDF command. ${command}`, e);
118+
throw e;
119+
}
120+
}
67121
}
68122

69123
export default WebViewerModuleClient;

0 commit comments

Comments
 (0)