是否可以使用 Puppeteer 将 PDF 转换为 HTML?

Is it possible to use Puppeteer to convert PDF to HTML?

我知道可以用其他方式(HTML 到 PDF),但可以用其他方式完成吗?

我没有找到与此相关的任何文档。

不,Puppeteer 不能用于将 PDF 转换为 HTML。根据其网站:

Puppeteer is a Node library which provides a high-level API to control Chrome or Chromium over the DevTools Protocol.

也就是说,Puppeteer 是一个无头的Chrome。由于 Chrome 无法将 PDF 转换为 HTML(如果我错了,请纠正我),Puppeteer 也不能。

不过,您可以使用其他npm模块,例如pdf-parse to parse the text content of PDF, and generating the HTML by yourself. Or, just use npm modules such as pdf2html直接转换pdf。