Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: HTML PHP MySQL IFrame
 <iframe src="http://docs.google.com/gview?url=http://example.com/test/pdf/ex.pdf; ?>&embedded=true" style="width:608px; height:700px;" frameborder="0"></iframe>
 

The above iframe code, displays pdf on the browser.
 
But my problem is, I have uploaded the pdf to the database(BLOB) and to be able to download the pdf - the link would be something like
 
www.example.com/test/view.php?id=21 
 
and if i add above url in iframe google viewer, it never recognize is parameter.
 
<iframe src="http://docs.google.com/gview?url=http://example.com/test/view.php&id=21 ; ?>&embedded=true" style="width:608px; height:700px;" frameborder="0"></iframe
 

So what's the best way to be able to view the pdf on the browser, using same technique or something else -
 
The below code downloads the pdf
 
header("Content-type: $this->type");
header("Content-Disposition: attachment; filename=$this->name");
echo $this->content;
 
Is there anything i can change in this code to force it to open in the same browser instead of download?
 
Thanks
Posted 20-Jul-12 4:45am
AndyInUK3.4K
Comments
AndyInUK at 20-Jul-12 11:58am
   
No php/mysql/html guru here??
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

YOu shoudl search codeproject for this question.... For instance: Blend PDF with Silverlight
 
The solution is quite complicated though.....
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

I am interested to know about your server is it online? can I access it? or it just a local machine? if this is a local machine then it is sure that google server wont be able to get the pdf.
 
When a client send a request to server it does not know what is going to be replied from server. server can give some direction to client but server cant force client. Server can inform client application that it is sending a pdf. but if client application choose to open pdf file on her application or want to save on local machine then she can. But it depends whether your server is accessible to outside world or not. And whether you mention to google server to download or just to view it would download anyway in order to do processing.
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

I created a (private, used by us in the timetable dept) alternative timetable viewing system for a college I worked at a couple of years back. This would display pdfs inside Iframes too. The code that I had was considerably shorter for embedding the pdf.
 
Basically, the JS would construct the following html for the pdf's iframe.
<iframe src="pdfTimetable.php?id=12345678&type=student" width="700px" height="500px"></iframe>
 
The underlying database has since been damaged, however I was able to test the code earlier this year with my android and desktop browsers, the behaviour was still the same as it was 2 years ago, when tested with Chrome, FF, IE 6,7,8.
 
Which browser(s) are you testing with?
 
Also, I think the term you're looking for is uploads. As in - "The below code downloads the pdf" --> "The below code uploads the pdf (to the client machine, from the server)"
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 George Jonsson 215
1 Kornfeld Eliyahu Peter 169
2 OriginalGriff 120
3 PIEBALDconsult 110
4 Zoltán Zörgő 99
0 OriginalGriff 6,165
1 DamithSL 4,658
2 Maciej Los 4,107
3 Kornfeld Eliyahu Peter 3,649
4 Sergey Alexandrovich Kryukov 3,342


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 26 Jul 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100