简体   繁体   English

将网页转换为pdf图像的最佳方法

[英]The best way to convert web-page to pdf image

任何人都可以告诉我一个简单的方法将网页屏幕截图转换为PDF格式

If you are trying to do this from a desktop user standpoint 如果您尝试从桌面用户的角度来执行此操作
Windows: http://www.go2pdf.com/product.html Windows: http//www.go2pdf.com/product.html
Linux: http://www.linux.com/archive/feed/35022 Linux: http//www.linux.com/archive/feed/35022

If you mean form code then: 如果您指的是表单代码,那么:
PHP: http://www.imagemagick.org/script/formats.php PHP: http//www.imagemagick.org/script/formats.php

But more information would definitely be useful :D 但更多信息肯定会有用:D

PDFMyURLcom , hands down. PDFMyURLcom ,请放下。

Perfect rendering, except for some custom fonts. 完美渲染,除了一些自定义字体。 Here's an example: 这是一个例子:

http://pdfmyurl.com?url=github.com/portfolio&-B=0mm&-T=0mm&-L=0mm&--margin-right=0mm&--page-size=A3&-O=Portrait . http://pdfmyurl.com?url=github.com/portfolio&-B=0mm&-T=0mm&-L=0mm&--margin-right=0mm&--page-size=A3&-O=Portrait

Creating a PDF from HTML instead of letting the user just see the HTML should not be done without consideration. 从HTML创建PDF而不是让用户只看到HTML不应该在没有考虑的情况下完成。 If you already have a usable HTML page you can display, ask yourself: what would the user benefit from having this in a PDF ? 如果您已经有一个可用的HTML页面可以显示,请问自己:用户在PDF中有什么好处? If the issue still stands, here are a few options: 如果问题仍然存在,可以选择以下几种方法:

  • Use the well known but buggy DOMPDF . 使用众所周知但有缺陷的DOMPDF All you need is PHP, and it renders somewhat decent. 所有你需要的是PHP,它呈现一些体面。 They had some security problems but those went relatively unnoticed because no big fish is using it. 他们遇到了一些安全问题,但由于没有大鱼在使用它,因此相对不被注意。 No CSS support. 没有CSS支持。
  • Use wkhtmltopdf which is absolutely great, supports CSS etc. Thing is, it requires access to the box. 使用wkhtmltopdf这绝对是伟大的,支持CSS等。事实是,它需要访问框。 Oh, and another pesky little issue, X client libraries must be installed. 哦,另一个讨厌的小问题,必须安装X客户端库。 Aside from that, it renders great and the PDF you are producing ends up looking a lot like the original page. 除此之外,它呈现出色,并且您生成的PDF最终看起来很像原始页面。
  • If the HTML is dynamic (outputted by some script), have it outputted directly as a PDF, using PDFLIB or it's poor cousin FPDF . 如果HTML是动态的(由某些脚本输出),可以使用PDFLIB或者它的表兄FPDF直接输出为PDF。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM