我目前正在开发一个文档生成器symfony 2包,它允许生成HTML和PDF文档(例如发票)。
当我以HTML页面的形式在浏览器中生成我的文档时,一切都很好,但是当我生成PDF文件时,我没有字体应用于我的文档。
对于这两种情况,我使用相同的模板。以下是我的pdf生成方法:
private function generatePdfWithoutMerge($html)
{
$pdfService = $this->get('knp_snappy.pdf');
return $pdfService->getOutputFromHtml($html);
}$html变量是从呈现的小枝模板生成的,正如前面所说的,如果我在浏览器中将它显示为HTML,就没有问题。
减档案:
@base-url: 'url-to-bucket';
@dark-grey: #555559;
@dark-pink: #970047;
@font-face {
font-family: paralucent_demi_boldregular;
src: url('@{base-url}/paradb__-webfont.eot');
src: url('@{base-url}/paradb__-webfont.eot?#iefix') format('embedded-opentype'),
url('@{base-url}/paradb__-webfont.woff') format('woff'),
url('@{base-url}/paradb__-webfont.ttf') format('truetype'),
url('@{base-url}/paradb__-webfont.svg#paralucent_demi_boldregular') format('svg');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: paralucent_lightregular;
src: url('@{base-url}/paral___-webfont.eot');
src: url('@{base-url}/paral___-webfont.eot?#iefix') format('embedded-opentype'),
url('@{base-url}/paral___-webfont.woff') format('woff'),
url('@{base-url}/paral___-webfont.ttf') format('truetype'),
url('@{base-url}/paral___-webfont.svg#paralucent_lightregular') format('svg');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: paralucent_thinregular;
src: url('@{base-url}/parat___-webfont.eot');
src: url('@{base-url}/parat___-webfont.eot?#iefix') format('embedded-opentype'),
url('@{base-url}/parat___-webfont.woff') format('woff'),
url('@{base-url}/parat___-webfont.ttf') format('truetype'),
url('@{base-url}/parat___-webfont.svg#paralucent_thinregular') format('svg');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: paralucent_mediumregular;
src: url('@{base-url}/param___-webfont.eot');
src: url('@{base-url}/param___-webfont.eot?#iefix') format('embedded-opentype'),
url('@{base-url}/param___-webfont.woff') format('woff'),
url('@{base-url}/param___-webfont.ttf') format('truetype'),
url('@{base-url}/param___-webfont.svg#paralucent_mediumregular') format('svg');
font-weight: normal;
font-style: normal;
}
body {
color: @dark-grey;
font-family: paralucent_lightregular, Helvetica, Arial, sans-serif;
font-size: 1.2em;
line-height: 0.9em;
}
.thin {
font-family: paralucent_thinregular, Helvetica, Arial, sans-serif;
}
.bold {
font-family: paralucent_mediumregular, Helvetica, Arial, sans-serif;
}
.demibold {
font-family: paralucent_demi_boldregular, Helvetica, Arial, sans-serif;
}
.price {
font-family: Arial, sans-serif;
font-size: 0.8em;
}
.separator_unbreak_wrapper {
}
.separator_unbreak {
page-break-inside: avoid !important;
}
.city_format {
font-size: 0.75em;
}
table tr th {
border-bottom: 1px solid @dark-pink;
font-weight: normal;
font-style: normal;
}发布于 2016-03-16 14:45:42
感谢DevDonkey的评论:
我试图拥有一个很好的文件体系结构,其中包含一个从公共父模板扩展而来的子模板和一个公共的更少的文件,但是Wkhtmltopdf在这样复杂的体系结构中存在一些问题。我必须将所有内容收集到一个HTML文件中才能正常工作。
非常感谢你的帮助。
https://stackoverflow.com/questions/36037405
复制相似问题