Hi folks,
I've been going over the examples and searched the form, but i can't figure out how to set a default font;
i have a variable $font which has the value freeserif
so now i want to set the default font with the following code:
$html2pdf->pdf->setDefaultFont($font);
this returns: Fatal error: Call to undefined method MyPDF::setDefaultFont() ....
also i have tried this: $html2pdf->pdf->setDefaultFont('freeserif');
which did return a pdf instead of an error, although the plain text that was parsed looked like arial, the html looked like this: 来汩敶攠瑥⁶敲浥汤敮 瀠畷潲牥獰潮摥湴楥
so, basicly... just to understand how to use a different font (present in the fonts folder that came with the zip), how do i set this? Am i missing something here?
Thanks!
Marco
Spipu Le 18/04/2011 à 16:21 With a font-family on a PAGE tag.
look at the examples (like utf8.php) in the ZIP file
Thanks Spipu,
Still getting the same error... just hardcoded 'freeserif' for testing, though the variable $font exsists with value freeserif
i've set (for testing) the PAGE tag like:
<page backtop="<?php echo $bodyT.'mm'; ?>" backbottom="<?php echo $bodyB.'mm'; ?>" backleft="<?php echo $bodyL.'mm'; ?>" backright="<?php echo $bodyR.'mm'; ?>" backimg="<?php echo $imgURL; ?>" backimgx="<?php echo $imgXpos; ?>" backimgy="<?php echo $imgYpos; ?>" backimgw="<?php echo $imgW; ?>" style="font-size: <?php echo $fontsize."pt"; ?>; font-family: freeserif; " >
<?php // instead of the above font-family, use: if ($font) { echo "font-family: ".$font.";"; } ?>
if ($font) {
$html2pdf->pdf->setDefaultFont('freeserif');
// instead of the above function use: $html2pdf->pdf->setDefaultFont($font);
}
okay... i've mistaken the instructions on the use of the function then!
like your example... i have the font-family now (only) on the PAGE tag, for testing now hardcoded: font-family: times;
The error is gone, though the PDF result is actually still in ARIAL
Am i missing something else?
i think i have found the solution...
understanding the theory that you have to add a style to a tag, i found that i had my </PAGE> tag closed before writing the entire content so that was basicly it!
@spipu: thanks for your help... it sure is a great script!