Can I read PDF or Word Docs with Node.js?

后端 未结 8 2060
不知归路
不知归路 2021-02-02 14:11

I can\'t find any packages to do this. I know PHP has a ton of libraries for PDFs (like http://www.fpdf.org/) but anything for Node?

相关标签:
8条回答
  • 2021-02-02 14:34

    Another good option if you only need to convert from Word documents is Mammoth.js.

    Mammoth is designed to convert .docx documents, such as those created by Microsoft Word, and convert them to HTML. Mammoth aims to produce simple and clean HTML by using semantic information in the document, and ignoring other details. For instance, Mammoth converts any paragraph with the style Heading 1 to h1 elements, rather than attempting to exactly copy the styling (font, text size, colour, etc.) of the heading.

    There's a large mismatch between the structure used by .docx and the structure of HTML, meaning that the conversion is unlikely to be perfect for more complicated documents. Mammoth works best if you only use styles to semantically mark up your document.

    0 讨论(0)
  • 2021-02-02 14:44

    You can easily convert one into another, or use for example a .doc template to generate a .pdf file, but you will probably want to use an existing web service for this task.

    This can be done using the services of Livedocx for example

    To use this service from node, see node-livedocx (Disclaimer: I am the author of this node module)

    0 讨论(0)
提交回复
热议问题