Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Creating download pdf file

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Tips and Tricks
View previous topic :: View next topic  
Author Message
freebeart
Smarty n00b


Joined: 11 Oct 2012
Posts: 3

PostPosted: Thu Oct 11, 2012 8:59 pm    Post subject: Creating download pdf file Reply with quote

Hello,
Please help,

I want to be able open or download file of my Smarty output.
I want to be able to have that download/open directly to the user's computer as a .pdf file.

Any ideas?

This function did not work for me. Bad file is opened.
public function DisplayTac()
{
header('Content-disposition: attachment; filename="documents/tac.pdf"');
header('Content-type: "application/pdf"; charset="utf8"');
}

my paths are:

/smarty/templates/

and

/documents/tac.pdf

Thank you
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Fri Oct 12, 2012 3:46 pm    Post subject: Reply with quote

Don't you need to send the file as well as headers?

Code:
header('Content-disposition: attachment; filename="documents/tac.pdf"');
header('Content-type: "application/pdf"; charset="utf8"');
readfile(documents/tac.pdf);
Back to top
View user's profile Send private message Visit poster's website
freebeart
Smarty n00b


Joined: 11 Oct 2012
Posts: 3

PostPosted: Fri Oct 12, 2012 4:28 pm    Post subject: Reply with quote

mohrt wrote:
Don't you need to send the file as well as headers?

Code:
header('Content-disposition: attachment; filename="documents/tac.pdf"');
header('Content-type: "application/pdf"; charset="utf8"');
readfile(documents/tac.pdf);


Hi, thanks for replay.

But this did not work.
File is downloaded but, bad size. And Foxit reader pops up.
"Format error. not PDF od corrupted".

Any other ideas?

I can not find the solution.

Thank you very much
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Fri Oct 12, 2012 4:36 pm    Post subject: Reply with quote

google php download files, see appropriate headers. this isn't something smarty needs to address too, btw.
Back to top
View user's profile Send private message Visit poster's website
freebeart
Smarty n00b


Joined: 11 Oct 2012
Posts: 3

PostPosted: Fri Oct 12, 2012 5:07 pm    Post subject: Reply with quote

mohrt wrote:
google php download files, see appropriate headers. this isn't something smarty needs to address too, btw.


Ok. thank you
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Tips and Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP