将 HTML 转换为 doc(x) 和/或 PDF

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8404019/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 11:51:17  来源:igfitidea点击:

Converting HTML to doc(x) and / or PDF

htmlpdfdocxdocaspose

提问by Boas Enkler

I have to convert html to the doc(x) and pdf format.

我必须将 html 转换为 doc(x) 和 pdf 格式。

I found aspose, but this tool can do a lot of more work than i need, and thats why it isn't really cheap.

我发现 aspose,但是这个工具可以做比我需要的更多的工作,这就是为什么它并不便宜。

Are there similar tools, which can just do this conversion ?

是否有类似的工具,可以进行这种转换?

I need this on a Desktopapplication where no word / office is installed

我在没有安装 word/office 的桌面应用程序上需要这个

*Just for Info Finally bought asponse words. all other options weren't as good as this tool

*仅供参考 终于买了回应词。所有其他选项都没有这个工具那么好

回答by BRPocock

Assuming that these are essentially “documents” and not fancy graphical web pages (i.e. you'd like them to be legible, but aren't deeply concerned with the minuti? of web layout formatting), you can use LibreOffice to convert them; either manually (open, export as…) or using the "headless" mode, e.g.:

假设这些本质上是“文档”,而不是花哨的图形网页(即您希望它们清晰易读,但不关心网页布局格式的细节?),您可以使用 LibreOffice 来转换它们;手动(打开,导出为...)或使用“无头”模式,例如:

soffice -headless -convert-to pdf -outdir pdfs/ *.html
soffice -headless -convert-to doc -outdir docs/ *.html

Free, cross-platform, but a bit of a hefty install. (I think it's nearing the half-gigabyte mark for the full suite with all the plug-ins installed, but you should only need the Writer component)

免费的,跨平台的,但安装量有点大。(我认为安装了所有插件的完整套件已接近半 GB 标记,但您应该只需要 Writer 组件)

回答by Siar

Maybe this http://kitpdf.commight help. I tried it, it's free and really easy to use.

也许这个http://kitpdf.com可能会有所帮助。我试过了,它是免费的,而且非常容易使用。

回答by illbzo1

I can't speak for docx format, but you might look into DocRaptor to convert HTML to PDFformat. It definitely handles CSS styling better than comparable programs, and doesn't just give you an image like creating a PDF with Photoshop.

我不能说 docx 格式,但您可以查看 DocRaptor将 HTML 转换为 PDF格式。它肯定比同类程序更好地处理 CSS 样式,并且不仅仅为您提供像使用 Photoshop 创建 PDF 之类的图像。

回答by Thorgeir

回答by adamhuxtable

If the webpage is or can be hosted then you can download an extension for Google Chrome called Screen Capture, this allows you to take a full screen grab of the webpage then you can paste it into Photoshop and Save As a .pdf (that is assuming you have Photoshop that is)

如果网页是或可以托管,那么您可以下载名为 Screen Capture 的 Google Chrome 扩展程序,这允许您全屏抓取网页,然后您可以将其粘贴到 Photoshop 中并另存为 .pdf(假设你有 Photoshop 那是)