HTML to PDF批量模式转换器,尊重CSS的@ font-face? [英] HTML to PDF Batch Mode Converter that Respects CSS's @font-face?

查看:108
本文介绍了HTML to PDF批量模式转换器,尊重CSS的@ font-face?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

注:我的请求涵盖软件或库,因此我在这里发布。我也在这里检查了类似的线程,但他们要求的东西略有不同。



我有以下的HTML页面:

 < html> 
< head>
< link rel =stylesheettype =text / csshref =font.css>
< style>
body {
font-family:Gotham SSm A;
font-size:22px;
}
< / style>
< / head>
< body>
摘要
< / body>
< / html>



font.css中的字体定义(为了简洁起见被截断):

  @ font-face {
font-family:Gotham SSm A;
src:url(data:font / truetype; base64,...)format('truetype');
font-weight:700;
font-style:italic;
}

页面在浏览器中显示正常,并且从浏览器也呈现良好。但是,我用来从服务器端软件(PHP)生成PDF的每个实用程序都失败了:


  1. Wkhtmltopdf,PhantomJS和PrinceXML没有显示正确的字体(后者给出了关于不解析所有CSS规则的警告)。

  2. 不可接受的
    依赖关系pandoc只能转换为LaTeX并需要不同的实用程序(在
    Windows / Linux上)才能转为PDF。更重要的是,它的LaTeX转换
    (根据在线版本I trie)把字体弄乱了

我有什么选择?我需要这个......

  1。尊重现代CSS(包括@ font-face)。 
2.在Windows&在
上有类似输出的Linux 3.离线(实用程序或库很好)
4.允许商业使用
5.具有成本效益(最好是免费)


我不能将您指向一个网址,因为它将在2015年1月发布,但如果您想查看它是否有效,请发送私人讯息。


NOTES: My request covers software or libraries, hence why I'm posting here. I also checked the similar threads here, but they asked for something subtly different.

I have the following HTML page:

<html>
<head>
   <link rel="stylesheet" type="text/css" href="font.css">
   <style>
      body {
        font-family: "Gotham SSm A";
        font-size: 22px;
      }
   </style>
</head>
<body>
   SUMMARY
</body>
</html>

And the font definition in font.css (truncated for brevity):

@font-face { 
   font-family: "Gotham SSm A"; 
   src: url(data:font/truetype;base64,...) format('truetype'); 
   font-weight:700; 
   font-style:italic; 
}

The page shows up fine in the browser, and when printed to PDF from the browser, is rendered fine as well. However, every utility I used to generate a PDF from server-side software (PHP) failed:

  1. Wkhtmltopdf, PhantomJS and PrinceXML didn't show the correct font (the latter gave a warning about not parsing all the CSS rules).

  2. SlimerJS failed to render, opened windows, and had unacceptable dependencies

  3. pandoc only converts to LaTeX and requires different utilities (on Windows/Linux) to go to PDF. What's more, it's LaTeX conversion (according to the online version I trie) messed up the fonts as well.

What are my alternatives? I need this to...

1. Respect modern CSS (including @font-face).
2. Be available on Windows & Linux with similar output on both
3. Be offline (utility or library is fine)
4. Allow commercial use
5. Be cost effective (preferably free)

解决方案

callas software (watch it, I'm affiliated with this company!) has a technology they have been working on called pdfChip which will do this perfectly. It's not free, but it will handle HTML + CSS + Javascript using a simple command-line tool. And it can generate good, print-ready PDF (including PDF/X, metadata, professional color spaces, bar codes and more...).

I can't point you to a URL yet as it's going to be released in January 2015, but send me a private message if you want to see whether it would work.

这篇关于HTML to PDF批量模式转换器,尊重CSS的@ font-face?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆