Skip to content

Commit 07a071a

Browse files
Aspose.PDF for JavaScript/Node.js via C++: AsposePdfToDocXEnhanced
1 parent 1bc6f8c commit 07a071a

File tree

6 files changed

+132
-0
lines changed

6 files changed

+132
-0
lines changed

english/javascript-cpp/_index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Such operations are very time consuming, so we recommend using Web Worker.
4343
| [AsposePdfExportXml](./convert/asposepdfexportxml/) | Export from a PDF-file with AcroForm to XML.|
4444
| [AsposePdfPagesToPDF](./convert/asposepdfpagestopdf/) | Convert a PDF-file to PDF (separate pages). |
4545
| [AsposePdfToMarkdown](./convert/asposepdftomarkdown/) | Convert a PDF-file to Markdown. |
46+
| [AsposePdfToDocXEnhanced](./convert/asposepdftodocxenhanced/) | Convert a PDF-file to DocX with Enhanced Recognition Mode. |
4647

4748

4849
## Convert to PDF functions

english/javascript-cpp/convert/_index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ url: /javascript-cpp/convert/
3636
| [AsposePdfExportXml](./asposepdfexportxml/) | Export from a PDF-file with AcroForm to XML.|
3737
| [AsposePdfPagesToPDF](./asposepdfpagestopdf/) | Convert a PDF-file to PDF (separate pages). |
3838
| [AsposePdfToMarkdown](./asposepdftomarkdown/) | Convert a PDF-file to Markdown. |
39+
| [AsposePdfToDocXEnhanced](./asposepdftodocxenhanced/) | Convert a PDF-file to DocX with Enhanced Recognition Mode. |
3940

4041

4142
## Detailed Description
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
title: "AsposePdfToDocXEnhanced"
3+
second_title: Aspose.PDF for JavaScript via C++
4+
description: "Convert a PDF-file to DocX with Enhanced Recognition Mode."
5+
type: docs
6+
url: /javascript-cpp/convert/asposepdftodocxenhanced/
7+
---
8+
9+
_Convert a PDF-file to DocX with Enhanced Recognition Mode (fully editable tables and paragraphs)._
10+
11+
```js
12+
function AsposePdfToDocXEnhanced(
13+
fileBlob,
14+
fileName,
15+
fileNameResult
16+
)
17+
```
18+
19+
**Parameters**:
20+
21+
* **fileBlob** Blob object
22+
* **fileName** file name
23+
* **fileNameResult** result file name
24+
25+
**Return**:
26+
JSON object
27+
* **errorCode** - code error (0 no error)
28+
* **errorText** - text error ("" no error)
29+
* **fileNameResult** - result file name
30+
31+
32+
**Web Worker example**:
33+
```js
34+
/*Create Web Worker*/
35+
const AsposePDFWebWorker = new Worker("AsposePDFforJS.js");
36+
AsposePDFWebWorker.onerror = evt => console.log(`Error from Web Worker: ${evt.message}`);
37+
AsposePDFWebWorker.onmessage = evt => document.getElementById('output').textContent =
38+
(evt.data == 'ready') ? 'loaded!' :
39+
(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}`;
40+
41+
/*Event handler*/
42+
const ffileToDocXEnhanced = e => {
43+
const file_reader = new FileReader();
44+
file_reader.onload = event => {
45+
/*Convert a PDF-file to DocX and with Enhanced Recognition Mode (fully editable tables and paragraphs) save the "ResultPDFtoDocXEnhanced.docx" - Ask Web Worker*/
46+
AsposePDFWebWorker.postMessage({ "operation": 'AsposePdfToDocXEnhanced', "params": [event.target.result, e.target.files[0].name, "ResultPDFtoDocXEnhanced.docx"] }, [event.target.result]);
47+
};
48+
file_reader.readAsArrayBuffer(e.target.files[0]);
49+
};
50+
51+
/*Make a link to download the result file*/
52+
const DownloadFile = (filename, mime, content) => {
53+
mime = mime || "application/octet-stream";
54+
var link = document.createElement("a");
55+
link.href = URL.createObjectURL(new Blob([content], {type: mime}));
56+
link.download = filename;
57+
link.innerHTML = "Click here to download the file " + filename;
58+
document.body.appendChild(link);
59+
document.body.appendChild(document.createElement("br"));
60+
return filename;
61+
}
62+
```
63+
**Simple example**:
64+
```js
65+
var ffileToDocXEnhanced = function (e) {
66+
const file_reader = new FileReader();
67+
file_reader.onload = (event) => {
68+
/*Convert a PDF-file to DocX with Enhanced Recognition Mode (fully editable tables and paragraphs) and save the "ResultPDFtoDocXEnhanced.docx"*/
69+
const json = AsposePdfToDocXEnhanced(event.target.result, e.target.files[0].name, "ResultPDFtoDocXEnhanced.docx");
70+
if (json.errorCode == 0) document.getElementById('output').textContent = json.fileNameResult
71+
else document.getElementById('output').textContent = json.errorText;
72+
/*Make a link to download the result file*/
73+
DownloadFile(json.fileNameResult, "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
74+
}
75+
file_reader.readAsArrayBuffer(e.target.files[0]);
76+
}
77+
```

english/nodejs-cpp/_index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ is_root: true
4242
| [AsposePdfExportXml](./convert/asposepdfexportxml/) | Export from a PDF-file with AcroForm to XML.|
4343
| [AsposePdfPagesToPDF](./convert/asposepdfpagestopdf/) | Convert a PDF-file to PDF (separate pages). |
4444
| [AsposePdfToMarkdown](./convert/asposepdftomarkdown/) | Convert a PDF-file to Markdown. |
45+
| [AsposePdfToDocXEnhanced](./convert/asposepdftodocxenhanced/) | Convert a PDF-file to DocX with Enhanced Recognition Mode. |
4546

4647

4748
## Convert to PDF functions

english/nodejs-cpp/convert/_index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ url: /nodejs-cpp/convert/
3636
| [AsposePdfExportXml](./asposepdfexportxml/) | Export from a PDF-file with AcroForm to XML.|
3737
| [AsposePdfPagesToPDF](./asposepdfpagestopdf/) | Convert a PDF-file to PDF (separate pages). |
3838
| [AsposePdfToMarkdown](./asposepdftomarkdown/) | Convert a PDF-file to Markdown. |
39+
| [AsposePdfToDocXEnhanced](./asposepdftodocxenhanced/) | Convert a PDF-file to DocX with Enhanced Recognition Mode. |
3940

4041

4142
## Detailed Description
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
title: "AsposePdfToDocXEnhanced"
3+
second_title: Aspose.PDF for Node.js via C++
4+
description: "Convert a PDF-file to DocX with Enhanced Recognition Mode."
5+
type: docs
6+
url: /nodejs-cpp/convert/asposepdftodocxenhanced/
7+
---
8+
9+
_Convert a PDF-file to DocX with Enhanced Recognition Mode (fully editable tables and paragraphs)._
10+
11+
```js
12+
function AsposePdfToDocXEnhanced(
13+
fileName,
14+
fileNameResult
15+
)
16+
```
17+
18+
**Parameters**:
19+
20+
* **fileName** file name
21+
* **fileNameResult** result file name
22+
23+
**Return**:
24+
JSON object
25+
* **errorCode** - code error (0 no error)
26+
* **errorText** - text error ("" no error)
27+
* **fileNameResult** - result file name
28+
29+
30+
**CommonJS**:
31+
32+
```js
33+
const AsposePdf = require('asposepdfnodejs');
34+
const pdf_file = 'Aspose.pdf';
35+
AsposePdf().then(AsposePdfModule => {
36+
/*Convert a PDF-file to DocX with Enhanced Recognition Mode (fully editable tables and paragraphs) and save the "ResultPDFtoDocXEnhanced.docx"*/
37+
const json = AsposePdfModule.AsposePdfToDocXEnhanced(pdf_file, "ResultPDFtoDocXEnhanced.docx");
38+
console.log("AsposePdfToDocXEnhanced => %O", json.errorCode == 0 ? json.fileNameResult : json.errorText);
39+
});
40+
```
41+
42+
**ECMAScript/ES6**:
43+
44+
```js
45+
import AsposePdf from 'asposepdfnodejs';
46+
const AsposePdfModule = await AsposePdf();
47+
const pdf_file = 'Aspose.pdf';
48+
/*Convert a PDF-file to DocX with Enhanced Recognition Mode (fully editable tables and paragraphs) and save the "ResultPDFtoDocXEnhanced.docx"*/
49+
const json = AsposePdfModule.AsposePdfToDocXEnhanced(pdf_file, "ResultPDFtoDocXEnhanced.docx");
50+
console.log("AsposePdfToDocXEnhanced => %O", json.errorCode == 0 ? json.fileNameResult : json.errorText);
51+
```

0 commit comments

Comments
 (0)