Hello, please I need help, I make a Report with format like this (IMG1 Attachment):

But when I download the quote on pdf the format change like this (IMG2 Attachment):
The spaces between lines is too large, fonts and styles are changed, font size is not the same on template.
Please I need help in order to make pdf’s like my template.
Regards,
Raul.
adr
2
Hi raulpuig ,
i you want to customize the pdf according to your needs you can make use of mpdf class
you can find it under : modules/AOS_PDF_Templates/PDF_Lib/mpdf.php
here the example i have customized table in using mpdf class
public function getpdf($cond)
{
require_once('modules/AOS_PDF_Templates/PDF_Lib/mpdf.php');
$d_image = explode('?',SugarThemeRegistry::current()->getImageURL('company_logo.png'));
$head = '<table style="width: 100%; font-family: Arial; text-align: center;" border="0" cellpadding="2" cellspacing="2">
<tbody style="text-align: left;">
<tr style="text-align: left;">
<td style="text-align: left;">
<p><img src="'.$d_image[0].'" style="float: left;"/> </p>
</td>
<tr style="text-align: left;">
<td style="text-align: left;"></td>
</tr>
<tr style="text-align: left;">
<td style="text-align: left;">
</td>
<tr style="text-align: left;">
<td style="text-align: left;"></td>
</tr>
<tr style="text-align: left;">
<td style="text-align: left;">
<b>'.strtoupper($this->bean->name).'</b>
</td>
</tr>
</tbody>
</table><br />';
global $db;
$sql = "SELECT o_order.id , o_order.order_number , o_order.billing_address_country , o_order.total_cost , o_order.tracking_id , o_order.billing_address_city , o_order.order_status , o_order.phone_office , jt0.user_name assigned_user_name , jt0.created_by assigned_user_name_owner , 'Users' assigned_user_name_mod, o_order.date_entered , o_order.assigned_user_id FROM o_order LEFT JOIN users jt0 ON o_order.assigned_user_id=jt0.id AND jt0.deleted=0 AND jt0.deleted=0 where ($cond) AND o_order.deleted=0 ORDER BY o_order.date_entered DESC";
$res = $db->query($sql);
$body_head = '<table cellpadding="0" cellspacing="0" width="100%" border="0" ><tbody><tr>
<td scope="col" width="12%" bgcolor="#35478F" color="#FFFFFF" > Order number </td>
<td scope="col" width="12%" bgcolor="#35478F" color="#FFFFFF" > Billing Country </td>
<td scope="col" width="12%" bgcolor="#35478F" color="#FFFFFF" > Order status </td>
<td scope="col" width="12%" bgcolor="#35478F" color="#FFFFFF" > Phone </td>
<td scope="col" width="19%" bgcolor="#35478F" color="#FFFFFF" > Tracking Id </td>
<td scope="col" width="2%" bgcolor="#35478F" color="#FFFFFF" > Total Cost </td>
<td scope="col" width="2%" bgcolor="#35478F" color="#FFFFFF" > Date Entered </td></tr>';
$body_foot = '</tbody></table>';
$out_put='';
while($f_res = $db->fetchByAssoc($res)){
$out_put .= '<tr hight="20"><td scope="row" align="left" valign="top">'.$f_res['order_number'].'</td>
<td scope="row" align="left" valign="top">'.$f_res['billing_address_country'].'</td>
<td scope="row" align="left" valign="top">'.$f_res['order_status'].'</td>
<td scope="row" align="left" valign="top">'.$f_res['phone_office'].'</td>
<td scope="row" align="left" valign="top">'.$f_res['tracking_id'].'</td>
<td scope="row" align="left" valign="top">'.$f_res['total_cost'].'</td>
<td scope="row" align="left" valign="top">'.$f_res['date_entered'].'</td>
</tr>';
}
$table = $body_head.$out_put.$body_foot;
$stylesheet = file_get_contents('themes/Suite7/css/style.css');
$pdf=new mPDF('en','A4','','DejaVuSansCondensed');
$pdf->setAutoFont();
$pdf->WriteHTML($stylesheet,1);
$pdf->WriteHTML($head,2);
$pdf->WriteHTML('<p><h1>Order Report</h1></p>',2);
$pdf->WriteHTML('<p><h1> </h1></p>',2);
$pdf->WriteHTML($table,3);
$pdf->Output('OrderReport.pdf', "D");
}
Thanks for your time and support !
1 Like
Hi adr, if i want to format my pdf object adding the table header if a page brek occurs, what do you think i should do?