Skip to content

Instantly share code, notes, and snippets.

@blog-aspose-cloud
Last active October 6, 2024 16:46
Show Gist options
  • Select an option

  • Save blog-aspose-cloud/0b9b424974f335d0694d176a894764a7 to your computer and use it in GitHub Desktop.

Select an option

Save blog-aspose-cloud/0b9b424974f335d0694d176a894764a7 to your computer and use it in GitHub Desktop.

Revisions

  1. blog-aspose-cloud revised this gist Dec 19, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion readme.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    # Convert PDF to Word in Node.js
    <br>
    <a href="https://wiki.fileformat.com/view/pdf/">PDF<a> file is multiplatform and can be viewed on any platform and you can edit files to some extent. However, we cannot easily edit the PDF file but on the other end, if we have a word document, its easy to edit and manipulate the content inside it.
    This gist explains the steps on how to develop PDF to Word converter online using <a href="https://products.aspose.cloud/pdf/nodejs/">Aspose.PDF Cloud SDK for Node.js</a>. For complete information, please visit <a href="https://blog.aspose.cloud/pdf/pdf-to-doc-converter-aspose.pdf-cloud-sdks-for-node.js/">PDF To Word in Node.js.</a>.
    This gist explains the steps on how to develop PDF to Word converter online using <a href="https://products.aspose.cloud/pdf/nodejs/">Aspose.PDF Cloud SDK for Node.js</a>. For complete information, please visit <a href="https://blog.aspose.cloud/pdf/pdf-to-doc-converter-aspose.pdf-cloud-sdks-for-node.js/">PDF To Word in Node.js.</a>

    ![pdf to word](https://blog.aspose.cloud/pdf/pdf-to-doc-converter-aspose.pdf-cloud-sdks-for-node.js/images/pdf-to-doc-convertor.png)

  2. blog-aspose-cloud revised this gist Dec 15, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion readme.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    # Convert PDF to Word in Node.js
    <br>
    <a href="https://wiki.fileformat.com/view/pdf/">PDF<a> file is multiplatform and can be viewed on any platform and you can edit files to some extent. However, we cannot easily edit the PDF file but on the other end, if we have a word document, its easy to edit and manipulate the content inside it.
    This gist explains the steps on how to develop PDF to Word converter online using <a href="https://products.aspose.cloud/pdf/nodejs/">Aspose.PDF Cloud SDK for Node.js</a>. For complete information, please visit <a href="https://blog.aspose.cloud/pdf/pdf-to-doc-converter-aspose.pdf-cloud-sdks-for-node.js/">PDF To Word in Node.js. PDF to DOCX or PDF to DOC conversion</a>.
    This gist explains the steps on how to develop PDF to Word converter online using <a href="https://products.aspose.cloud/pdf/nodejs/">Aspose.PDF Cloud SDK for Node.js</a>. For complete information, please visit <a href="https://blog.aspose.cloud/pdf/pdf-to-doc-converter-aspose.pdf-cloud-sdks-for-node.js/">PDF To Word in Node.js.</a>.

    ![pdf to word](https://blog.aspose.cloud/pdf/pdf-to-doc-converter-aspose.pdf-cloud-sdks-for-node.js/images/pdf-to-doc-convertor.png)

  3. blog-aspose-cloud created this gist Dec 15, 2022.
    1 change: 1 addition & 0 deletions PDF to Word in Node.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    Convert PDF to Word using Node.js SDK
    51 changes: 51 additions & 0 deletions pdf-to-word.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,51 @@
    import { Controller, Post } from '@nestjs/common';
    import { AppService } from './app.service';
    import { PdfApi } from 'asposepdfcloud';
    import \* as fs from 'fs';
    @Controller()
    export class AppController {
    constructor(private readonly appService: AppService) {}

    @Post('/pdf-to-doc')
    async pdfToDoc() {
    const name = 'm.pdf';
    const SrcFile = '/' + name;
    const resultName = 'result.doc';
    const resultPath = 'myfolder/' + resultName;
    const storageName = 'testing';
    const fileToWrite = process.cwd() + '/' + resultName;
    const pdfApi = new PdfApi(
    'YOUR-APPSID',
    'YOUR-APPKEY',
    );
    try {
    const data = fs.readFileSync(name);
    await pdfApi.uploadFile(SrcFile, new Buffer(data), storageName);
    await pdfApi.putPdfInStorageToDoc(
    name,
    resultPath,
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    '',
    '',
    '',
    '',
    '',
    '',
    '',
    '',
    '',
    storageName,
    );

    // Download pdf from cloud storage

    const fileData = await pdfApi.downloadFile(resultPath, storageName, '');
    const writeStream = fs.createWriteStream(fileToWrite);
    writeStream.write(fileData.body);
    return 'PDF converted to DOC successfully';
    } catch (e) {
    throw e;
    }
    }
    }
    10 changes: 10 additions & 0 deletions readme.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    # Convert PDF to Word in Node.js
    <br>
    <a href="https://wiki.fileformat.com/view/pdf/">PDF<a> file is multiplatform and can be viewed on any platform and you can edit files to some extent. However, we cannot easily edit the PDF file but on the other end, if we have a word document, its easy to edit and manipulate the content inside it.
    This gist explains the steps on how to develop PDF to Word converter online using <a href="https://products.aspose.cloud/pdf/nodejs/">Aspose.PDF Cloud SDK for Node.js</a>. For complete information, please visit <a href="https://blog.aspose.cloud/pdf/pdf-to-doc-converter-aspose.pdf-cloud-sdks-for-node.js/">PDF To Word in Node.js. PDF to DOCX or PDF to DOC conversion</a>.

    ![pdf to word](https://blog.aspose.cloud/pdf/pdf-to-doc-converter-aspose.pdf-cloud-sdks-for-node.js/images/pdf-to-doc-convertor.png)

    ## Important Links

    [Product Page](https://products.aspose.cloud/pdf/nodejs/) | [Docs](https://docs.aspose.cloud/pdf/developer-guide/) | [Live Demo](https://products.aspose.app/pdf/family) | [Swagger UI](https://apireference.aspose.cloud/pdf/) | [Code Samples](https://github.com/aspose-pdf-cloud/aspose-pdf-cloud-node.js/tree/master/Examples) | [Source Code](https://github.com/aspose-pdf-cloud/aspose-pdf-cloud-node.js) | [New Releases](https://repository.aspose.cloud/pdf/) | [Blog](https://blog.aspose.cloud/category/pdf/) | [Free Support](https://forum.aspose.cloud/c/pdf/13) | [Free Trial](https://purchase.aspose.cloud/trial)