0

guys i use TCPDF library for my php server and i want to create a label with width:57mm and height:32mm

$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf->SetPrintHeader(false);
$pdf->SetPrintFooter(false);
$pdf->AddPage('L', array(57,32));
$pdf->SetFont('dejavusans');
$html ="
    <table class='domi'>
    <tbody >";
    for($i=0; $i<$rows; $i++){
        $style=' style="font-size:'.$fontsize[0][$i].'px"';
        if($bold[0][$i]===0){
            $html2a[$i] = "<tr><td".$style.">".$content_line[$i]."</td></tr>";
        } else {
            $html2a[$i] = "<tr><td".$style."><b>".$content_line[$i]."</b></td></tr>";
        }
        $html2b .= $html2a[$i];//$pdf->GetStringWidth($html2a[$i])." ";
    }
    $html3 = "</tbody>
    </table>";
$pdf->writeHTMLCell($w=55, $h=2, $x='1', $y='1', $html.$html2b.$html3, $border=1, $ln=1, $fill=0, $reseth=false, $align='C', $autopadding=true);
$pdf->Output($_SERVER['DOCUMENT_ROOT'] . 'Site/labels/label'.$id.'.pdf', 'FI');

1st of all it prints the contents fine from the database in A4 size etc but all i want is to create and save the pdf document in the label size width:57mm and height:32mm!!! https://i.stack.imgur.com/kQ8Be.png

as you see, I've marked with 1-5 numbers the actual data and the rest are marked with questionmarks!! I dont understand why of course.

2nd when i change the line $pdf->AddPage('L', array(57,32)); to $pdf->AddPage('L', array(57,57)); the label is created but i have an empty space in the bottom-right corner + it doesnt have the 32x57 size!!! https://i.stack.imgur.com/XgEWU.png

thanks in advance!!!

  • final my end result should be: a new pdf with sizes 32x57mm would be created even if the whole content doesn fit inside and its role will be as a preview in my main page!! i prefer this for example that has the 4/5 lines and also has the dimentions 32x57mm!! https://i.stack.imgur.com/GA3Jy.png – Ηλιας Τσορομωκος Jul 27 '17 at 14:10

1 Answers1

1

it seems that i had missconfigured my TCPDF library... the simple solution that i came up was to put this line

$pdf->SetAutoPageBreak(true, 0);

after this

$pdf->SetFont('dejavusans');

and the result was perfect!!!

https://i.stack.imgur.com/hGwyR.png <-perfectly configured label

https://i.stack.imgur.com/khs9v.png <-wrongly configured label but in my case it perfect for the job!!! all i want is to preview the result before saving (i mean saving the wrong configuration and then update the base until the configuration is good!!)