PDF not generated correctly

i really really dont get it, the web version of the invoic looks ok, just this one looks really odd.

…This is because the web version uses a different template.

Looks like the template has lost its CSS styling. Maybe a corrupt file during installation? You could also try clearing your browser cache (that would be my first bet).

Like @Maxime_GRIMLER said if you’re using a custom template to generate the PDFs you may need to update its styling.

However if you’re using a default template you may try downloading the IP files again and replacing the PDF template files only - just in case it is corrupt or something.

i redownloaded IP, reuploaded all files, still no css styling.

If you want i can give you a login for you to try? i’m out of ideas.

No no no need of your credentials.

Can you please paste your PHP file template in https://pastebin.com/
Maybe someone can check and help you by seeing if there is missing styles or test on his own.

https://pastebin.com/P4PiUkb3

You mean it’s the default one in used ? Because I see no changes, I test it and no problem for me.

Can you provide me your logo ? Maybe that’s the reason otherwise I don’t see any problem for me on your template (and I test by downloading invoice and send it by mail)

I’m actually in hospital at the minute (that’s what they call dedication :wink:) so have no access to my lab environment at the minute.

So I’ll leave you with @Maxime_GRIMLER

But just to confirm you have tried clearing your browser cache? As obviously it’s working when he tests it?

I HAVE FOUND IT!

Problem was in my ipconfig.php,

i still had the url to the temp domain in IP_URL=
but i was allready accessing the site from the correct URL i didnt find the problem immediately because everything was working correctly.

1 Like

Ergz ok ok then hard to find from our point of view :smiley:

Glad to hear it works now :slight_smile: Have some fun with InvoicePlane now :stuck_out_tongue:

1 Like

But its a good comment to keep in mind if people have the same problem :slight_smile:

continuing from:

PDF not generated correctly

Hi I have developed the same symptoms.

Server
Debian 9
Apache2
php 5.6.30…

Changes to system:
Normal updates to OS last at 2017-12, but problem started 2017-10-20 (y-m-d)
while using IP 1.5.2 now upgraded to 1.5.5 with the same problem.

Problem statement:
1.) PDFs were being created correctly for a few months.
2.) With no deliberate change to IP.
3.) As per the preceding post examples
All pdf’s became left justified.
Alternate lines are no longer highlighted differently.
Bold characters are not bold.

Observation:

  1. Content ok,
  2. Formatting lost.

Corrective actions:

as per Customising Templates

in
application/helpers/pdf_helper.php
Place

print_r($html);exit; at line 98 for invoice templates.

(
PS
my one was line 103, before

$CI->load->helper('mpdf');

)

If I tried to download a pdf an html version of the pdf was displayed,
other than the logo not showing (assume hyper link not created for pdf)
the layout was correct in html view.

I also deleted the logo with the same results when the pdf was generated.

I reset user permissions (as test)
User: www-data
Group: www-data

u+rwx
g+rx
o+rx

Any suggestions.

Regards
Eric

Snapshot of PDF

Snapshot of html version (pdf download selection, but with debug option)

If it counts!

I am hosting 3 sites (4 with the test) on the same server. All are showing the same symptoms.
my own and two instructor friends.

The sites are kept separate by virtue of using 4 separate directory with 4 DB’s under mysql and
4 conf files under /etc/apache2/conf-available/…

Regards
Eric

Did a clean installation in a new directory with a clean DB.
Unfortunately with the same results.

During the installation IP reported all requirements where ok.

Will try installing in a clean machine (Raspberry pi)

Did you read that: https://wiki.invoiceplane.com/en/1.5/getting-started/requirements ?

Bugger

PHP > 7.0 (PHP 5.6 may not be supported any longer)

Will install 7 and see, what happens.
Thanks.

UN-installed php 5.6, Installed php 7.0.26-1

Ran …/setup
unfortunately with the same result.

It appears mpdf can not read the *.css inspite of it being
shown when I use
print_r($html);exit;

I did note that the logo is referenced via the local filesystem whereas the css is via the web

<img src="/var/www/invTest/uploads/WAA_PDF_TestLogo1.jpg" id="invoice-logo">

whereas the css is

<link rel="stylesheet" href="https://...ASERVER.../invTest/assets/invoiceplane/css/templates.css">  
<link rel="stylesheet" href="https://...ASERVER.../invTest/assets/core/css/custom-pdf.css">

I tried the following from the server console

wget https://...ASERVER.../invTest/assets/core/css/custom-pdf.css

It failed!
Confirming that the style sheet is not accessible via https FROM the SERVE ITSELF but is available to external web clients, how can I change the reference to the css to a file system path like the logo.

Regards
Eric

PS the server has always served two domains internal/external.

An internal self signed htmls server named ‘zeus.xyz’, and a public name

I assume that some update has changed the ‘context’ under which the mpdf call is being made. so while the web client is being served from the external name the call to fetch the css is being done from the ‘inside network’ using the outside name, resulting in a name resolution error.

Regards
Eric

I think this is rather a configuration problem with the web server as mPDF is working for like thousands of installations without any problems.
You could try to completely remove the domain from the CSS link:

<link rel="stylesheet" href="/invTest/assets/invoiceplane/css/templates.css">

Thanks for the reply, yes you are correct this should not be required and up to a month ago WAS NOT required.

My solution (proof of concept)

I created a new template from the original
and changed the ‘head’ section as follows.

/application/views/invoice_templates/pdf/ELM-Invoice.php

<head>
    <meta charset="utf-8">
    <title><?php _trans('invoice'); ?></title>
   <style>
   <?php
         include("/var/www/invTest/assets/invoiceplane/css/templates.css");
         echo "";
         include("/var/www/invTest/assets/core/css/custom-pdf.css");
   ?>
   </style>
</head>

Yet to be done:
change paths so that it works as per the
invoice_logo_pdf() method ie paths must not be hard coded, but use IP variables.
can you give me a hint to get.

/var/www/invTest/ (IP variable / PHP)

PS php manual recommends using readfile() as apposed to include() due to security conserns, so I will experiment with that.

PPS I would switch to this method not because it is better, but because it works the same way as invoice_logo_pdf() which means fewer methods are being used in one program therefore less chance of that one out of the blue instances like mine.

Thanks

Eric

Final mod looks like this, and has been tested to work in debug and normal modes.
(producing html or pdf views)

<head>
    <meta charset="utf-8">
    <title><?php _trans('invoice'); ?></title>
   <style>
   <?php
         include(getcwd()."/assets/".get_setting('system_theme', 'invoiceplane')."/css/templates.css");
         echo "";
         include(getcwd()."/assets/core/css/custom-pdf.css");
   ?>
   </style>
</head>

Now that the stress is off, I will check the network to see what introduced this error.

Regards
Eric