Skip to content

Commit 66d3201

Browse files
Aspose.PDF for JavaScript via C++ 25.8
1 parent 8443e50 commit 66d3201

File tree

7 files changed

+118
-14
lines changed

7 files changed

+118
-14
lines changed

AsposePDFforJS.js

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

AsposePDFforJS.wasm.zip

193 KB
Binary file not shown.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Add PDF processing, manipulation, and conversion features to your front-end appl
1717
- **Concatenate**, **split**, or **reorganize** PDF files; delete specific or blank pages.
1818
- **Linearize** PDF documents for web optimization and **optimize** internal structure and resources.
1919
- **Convert** PDF documents to:
20-
- **Office formats:** DOC, DOCX, XLS, XLSX, PPTX
20+
- **Office formats:** DOC, DOCX, XLS, XLSX, PPTX, DOCX with Enhanced Recognition Mode
2121
- **Web formats:** SVG, SVG (ZIP), XPS, EPUB
2222
- **Image formats:** JPEG, PNG, BMP, TIFF, DICOM
2323
- **Other formats:** Grayscale PDF, PDF/A, TeX, TXT, Markdown

example.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ <h2>Aspose.PDF for JavaScript via C++</h2>
130130
<label for="fileToMarkdown">MD<span class="tooltip">Convert a PDF-file to Markdown</span></label>
131131
<input type="file" id="fileToMarkdown" accept="application/pdf" onchange="ffileToMarkdown(event)">
132132
</div>
133+
<div class="column">
134+
<label for="fileToDocXEnhanced">DOCX ENHANCED<span class="tooltip">Convert a PDF-file to DocX with Enhanced Recognition Mode (fully editable tables and paragraphs)</span></label>
135+
<input type="file" id="fileToDocXEnhanced" accept="application/pdf" onchange="ffileToDocXEnhanced(event)">
136+
</div>
133137
</div>
134138
</div>
135139

@@ -699,6 +703,17 @@ <h2>Aspose.PDF for JavaScript via C++</h2>
699703
file_reader.readAsArrayBuffer(e.target.files[0]);
700704
}
701705

706+
var ffileToDocXEnhanced = function (e) {
707+
const file_reader = new FileReader();
708+
file_reader.onload = (event) => {
709+
const json = AsposePdfToDocXEnhanced(event.target.result, e.target.files[0].name, "ResultPDFtoDocXEnhanced.docx");
710+
if (json.errorCode == 0) document.getElementById('output').textContent = json.fileNameResult;
711+
else document.getElementById('output').textContent = json.errorText;
712+
DownloadFile(json.fileNameResult, "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
713+
}
714+
file_reader.readAsArrayBuffer(e.target.files[0]);
715+
}
716+
702717
var ffileToXlsX = function (e) {
703718
const file_reader = new FileReader();
704719
file_reader.onload = (event) => {

example_worker.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
<option value="AsposePdfConvertToPDFA">Convert a PDF-file to PDF/A</option>
4242
<option value="AsposePdfAConvertToPDF">Convert a PDF/A-file to PDF</option>
4343
<option value="AsposePdfToDocX">Convert a PDF-file to DocX</option>
44+
<option value="AsposePdfToDocXEnhanced">Convert a PDF-file to DocX with Enhanced Recognition Mode</option>
4445
<option value="AsposePdfToXlsX">Convert a PDF-file to XlsX</option>
4546
<option value="AsposePdfToEPUB">Convert a PDF-file to ePub</option>
4647
<option value="AsposePdfToDoc">Convert a PDF-file to Doc</option>
@@ -262,6 +263,7 @@
262263
DownloadFile(json.fileNameLogResult, "application/xml", params[1]);
263264
break;
264265
case 'AsposePdfToDocX':
266+
case 'AsposePdfToDocXEnhanced':
265267
DownloadFile(json.fileNameResult, "application/vnd.openxmlformats-officedocument.wordprocessingml.document", params[0]);
266268
break;
267269
case 'AsposePdfToXlsX':
@@ -363,6 +365,7 @@
363365
params = [event.target.result, ffile.name];
364366
break;
365367
case 'AsposePdfToDocX':
368+
case 'AsposePdfToDocXEnhanced':
366369
transfer = [event.target.result];
367370
params = [event.target.result, ffile.name, `Result${operation}.docx`];
368371
break;
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
<meta charset="UTF-8">
7+
<title>Aspose.PDF for JavaScript via C++</title>
8+
</head>
9+
10+
<body>
11+
<label for="fileToDocXEnhanced">Choose a PDF-file to convert to DocX with Enhanced Recognition Mode (fully editable tables and paragraphs)</label>
12+
<input type="file" id="fileToDocXEnhanced" accept="application/pdf" onchange="ffileToDocXEnhanced(event)">
13+
<br>
14+
<pre id="output"></pre>
15+
</body>
16+
<!-- Load and initiate Aspose.PDF for JavaScript via C++ -->
17+
<script type="text/javascript" async src="AsposePDFforJS.js"></script>
18+
<script type="text/javascript">
19+
/// [Code snippet]
20+
var ffileToDocXEnhanced = function (e) {
21+
const file_reader = new FileReader();
22+
file_reader.onload = (event) => {
23+
/*Convert a PDF-file to DocX with Enhanced Recognition Mode (fully editable tables and paragraphs) and save the "ResultPDFtoDocXEnhanced.docx"*/
24+
const json = AsposePdfToDocXEnhanced(event.target.result, e.target.files[0].name, "ResultPDFtoDocXEnhanced.docx");
25+
if (json.errorCode == 0) document.getElementById('output').textContent = json.fileNameResult
26+
else document.getElementById('output').textContent = json.errorText;
27+
/*Make a link to download the result file*/
28+
DownloadFile(json.fileNameResult, "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
29+
}
30+
file_reader.readAsArrayBuffer(e.target.files[0]);
31+
}
32+
/// [Code snippet]
33+
</script>
34+
35+
</html>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
<meta charset="UTF-8">
7+
<title>Aspose.PDF for JavaScript via C++</title>
8+
</head>
9+
10+
<body>
11+
<label for="fileToDocXEnhanced">Choose a PDF-file to convert to DocX with Enhanced Recognition Mode (fully editable tables and paragraphs)</label>
12+
<input type="file" id="fileToDocXEnhanced" accept="application/pdf" onchange="ffileToDocXEnhanced(event)">
13+
<br>
14+
<pre id="output">please wait for loading...</pre>
15+
</body>
16+
17+
<script type="text/javascript">
18+
/// [Code snippet]
19+
/*Create Web Worker*/
20+
const AsposePDFWebWorker = new Worker("AsposePDFforJS.js");
21+
AsposePDFWebWorker.onerror = evt => console.log(`Error from Web Worker: ${evt.message}`);
22+
AsposePDFWebWorker.onmessage = evt => document.getElementById('output').textContent =
23+
(evt.data == 'ready') ? 'loaded!' :
24+
(evt.data.json.errorCode == 0) ? `Result:\n${DownloadFile(evt.data.json.fileNameResult, "application/vnd.openxmlformats-officedocument.wordprocessingml.document", evt.data.params[0])}` : `Error: ${evt.data.json.errorText}`;
25+
26+
/*Event handler*/
27+
const ffileToDocXEnhanced = e => {
28+
const file_reader = new FileReader();
29+
file_reader.onload = event => {
30+
/*Convert a PDF-file to DocX and with Enhanced Recognition Mode (fully editable tables and paragraphs) save the "ResultPDFtoDocXEnhanced.docx" - Ask Web Worker*/
31+
AsposePDFWebWorker.postMessage({ "operation": 'AsposePdfToDocXEnhanced', "params": [event.target.result, e.target.files[0].name, "ResultPDFtoDocXEnhanced.docx"] }, [event.target.result]);
32+
};
33+
file_reader.readAsArrayBuffer(e.target.files[0]);
34+
};
35+
/// [Code snippet]
36+
37+
/*Make a link to download the result file*/
38+
const DownloadFile = (filename, mime, content) => {
39+
mime = mime || "application/octet-stream";
40+
var link = document.createElement("a");
41+
link.href = URL.createObjectURL(new Blob([content], {type: mime}));
42+
link.download = filename;
43+
link.innerHTML = "Click here to download the file " + filename;
44+
document.body.appendChild(link);
45+
document.body.appendChild(document.createElement("br"));
46+
return filename;
47+
}
48+
</script>
49+
50+
</html>

0 commit comments

Comments
 (0)