Jump to content

Solved: Header And Content Superimposed In Pdf

Recommended Posts

Solved by tuk66, the solution is to modify the top margin which is set in classes/pdf/PDFGenerator.php, function writepage().  Here the relevant line:


$this->setMargins(10, 40, 10);


The second argument (40) is the top margin for the main content.  By increasing this margin, the main content is rendered lower down on the page so it doesn't overlap with the header.


Original post follows:



Using PrestaShop


I've added a "job card" feature to my PrestaShop, for internal use by the company.  It's similar to an invoice but with different information.  It renders as a PDF, just like the invoice.  Override class is override/classes/pdf/HTMLTemplateJobCard.php (derived from classes/pdf/HTMLTemplateInvoice.php).


The header template is this:


<table style="width: 100%">
    <td style="width: 50%">
        {if $logo_path}
            <img src="{$logo_path}" style="width:{$width_logo}px; height:{$height_logo}px;" />
    <td style="width: 50%; text-align: left;">
        <table style="width: 100%">
                <td style="font-weight: bold; font-size: 14pt; color: #444; width: 100%;"><h1>Job Work Order</h1></td>
            <tr><td> </td></tr>
                <td style="font-weight: bold; font-size: 14pt; color: #444; width: 100%;">Reference: {$order_reference}</td>
            <tr><td style="width: 25%; text-align:left;">Order Date:</td><td style="width: 75%; text-align:left;">{$invoice_date}</td></tr>
            <tr><td style="width: 25%; text-align:left;">Due Date:</td><td style="width: 75%; text-align:left;">{$delivery_date}</td></tr>
            <tr><td style="width: 25%; text-align:left;">Send Bill To:</td><td style="width: 75%; text-align:left;">{$address_delivery}</td></tr>
            <tr><td style="width: 25%; text-align:left;">Ship To:</td><td style="width: 75%; text-align:left;">{$address_invoice}</td></tr>
            <tr><td style="width: 25%; text-align:left;">Phone:</td><td style="width: 75%; text-align:left;">{$phone}</td></tr>
            <tr><td style="width: 25%; text-align:left;">Email:</td><td style="width: 75%; text-align:left;">{$email}</td></tr>

The content template is this:


<table width="100%" id="body" border="0" cellpadding="0" cellspacing="0" style="margin:0;">
    <!-- Product -->
            <td colspan="2" align="center">Reference</td>
            <td colspan="1" align="center">Qty</td>
            <td colspan="1" align="center">Qty In Stock</td>
            <td colspan="6" align="center">Product</td>
            <td colspan="2" align="center">Unit Price</td>
        {foreach from=$details item=det}
            <td colspan="2">{$det.reference}</td>
            <td colspan="1">{$det.quantity}</td>
            <td colspan="1">{$det.quantity_in_stock}</td>
            <td colspan="6">{$det.product_name}</td>
            <td colspan="2" align="right">{$det.price}</td>
    <tr><td colspan=12> </td></tr>

There is no footer template (getFooter() returns empty string).


Both the header and the content render correctly.  Trouble is, they're superimposed: the top line of the content renders at the same place as "Ship To" in the header.


Any insights will be greatly appreciated!

Edited by JuanTomas (see edit history)

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More