I am currently working on a document generator symfony 2 bundle which allows to generate HTML and PDF documents (such as an invoice).
When i generate my document in-browser as an HTML page, everything's fine, but when i generate my PDF file, i have no fonts applied to my document.
I use the same templates for both case. Here is my pdf generation method :
private function generatePdfWithoutMerge($html)
{
$pdfService = $this->get('knp_snappy.pdf');
return $pdfService->getOutputFromHtml($html);
}
The $html variable is generated from a rendered twig template and, as said before, i have no issues if i display it as HTML in my browser.
LESS File :
@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;
}