1

Hi,

I am wondering if it is possible to do a check for true or false on Output?

if ($html2pdf->Output('filename.pdf', 'F')) {
// ... do something
} else {
// ... don't do something
}

I'm now using multiple output's, but i figure that once a pdf is created is better use the result (file) instead of calling Output again.
1: Create and save as a file: $html2pdf->Output('inkoopopdrachten/'.$INKOOPNR.'.pdf', 'F');2: Next, if i have an emailaddress, i'm calling Output again with $content_PDF = $html2pdf->Output($INKOOPNR.'.pdf', true); and then mail the pdf as attachment by PJ mail.
3: Display the pdf by calling $html2pdf->Output('filename.pdf', false);

What i intend to do is to check if the first Output is "true", then use the created file by: $content_PDF = filename.pdf;
Then if i have an emailaddress, send the mail
Call some javascript alerts to tell what has been done
Then open the file in a window

Do you have any suggestions?

Thanks!
Marco

2

just call the output one time, by asking directly the content of the PDF.

look at the wiki wink
Ancien pseudo : lolo

3

Hi Spipu,

I'm back on this issue... just to be sure if i understand correctly:

When i create a PDF and save the file
$html2pdf->Output($file_location.$file_name, 'F');

Then, next (under condition that there is an emailaddress) when i want to mail the PDF as attachment (using PJmail):

Previously i've tried to use the actual file as binary attachment, that does work although the received mailattachment isn't encrypted correctly i guess so this next line isn't working:
$content_PDF = $file_path;
I should use the following instead to get the content of the PDF just created and saved:
$content_PDF = $html2pdf->Output('', true);

It just seems kinda strange to call $html2pdf while there already is a saved file to use, once again... i'm no expert confus so maybe you could give me a hint here?
Thanks!

Marco

4

why calling OUTPUT twice ? just use the saved file on the disk
Ancien pseudo : lolo

5

Exactly my point!

So i have tried to use the declared filepath

$dir = "folder/";
$hello = getcwd();
$file_dir = ($hello . "/" . $dir);
$file_name = ($DOCUMENTNAME . ".pdf");
$file_path = ($file_dir.$file_name);

Then created and saved a PDF

$html2pdf->Output($dir.$file_name, 'F');

and then use the file as attachment for email:

$content_PDF = $file_path;
$mail->addbinattachement($file_name, $content_PDF);

However, the received email contains now the actual PDF file, but its unreadable since it's probably not encrypted correctly!? (i have no idea what the actual cause is)
The original (saved) file on the server is correct though

So i have tried to call the output again and this works fine...

Now i guess that the actual problem is in the addbinattachement!?

6

yes i think.

try wirh $pdfContent = file_get_contents($dir.$file_name);
Ancien pseudo : lolo

7

yup, that did the trick! Thanks man! top