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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 '<script type="text/javascript">javascript:self.close();</script>';
> }
> 
> 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



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux