Outputting FPDF to a new page

Is there a way with FPDF output() to make it go to a new web page. Currently it opens in the same page that calls it. Thanks

You can’t output from FPDF to a web page. It always creates a new PDF document, not a web page.

Yes. So my app runs in a browser as a web page. I have a link to create a pdf. The pdf takes the place of my page. What I would like to do is have the odd open in a new tab. Are you going to give me the same response? :blush:

Not odd. pdf

Hi,

As felgall says, FPDF sends the output to the browser just like any other page so I think you have two options:

  1. Make the PHP script open in a new tab, eg. <a href="pdf-generator.php" target="_blank">View PDF</a>
  2. Have FPDF save the PDF to the server rather than return it to the browser, then use javascript to make it download to the user’s computer.

Hope this helps,

Martin.

Just a thought: FPDF has the option of outputting the file inline to the browser or downloading it. If you want it to show inline I think the only option is to have the PHP file open in a new tab. If you’re not bothered then the easy option is to set the Output destination flag to ‘D’ and download the PDF.

http://www.fpdf.org/en/doc/output.htm

Thanks for the input. Using something like target=blank is the behavior I want. Let me fool with it that way. I appreciate the help.

that option takes away visitor choices. Without it your visitor can choose between the same tab, a different tab and a different window. With it they need to have their browser set to ignore the target in order to maintain their choices.

Interesting. I just tried a right click on the link to the pdf and sure enough it opened in another tab. So that works just fine. Not really sure why that didn’t dawn on me before but I have my suspicions. :smirk:

I do have a link that is a submit button on a form but that can be changed pretty easily to a link.

Thanks for the eye opener.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.