PDF name

juergen_mueller

DaDaBIK Guru
Hi Eugenio

I am writing some PDF templates for certain outputs. So far it works fine unless I want to change the name of the PDF file to anything I would like to set (e.g. variable from a field).

Using $pdf->Output('anyname.pdf', 'I'); results in a blank page apart from header and footer

What I get without $pdf->Output() is a PDF name like 'OFxSN7-TABLENAME.pdf'

Is there any solution?

Best

Juergen
 

eugenio

Administrator
Staff member
Hello Juergen,
let me ask a question first: without setting the name you should get something like TABLENAME.pdf not OFxSN7-TABLENAME.pdf, do you know where the OFxSN7 part comes from? Are you sure there isn't any additional code that interferers?

Best,
 

juergen_mueller

DaDaBIK Guru
Hi Eugenio

I have no idea where this random code comes from. Additionally, it changes every time I generate a new PDF from another record. I thought it was something you implemented ....

Best

Juergen
 

eugenio

Administrator
Staff member
Hi,
no the code just does something like

$pdf->Output($table_name.'.pdf', 'I');

can you try if with a new installation without templates you get the same behaviour?

Best,
 

juergen_mueller

DaDaBIK Guru
I guess, the whole thing is browser related. Safari creates this random code, adding it to the TABLENAME.pdf. Chrome does not do that.

Juergen
 

eugenio

Administrator
Staff member
That's strange, I've tried with Safari as well but I don't get the random code. It might depends on the version, though.

Coming back to your original question, at the moment there isn't any proper way to change the name of the pdf on the fly, because anyway this code is always executed:

$pdf->Output($table_name.'.pdf', 'I');

exit();

so I would say your additional $pdf->Output is interfering with the rest of the code.

I will think about a method to change the filename in a template; if it's easy to implement, I will add it to the next release.

Best,
 
Top