CalcBuilder Forum

PDF not formatted properly (does not open)

Usuario moon_1868 2015-01-28 17:49:07

Hi,

My form prints out a stream of html data saved in a php variable ($results).
When I recall this variable inside the Before/After calculation for pdf print this is what I obtain by clicking on the pdf icon:

Firefox: an index.php page is opened, showing the correct values. But if I download the file (mpdf.pdf) then I can't open it with Acrobat Reader because "the file is not supported". In fact, by inspecting the file with a text editor I can see my html code and after few lines the %PDF-1.4% header that should be at the very beginning of the file, according to what is stated on the Adobe site.

http://helpx.adobe.com/acrobat/kb/pdf-error-1015-11001-update.html

Chrome: no file is opened.

IE: no file is opened.

You can see the demo form here: www.studioinvento.it/testpantano

Could you please let me know how I could solve this issue?

Thanks for the assistance

Elena

Moonsoft support 2015-01-28 19:07:22

Hi,
when you say the form is printing a stream, maybe you're using echo instructions or var_dumps at your php code? that kind of instructions can break the pdf format, as they are executed before sending the contents to pdf library. The right way to print the html you have built is to place ##results## at your output section.

If this is not your case and you can't solve the issue, please place a ticket at the helpdesk sharing an access to your site and we'll take a look.


thanks,

Usuario moon_1868 2015-01-29 09:35:47

Hi!

That's been a very easy fix!!! Thank you!
I deleted the echo $results, and replaced it with a ##results## inside the exit layout and now everything works perfectly. Sorry, I thought it was the same.

Also, do you eventually know if it is possible to customize the pdf filename? I could hard-code a little bit the library if necessary, but I don't know where to look for.

Thanks again for the nice component and the very efficient assistance!

Elena

Moonsoft support 2015-01-29 12:24:53

hi,
great it worked. When no name is set, the library saves the file with a default name. You can force the file name editing the source where the output is printed:

JOOMLA\components\com_calcbuilder\views\calcbuilder\tmpl\pdf.php

replace the last line
$mpdf->Output ();

for this one
$mpdf->Output ('yourfilename.pdf','I');



This should do the work.


regards

Usuario moon_1868 2015-01-29 15:46:45

Thanks, I created an override inside my template and it works perfectly.

Elena

...
Support/development

Perfect for small code changes or to correct any bug at your site

Buy now!
...
List Manager

Build different lists for your site

Buy now!