How to open PDF file?

158 views
Skip to first unread message

Achille

unread,
Mar 11, 2009, 8:13:09 AM3/11/09
to fancybox
I want show a PDF file generated at run time by PHP code, but don't
work.
I tested it like iframe, ajax or simple link.

aguy

unread,
Mar 12, 2009, 4:44:41 AM3/12/09
to fancybox
try showing a demo page in an iframe to see if it basically works.

if that's ok then you might have a similar pdf-problem that i know
from thickbox:
showing any file worked ok, while only pdfs never showed up.

my solution to this was to set up a simple html page that does nothing
but to redirect immediately to the pdf-file.
it's strange, but even doing a redirect within php [header
("location: ...");] did not work - the redirect must happen using a
META redirect tag or javascript.

hope this helps...

Achille

unread,
Mar 12, 2009, 10:56:06 AM3/12/09
to fancybox
aguy, many thanks but also this test don't work.

The problem is that my PDF is non a file but is generated at run time
by php code sending "header('Content-disposition: inline;
filename=..."

aguy

unread,
Mar 12, 2009, 11:56:34 AM3/12/09
to fancybox
couldn't you move the pdf-generating part into a separate php file?
iframes can - by design - only display content from a separate file,
not inline generated content...

if that's not possible you might have to write the generated pdf-code
into a temporary file and link fancybox's iframe to that file...

pSouper

unread,
Mar 13, 2009, 6:32:18 AM3/13/09
to fancybox
I do almost this where the file shown is an image (requested as a link
to a php file - the response is then shown as an image file) you may
be able to use this...
(note: the fancybox dimensions are not set dynamically from the larger
content so you if you do not know these before hand you will need to
fake it somehow - i have asked for a tip on doing this so fingers
crossed)
________________________________________________
# php file that gets displayed as the large image
function getImage($id){
$filename = path/to/imageGenerator.'?id='.$id;
return '<img src="'.$filename.'" alt="'.$filename.' rel="fancybox"
class="thumbnail" border="0" >';
}
echo getImage($id);
________________________________________________
# html for each image cell to call the dynamic image
<div class="imageCell">
<a class="group1" href="{IMAGE}" border="0" rel="fancybox"
class="thumbnail">
<img src="{THUMBNAIL}" border="0" alt="{NAME}" target="_BLANK">
</a>
<div class="caption">
<label>Edit</label><input name="imageName" type="radio"
value="{IMAGE}" onclick="document.form.submit()">
</div>
</div>
________________________________________________

hope it helps - it works for me in my instance
Reply all
Reply to author
Forward
0 new messages