mythri Posted July 5 Share Posted July 5 I am trying to print multiple barcode labels at once using mpdf. There are 2 problems i am facing. 1st one : 1 blank page is getting adding at the beginning. 2nd : i want to display data like this A 1 8 instead ,it displays A 18 In TCPDF , i did not get any of these problems, but i have to use some indian language which properly displays only in Mpdf. Here is my Mpdf Code include('../includes/session.php'); require_once __DIR__ . '/bootstrap.php'; $defaultConfig = (new Mpdf\Config\ConfigVariables())->getDefaults(); $fontDirs = $defaultConfig['fontDir']; $defaultFontConfig = (new Mpdf\Config\FontVariables())->getDefaults(); $fontData = $defaultFontConfig['fontdata']; $mpdf = new \Mpdf\Mpdf([ 'fontDir' => array_merge($fontDirs, [__DIR__]), 'fontdata' => $fontData + [ 'freeserif' => [ 'R' => 'assets/FreeSerif.ttf', ], 'inkfree' => [ 'R' => 'assets/Inkfree.ttf', ], ], 'margin_left' => 1, 'margin_right' => 1, 'margin_top' => 1, 'margin_bottom' => 1, 'margin_header' => 1, 'margin_footer' => 1, 'showBarcodeNumbers' => TRUE ]); $sec1 = $con->prepare("SELECT bc.bc_id, bc.book_id, bc.depts, bc.dept_ids, bc.bcode_unq, bk.bk_name, bk.price, bk.currency, l.lang_name, ed.ed_dept, ed.short_code, eds.sub_dept, eds.short_code AS edssortcode FROM books_copy bc INNER JOIN books bk ON bc.book_id=bk.book_id INNER JOIN languages l ON bk.lang=l.lang_id INNER JOIN edu_dept ed ON bk.edu_dept=ed.ed_id INNER JOIN edu_subdept eds ON bk.edu_subdept=eds.eds_id WHERE bc.bc_id BETWEEN 53 AND 55"); $sec1->execute(); foreach($sec1 as $r1) { $agam = $r1['bc_id']; $bname = $r1['bk_name']; $price = $r1['price']; $lang = $r1['lang_name']; $edept = $r1['ed_dept']; $esubdept = $r1['sub_dept']; $escode = $r1['short_code']; $esscode = $r1['edssortcode']; $bcode = $r1['bcode_unq']; $dept_code = substr($r1['depts'],0,3); $deptids = $r1['dept_ids']; $dept = $escode.' '.$esscode; $deptsubdept = $edept.' '.$esubdept; $bvert = substr($esscode,0,3); $content = ''; $content .= '<html> <head> <style> body { font-family: freeserif; font-size: 12px; } .line { border-right:1px solid #000; } .vertical { border-collapse: collapse; text-align: right; writing-mode: vertical-lr; text-orientation: upright; } </style> </head> <body>'; $content .= '<table border="0"> <tr> <td> <table border="0" cellpadding="2" align="left" class="line"> <tr><td colspan="3" style="font-size:12px;"><strong>'.$_SESSION['library'].'</strong></td></tr> <tr><td>Agam : '.$agam.' </td><td colspan="2" align="right">रु. '.$price.'</td></tr> <tr><td colspan="3">Vibhag : '.$deptsubdept.'</td></tr> <tr><td colspan="3">Book : '.$bname.'</td></tr> </table> </td> <td valign="top" align="right"> <table><tr><td style="font-size:12px;" class="vertical">'.$bvert.' '.$deptids.' </td> </tr></table> </td> </tr> </table> <div style="position:fixed; top: 33mm;"> <barcode code="'.$agam.'" type="C39" class="barcode" /> <div style="text-align:center;">'.$agam.'</div> </div>'; $mpdf->WriteHTML('<pagebreak sheet-size="75mm 50mm" />'); $mpdf->WriteHTML($content); } $mpdf->Output(); i am attaching the pdf file generated thru mpdf as well as tcpdf. I can post db tables structure if it helps. Quote Link to comment https://forums.phpfreaks.com/topic/322165-display-problem-in-mpdf-php-with-database/ Share on other sites More sharing options...
mac_gyver Posted July 5 Share Posted July 5 as far as i can tell, mpdf doesn't support writing-mode or text-orientation - https://mpdf.github.io/css-stylesheets/supported-css.html the only reason you have a case where the letters are vertical is because there's only horizontal space in the layout for a single letter at that point. i recommend that you just add a <br> tag between each letter using code. 1 Quote Link to comment https://forums.phpfreaks.com/topic/322165-display-problem-in-mpdf-php-with-database/#findComment-1629363 Share on other sites More sharing options...
mythri Posted July 6 Author Share Posted July 6 @mac_gyver : Thank you for this solution. But Why a blank page is getting added in the beginning. Quote Link to comment https://forums.phpfreaks.com/topic/322165-display-problem-in-mpdf-php-with-database/#findComment-1629374 Share on other sites More sharing options...
Solution mac_gyver Posted July 6 Solution Share Posted July 6 here's a note about AddPage(), which does the same as the <pagebreak> tag - Quote Note: Unlike FPDF AddPage() does not need to be called at the beginning of the document if you are writing HTML code to the document. WriteHTML() will automatically add the first page to a new document. apparently WriteHtml() adds the first page at the beginning of a new document, so the specific <pagebreak> adds a second one. 1 Quote Link to comment https://forums.phpfreaks.com/topic/322165-display-problem-in-mpdf-php-with-database/#findComment-1629376 Share on other sites More sharing options...
mythri Posted July 6 Author Share Posted July 6 Thank you. I have corrected my code and got the result. Quote Link to comment https://forums.phpfreaks.com/topic/322165-display-problem-in-mpdf-php-with-database/#findComment-1629378 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.