[PHP] Re: Die Page, Die! (Was: Preview button to show PDF without submitting post data?)

2009-11-08 Thread Dave M G
Ashley,

Thank you for responding.

> I think you do, or where else would you show the PDF? Unless you force
> the PDF to download when the user clicks the preview button, you are
> left with the default option of the users browser, which will most
> usually be to display the PDF in the browser window.

No, that's not what's happening. I'm not showing the PDF in a browser
window. It's being given to the user with the option to download or view
in a separate application.

So I am fine with the download option. That's what I'm doing now, I
suppose. So since the user is downloading the PDF, they don't need an
in-browser window to view it.

Once the PDF is downloaded/viewed, I want the new window to die by any
means necessary.

Surely there's a way.

-- 
Dave M G

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Die Page, Die! (Was: Preview button to show PDF without submitting post data?)

2009-11-08 Thread Ashley Sheridan
On Sun, 2009-11-08 at 21:38 +0900, Dave M G wrote:

> PHP List,
> 
> Okay, so I've got a nice situation where a form has a preview button as
> well as a submit button. When the user presses "Submit", the page
> reloads, and it emails a PDF.
> 
> If the user presses "Preview", it launches a new page in a new window,
> and also outputs a PDF directly to the user so they can review it.
> 
> All good, but I don't need that second window open once the PDF has been
> shown to the user.
> 
> For some reason I can't kill that second window. I've tried two methods.
> Killing it with PHP, and killing it with JavaScript.
> 
> Here's the PHP version:
> 
> if (isset($_POST['preview']))
> {
>   $pdf->Output("preview.pdf", "D");
>   die("PDF プレビュー出しました / PDF Preview Displayed");
> }
> 
> Here's the JavaScript version:
> 
> if (isset($_POST['preview']))
> {
>   $pdf->Output("preview.pdf", "D");
>   echo 'javascript:self.close();';
> }
> 
> But in either case, I keep getting that second page coming out, with the
> whole form rendered all over again.
> 
> How can I kill a page? Once the PDF is rendered, I don't need it. I'd be
> okay if it came down to the browser then closed, but it would be better
> if the server sent the PDF and didn't send the page.
> 
> Any advice would be much appreciated.


I think you do, or where else would you show the PDF? Unless you force
the PDF to download when the user clicks the preview button, you are
left with the default option of the users browser, which will most
usually be to display the PDF in the browser window. 

Thanks,
Ash
http://www.ashleysheridan.co.uk