简体   繁体   English

精确将html转换为pdf

[英]Exact html to pdf convert

I am writing an application (using Laravel framework), where user manually designs a poster, flyer and some other printable stuff. 我正在编写一个应用程序(使用Laravel框架),用户可以在其中手动设计海报,传单和其他可打印的内容。 So i made a JavaScript tool to allow above. 所以我做了一个JavaScript工具来允许以上。 In backend i have to make itprintable, so i tried to convert it to pdf. 在后端,我必须使其可打印,因此我尝试将其转换为pdf。 And that's where problems occure ie: 那就是问题发生的地方,即:

  1. html design is made in px and as far now i don't know how to recalculate it to mm which pdf operates in, html设计是以px为单位,到目前为止,我还不知道如何将其重新计算为pdf用于的mm,
  2. fonts are being renderet different etc. 字体正在渲染不同等。

I tried using https://github.com/dompdf/dompdf , https://github.com/barryvdh/laravel-snappy (which uses http://wkhtmltopdf.org/ ) but both give similar outputs. 我尝试使用https://github.com/dompdf/dompdfhttps://github.com/barryvdh/laravel-snappy (使用http://wkhtmltopdf.org/ )但两者给出相似的输出。

Does anybody know a solution how to convert content made in browser to printable version? 有人知道如何将浏览器中的内容转换为可打印版本的解决方案吗?

use this formula to convert pix into mm: 使用以下公式将pix转换为mm:

$witnInMM = floor(($withInPx * 25.4) / $dpi]);
$heightInMM = floor(($heightInPx * 25.4) / $dpi]);

Also I am working on a similar project and to convert the images to pdf I am using Imagick. 另外,我正在从事类似的项目,并将图像转换为pdf。 I tried snappy laravel but won't work with CMYK colours. 我尝试了活泼的laravel,但无法使用CMYK颜色。

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

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