Dompdf: View pdf in browser but save with wrong file name

Created on 6 Dec 2012  ·  3Comments  ·  Source: dompdf/dompdf

_Original author: [email protected] (September 10, 2012 11:00:46)_

In ffx when I disable the adobe plugin, a download box appears with the correct file name. In IE8 I cant disable the adobe plugin for some reason, so it always opens in browser. This works fine, however, in both ffx and IE8, when I press the save button from the adobe toolbar I get the wrong file name.

_Original issue: http://code.google.com/p/dompdf/issues/detail?id=531_

Priority-Medium bug imported

Most helpful comment

_From eclecticgeek on September 10, 2012 17:58:37_
If your goal is to save the file you should use:

$dompdf->stream('filename.pdf',array('Attachment'=>1));

Attachment should be 1 by default. I'm not sure how the browsers deal with a specified filename if the PDF is displayed in the browser. It may ignore the name and use the name of the PHP file. I'll have to do more research on this.

Also, which version of dompdf?

All 3 comments

_From eclecticgeek on September 10, 2012 17:58:37_
If your goal is to save the file you should use:

$dompdf->stream('filename.pdf',array('Attachment'=>1));

Attachment should be 1 by default. I'm not sure how the browsers deal with a specified filename if the PDF is displayed in the browser. It may ignore the name and use the name of the PHP file. I'll have to do more research on this.

Also, which version of dompdf?

The easiest way to control pdf file name is through "filename" attribute in Content-Disposition header. But this technique forces a pdf download instead of opening it in the browser (through Acrobat).
In the second case (open pdf in browser --> Acrobat), there is not a way to control the file name. Infact if you press "Save", Acrobat shows you a filename built using the page name and ".pdf".for examples, if you try to save the pdf created by CreatePdf.aspx, Acrobat choose "createpdf.pdf" as filename. I have found no way to change it (Content-Disposition + inline + filename does not work).
https://docs.google.com/document/d/1aIW7sRMGTZc8Whar2t1e6WAMF9-ifdTO6WSw8-EClFY/preview

_From eclecticgeek on September 10, 2012 17:58:37_
If your goal is to save the file you should use:

$dompdf->stream('filename.pdf',array('Attachment'=>1));

Attachment should be 1 by default. I'm not sure how the browsers deal with a specified filename if the PDF is displayed in the browser. It may ignore the name and use the name of the PHP file. I'll have to do more research on this.

Also, which version of dompdf?

This works for me. Thanks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jewei picture jewei  ·  4Comments

tylerjnorin picture tylerjnorin  ·  3Comments

AnarchyChampion picture AnarchyChampion  ·  3Comments

halfer picture halfer  ·  4Comments

whizsid picture whizsid  ·  3Comments