I am working with TCPDF's wrapper for wordpress (v. 6.2.11) and I made an extended class in PHP so I could use some own functions to load some data. At start I was trying just to load in PDF just some text in a box with this code:
`class pdfgenerator extends TCPDF
{
var $id_value;
// Page header
public function Header() {
$image_file = '../images/myimage.png';
$this->Image($image_file, 10, 10, 90, 0, 'PNG', '', '', true, 150, '', false, false, 0, false, false, true ); // <<-- this is OK, loaded successful
$this->SetFont('helvetica', '', 10);
$this->SetFontSize(10);
$text_data = "Lorem ipsum dolor sit amet, consectetur adipiscing elit,<br />sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.<br />Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.<br />";
$this->writeHTMLCell(110, 40, 40, 10, $text_data, 1, 0, false, true, "L"); // <<-- this returns a long sequence of numbers instead of the text htmled in $text_data variable, why???
$this->SetFontSize(12);
$border_header = array('LTRB' => array('width' => 0.3, 'cap' => 'round', 'dash' => 0, 'color' => array(0, 0, 0)));
$this->setCellPadding(5);
$this->RoundedRect(10, 42, 90, 50, 3, '1111', '', $border_header); // <<-- boxes draw perfect where as expected
$this->setCellPadding(5);
$this->RoundedRect(110, 42, 90, 50, 3, '1111', '', $border_header); // <<-- boxes draw perfect where as expected
$this->SetTopMargin($this->GetY()+10);
}
// Page footer
public function Footer() {
}
// Initialization PDF document
public function ConfigurePage($value) {
$id_value = $value;
$this->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
$this->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$this->SetAutoPageBreak(true, PDF_MARGIN_BOTTOM);
$this->setImageScale(PDF_IMAGE_SCALE_RATIO);
$this->setFontSubsetting(true);
$this->SetFont('dejavusans', '', 12, '', true);
$this->AddPage();
}
}`
and here in writeHTMLCell I should read that lorem ipsum text....indeed I see a long sequence of numbers like 65343567864334567..... ; I call this class from main code with:
I am working with TCPDF's wrapper for wordpress (v. 6.2.11) and I made an extended class in PHP so I could use some own functions to load some data. At start I was trying just to load in PDF just some text in a box with this code:
`class pdfgenerator extends TCPDF { var $id_value;
}`
and here in
writeHTMLCell
I should read thatlorem ipsum
text....indeed I see a long sequence of numbers like65343567864334567.....
; I call this class from main code with:$pdf = new pdfgenerator(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $pdf->ConfigurePage('209'); $pdf->Output(__DIR__ . '/mypdf_209.pdf', 'F');
As you know maybe to obtain right result with
writeHTMLCell
depends from some other settings that I could have missed or implemented wrong?...Thanks in advance! Cheers! :-)