Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Division by zero mpdf/mpdf.php Line: 15009 #296

Closed
wafiamustafa opened this issue Dec 28, 2016 · 6 comments
Closed

Division by zero mpdf/mpdf.php Line: 15009 #296

wafiamustafa opened this issue Dec 28, 2016 · 6 comments

Comments

@wafiamustafa
Copy link

I have this problem/would like to have this functionality

These are mPDF and PHP versions I am using

This is a PHP code snippet I use

<?php

$mpdf = new mPDF('', 'A4', '', '', 20, 20, 25, 25, 18, 8);
$mpdf->defaultfooterline = 0;
$mpdf->debug = true;
$footer = '<table width="100%">
    <tr>
    <td width="70%" style="color: #000000; padding-bottom:0px; margin-bottom:0px; vertical-align: bottom; font-family: Arial; font-size: 10px; text-align:left;border-bottom:1px dotted #000">Tenant Signed: '.$_POST['tenant_signed'].'</td><td style="color: #000000 ; text-align: left; vertical-align: bottom;  padding-bottom:0px; margin-bottom:0px;  font-family: Arial; font-size: 10px; border-bottom:1px dotted #000"> Dated: '.$agreement_datef.'</td>
    </tr>
    </table>';
$mpdf->SetFooter($footer);
$mpdf->DefHTMLFooterByName('Chapter2Footer', '<div style="text-align: right; vertical-align:top; font-weight: bold; font-size: 7pt; font-style: italic;">Chapter 2 Footer</div>');
$mpdf->SetDisplayMode('fullpage');
$mpdf->WriteHTML($html);
$fiepath = 'pdffiles/tenancy-'.$last_id. date('YmdHis') . '.pdf';
$fiepath1 = 'pdffiles/tenancy-'.$last_id. date('YmdHis') . '.docx';
$mpdf->Output('../'.$fiepath, 'F');

This is a HTML code snippet I use


@finwe
Copy link
Member

finwe commented Mar 9, 2017

Closing, unable to reporoduce in 7.0-beta

@finwe finwe closed this as completed Mar 9, 2017
@LewisWBPD
Copy link

For anyone else having this problem, it was caused for us because we had SVGs that had been saved using Adobe Illustrator's "Preserve editing abilities" setting enabled. This caused the SVG to contain invalid XML (&ns_ai; attributes) which MPDF failed to parse and just set the width/height of the image as 0. Here is some more info on cleaning the SVG so it works.

Looking at the latest code I suspect the issue is still present in 7.0. It's not so-much an issue with MPDF because of the broken XML, but maybe we could introduce a check for parsing errors after parsing the SVG's XML.

@zackphilipps
Copy link

I'm getting this error and I'm not even using SVGs...

@finwe
Copy link
Member

finwe commented Feb 27, 2018

@zackphilipps You are not helpful in fixing this. What about providing a code sample?

@zackphilipps
Copy link

@finwe Sorry, this is just really frustrating. In my case, this has nothing to do with the code; it's the environment. The exact same template works on live, just not on my local. So it's a problem with missing assets, file permissions, SSL cert config, or some combination of the three. I'm still investigating and will report back once I know more.

However, regarding images specifically, it seems like 9 times out of 10 the error message doesn't reflect the actual error that's occurring. I'm using 6.1; hopefully this has been improved in more recent versions.

@zackphilipps
Copy link

@finwe So, I got this error after adding this line to my php.ini to fix the invalid cert problem:

curl.cainfo = "/etc/apache2/ssl/apache.crt"

But, let's say the image in question is called image1.jpg. This file actually didn't exist in the filesystem, so I should've gotten the standard "Fatal error: Uncaught MpdfException: IMAGE Error (image1.jpg): Could not find image file." Right?

Prior to adding that line, I DID get "Fatal error: Uncaught MpdfException: IMAGE Error (image2.jpg): Could not find image file," only here's the rub: image2.jpg actually DID exist in the filesystem, and this was actually an invalid cert error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants