Skip to content

Commit 8fb6a9e

Browse files
Aspose.PDF for JavaScript via C++ 23.11
1 parent 95eb98d commit 8fb6a9e

File tree

8 files changed

+145
-44
lines changed

8 files changed

+145
-44
lines changed

AsposePDFforJS.js

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

AsposePDFforJS.wasm.zip

-1.43 MB
Binary file not shown.

example.html

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,9 @@ <h2>Aspose.PDF for JavaScript via C++</h2>
240240

241241
var onloadAsposePDFforJS = function () {
242242
var Module_onRuntimeInitialized = Module['onRuntimeInitialized'];
243-
Module['onRuntimeInitialized'] = function() {
243+
Module['onRuntimeInitialized'] = async function() {
244244
console.log('AsposePDFforJS has loaded');
245-
Module_onRuntimeInitialized();
245+
await Module_onRuntimeInitialized();
246246
//Key PKCS7 for test, converted to Base64, with "Pa$$w0rd2023" password
247247
const test_pfx = "data:application/octet-stream;base64,MIIEcQIBAzCCBDcGCSqGSIb3DQEHAaCCBCgEggQkMIIEIDCCAj8GCSqGSIb3DQEHBqCCAjAwggIsAgEAMIICJQYJKoZIhvcNAQcBMBwGCiqGSIb3DQEMAQYwDgQI4tjRHb+OMLsCAggAgIIB+OAPdXDmh+6qTyjHkumo2euCw4EvRZ8qSha/AAWYespZs8mA9dInLWM33HeDqktHEcZoPf/CCWqQopRA6RPFAYIn9ioR8s3Phd3LmoMPb52SKJMvWjRGRppLyo4gCNZfv37duV8+mKTSyDW1wrtHsZnvLlUHmy8+OcG8zsAAX6YwHTMkafllpRKkB0kmO1boSvHEp5IPsU8u50VpF21OXYNV7D5c4W2O1GrV0a5HD6OyObHJjj+ufPF7nh+qEuPN/b8hm14y+sZPoVSRvwtH+O8VVDxnJWX+y+jGhChLxiYUYRnhBMW6X+cZW9bcpXZIkFdQdPWA1/opOdTguHlXQF1R+JNnUUOtopwX103undyPGl5JGXvLrr6iH2aO1GY1p2Asd1exaQdfwFQ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251251
AsposePdfPrepareBase64(sign_png,"sign.png");
252252
//Get info about Product
253253
const json = AsposePdfAbout();
254-
if (json.errorCode == 0) document.getElementById('output').textContent = json.producer;
254+
if (json.errorCode == 0) document.getElementById('output').textContent = "Product : " + json.product
255+
+ "\nFamily : " + json.family
256+
+ "\nVersion : " + json.version
257+
+ "\nRelease date : " + json.releasedate
258+
+ "\nProducer : " + json.producer
259+
+ "\nIs licensed : " + json.islicensed;
255260
else document.getElementById('output').textContent = json.errorText;
256261
}
257262
}
@@ -424,13 +429,28 @@ <h2>Aspose.PDF for JavaScript via C++</h2>
424429
const file_reader = new FileReader();
425430
file_reader.onload = (event) => {
426431
const json = AsposePdfGetInfo(event.target.result, e.target.files[0].name);
427-
if (json.errorCode == 0) document.getElementById('output').textContent = "Title: " + json.title + "\nCreator: " + json.creator + "\nAuthor: " + json.author
428-
+ "\nSubject: " + json.subject + "\nKeywords: " + json.keywords
429-
+ "\nCreation Date: " + json.creation + "\nModify Date: " + json.mod
430-
+ "\nPDF format: " + json.format + "\nPDF version: " + json.version
431-
+ "\nPDF is PDF/A: " + json.ispdfa + "\nPDF is PDF/UA: " + json.ispdfua
432-
+ "\nPDF permission: " + json.permission + "\nPDF page size: " + json.size
433-
+ "\nPage count: " + json.pagecount;
432+
if (json.errorCode == 0) document.getElementById('output').textContent = "Title : " + json.title
433+
+ "\nCreator : " + json.creator
434+
+ "\nAuthor : " + json.author
435+
+ "\nSubject : " + json.subject
436+
+ "\nKeywords : " + json.keywords
437+
+ "\nCreation Date : " + json.creation
438+
+ "\nModify Date : " + json.mod
439+
+ "\nPDF format : " + json.format
440+
+ "\nPDF version : " + json.version
441+
+ "\nPDF is PDF/A : " + json.ispdfa
442+
+ "\nPDF is PDF/UA : " + json.ispdfua
443+
+ "\nPDF is linearized : " + json.islinearized
444+
+ "\nPDF is encrypted : " + json.isencrypted
445+
+ "\nPDF permission : " + json.permission
446+
+ "\nPDF page size : " + json.size
447+
+ "\nPage count : " + json.pagecount
448+
+ "\nAnnotation count : " + json.annotationcount
449+
+ "\nBookmark count : " + json.bookmarkcount
450+
+ "\nAttachment count : " + json.attachmentcount
451+
+ "\nMetadata count : " + json.metadatacount
452+
+ "\nJavaScript count : " + json.javascriptcount
453+
+ "\nImage count : " + json.imagecount;
434454
else document.getElementById('output').textContent = json.errorText;
435455
}
436456
file_reader.readAsArrayBuffer(e.target.files[0]);

example_worker.html

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,18 @@
114114
const operation = evt.data.operation;
115115
const params = evt.data.params;
116116
if (json.errorCode == 0) {
117-
document.getElementById('output').textContent = "completed!";
117+
if (operation !== 'AsposePdfPrepare') document.getElementById('output').textContent = "completed!";
118118
document.getElementById('fileDownload').innerHTML = "";
119119
// peculiar properties
120120
switch (operation) {
121121
case 'AsposePdfAbout':
122122
document.getElementById('AsposeTitle').innerHTML = json.producer;
123+
document.getElementById('output').textContent = "Product : " + json.product
124+
+ "\nFamily : " + json.family
125+
+ "\nVersion : " + json.version
126+
+ "\nRelease date : " + json.releasedate
127+
+ "\nProducer : " + json.producer
128+
+ "\nIs licensed : " + json.islicensed;
123129
break;
124130
case 'AsposePdfPrepare':
125131
// if 'optdata' is Array
@@ -145,13 +151,28 @@
145151
document.getElementById('output').textContent = listFonts;
146152
break;
147153
case 'AsposePdfGetInfo':
148-
document.getElementById('output').textContent = "Title: " + json.title + "\nCreator: " + json.creator + "\nAuthor: " + json.author
149-
+ "\nSubject: " + json.subject + "\nKeywords: " + json.keywords
150-
+ "\nCreation Date: " + json.creation + "\nModify Date: " + json.mod
151-
+ "\nPDF format: " + json.format + "\nPDF version: " + json.version
152-
+ "\nPDF is PDF/A: " + json.ispdfa + "\nPDF is PDF/UA: " + json.ispdfua
153-
+ "\nPDF permission: " + json.permission + "\nPDF page size: " + json.size
154-
+ "\nPage count: " + json.pagecount;
154+
document.getElementById('output').textContent = "Title : " + json.title
155+
+ "\nCreator : " + json.creator
156+
+ "\nAuthor : " + json.author
157+
+ "\nSubject : " + json.subject
158+
+ "\nKeywords : " + json.keywords
159+
+ "\nCreation Date : " + json.creation
160+
+ "\nModify Date : " + json.mod
161+
+ "\nPDF format : " + json.format
162+
+ "\nPDF version : " + json.version
163+
+ "\nPDF is PDF/A : " + json.ispdfa
164+
+ "\nPDF is PDF/UA : " + json.ispdfua
165+
+ "\nPDF is linearized : " + json.islinearized
166+
+ "\nPDF is encrypted : " + json.isencrypted
167+
+ "\nPDF permission : " + json.permission
168+
+ "\nPDF page size : " + json.size
169+
+ "\nPage count : " + json.pagecount
170+
+ "\nAnnotation count : " + json.annotationcount
171+
+ "\nBookmark count : " + json.bookmarkcount
172+
+ "\nAttachment count : " + json.attachmentcount
173+
+ "\nMetadata count : " + json.metadatacount
174+
+ "\nJavaScript count : " + json.javascriptcount
175+
+ "\nImage count : " + json.imagecount;
155176
break;
156177
case 'AsposePdfPagesToJpg':
157178
document.getElementById('output').textContent = "Files(pages) count: " + json.filesCount.toString();

snippets/AsposePdfAbout.html

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,19 @@
2020
/*Get info about Product*/
2121
const json = AsposePdfAbout();
2222
/* JSON
23-
Product name: json.product
24-
Product family: json.family
25-
Product version: json.version
26-
Date release: json.releasedate
27-
Full name/producer: json.producer
23+
Product name : json.product
24+
Product family : json.family
25+
Product version : json.version
26+
Date release : json.releasedate
27+
Full name/producer : json.producer
28+
Product is licensed: json.islicensed
2829
*/
29-
if (json.errorCode == 0) document.getElementById('output').textContent = "JSON:\n" + JSON.stringify(json, null, 4);
30+
if (json.errorCode == 0) document.getElementById('output').textContent = "Product : " + json.product
31+
+ "\nFamily : " + json.family
32+
+ "\nVersion : " + json.version
33+
+ "\nRelease date : " + json.releasedate
34+
+ "\nProducer : " + json.producer
35+
+ "\nIs licensed : " + json.islicensed;
3036
else document.getElementById('output').textContent = json.errorText;
3137
}
3238
/// [Code snippet]

snippets/AsposePdfAbout_worker.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@
2020
AsposePDFWebWorker.onerror = evt => console.log(`Error from Web Worker: ${evt.message}`);
2121
AsposePDFWebWorker.onmessage = evt => document.getElementById('output').textContent =
2222
(evt.data == 'ready') ? 'loaded!' :
23-
(evt.data.json.errorCode == 0) ? evt.data.json.producer : `Error: ${evt.data.json.errorText}`;
23+
(evt.data.json.errorCode !== 0) ? `Error: ${evt.data.json.errorText}` :
24+
"Product : " + evt.data.json.product
25+
+ "\nFamily : " + evt.data.json.family
26+
+ "\nVersion : " + evt.data.json.version
27+
+ "\nRelease date : " + evt.data.json.releasedate
28+
+ "\nProducer : " + evt.data.json.producer
29+
+ "\nIs licensed : " + evt.data.json.islicensed;
2430

2531
/*Event handler*/
2632
const onAsposePdfAbout = e => {

snippets/AsposePdfGetInfo.html

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,49 @@
2323
/*Get info (metadata) from a PDF-file*/
2424
const json = AsposePdfGetInfo(event.target.result, e.target.files[0].name);
2525
/* JSON
26-
Title: json.title
27-
Creator: json.creator
28-
Author: json.author
29-
Subject: json.subject
30-
Keywords: json.keywords
31-
Creation Date: json.creation
32-
Modify Date: json.mod
33-
PDF format: json.format
34-
PDF version: json.version
35-
PDF is PDF/A: json.ispdfa
36-
PDF is PDF/UA: json.ispdfua
37-
PDF permission: json.permission
38-
PDF page size: json.size
39-
Page count: json.pagecount
26+
Title : json.title
27+
Creator : json.creator
28+
Author : json.author
29+
Subject : json.subject
30+
Keywords : json.keywords
31+
Creation Date : json.creation
32+
Modify Date : json.mod
33+
PDF format : json.format
34+
PDF version : json.version
35+
PDF is PDF/A : json.ispdfa
36+
PDF is PDF/UA : json.ispdfua
37+
PDF permission : json.permission
38+
PDF page size : json.size
39+
Page count : json.pagecount
40+
Annotation count: json.annotationcount
41+
Bookmark count : json.bookmarkcount
42+
Attachment count: json.attachmentcount
43+
Metadata count : json.metadatacount
44+
JavaScript count: json.javascriptcount
45+
Image count : json.imagecount
4046
*/
41-
if (json.errorCode == 0) document.getElementById('output').textContent = "JSON:\n" + JSON.stringify(json, null, 4);
47+
if (json.errorCode == 0) document.getElementById('output').textContent = "Title : " + json.title
48+
+ "\nCreator : " + json.creator
49+
+ "\nAuthor : " + json.author
50+
+ "\nSubject : " + json.subject
51+
+ "\nKeywords : " + json.keywords
52+
+ "\nCreation Date : " + json.creation
53+
+ "\nModify Date : " + json.mod
54+
+ "\nPDF format : " + json.format
55+
+ "\nPDF version : " + json.version
56+
+ "\nPDF is PDF/A : " + json.ispdfa
57+
+ "\nPDF is PDF/UA : " + json.ispdfua
58+
+ "\nPDF is linearized : " + json.islinearized
59+
+ "\nPDF is encrypted : " + json.isencrypted
60+
+ "\nPDF permission : " + json.permission
61+
+ "\nPDF page size : " + json.size
62+
+ "\nPage count : " + json.pagecount
63+
+ "\nAnnotation count : " + json.annotationcount
64+
+ "\nBookmark count : " + json.bookmarkcount
65+
+ "\nAttachment count : " + json.attachmentcount
66+
+ "\nMetadata count : " + json.metadatacount
67+
+ "\nJavaScript count : " + json.javascriptcount
68+
+ "\nImage count : " + json.imagecount;
4269
else document.getElementById('output').textContent = json.errorText;
4370
};
4471
file_reader.readAsArrayBuffer(e.target.files[0]);

0 commit comments

Comments
 (0)