HTML to PDF批量模式转换器,尊重CSS的@ font-face? [英] HTML to PDF Batch Mode Converter that Respects CSS's @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的每个实用程序都失败了:
-
Wkhtmltopdf,PhantomJS和PrinceXML没有显示正确的字体(后者给出了关于不解析所有CSS规则的警告)。
- 不可接受的
依赖关系pandoc只能转换为LaTeX并需要不同的实用程序(在
Windows / Linux上)才能转为PDF。更重要的是,它的LaTeX转换
(根据在线版本I trie)把字体弄乱了
。
我有什么选择?我需要这个......
1。尊重现代CSS(包括@ font-face)。
2.在Windows&在
上有类似输出的Linux 3.离线(实用程序或库很好)
4.允许商业使用
5.具有成本效益(最好是免费)
$ clasc软件(看它,我隶属于这家公司!)拥有一项技术他们一直致力于所谓的pdfChip,它将完美地完成这项工作。它不是免费的,但它会使用简单的命令行工具处理HTML + CSS + Javascript。它可以生成良好的,可打印的PDF(包括PDF / X,元数据,专业色彩空间,条形码等等)。
我不能将您指向一个网址,因为它将在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:
Wkhtmltopdf, PhantomJS and PrinceXML didn't show the correct font (the latter gave a warning about not parsing all the CSS rules).
SlimerJS failed to render, opened windows, and had unacceptable
dependencies
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屋!