3

I'm programming a html webpage and i need to show in an iframe a pdf that comes from a download link , how i can jump the download link and show the pdf in the without download the file?.

Sorry if i wrong explained , in short words i need to show in web with iframe the content of a PDF who only link with him is a force download link , i tested your solutions people but it doesn't work for my objectives, any idea ?

Thank you for read me.

0

2 Answers 2

0

You can use javascript to load the source, and it will not be visible in iframe url in page source code. For example with jQuery:

<script type="text/javascript">
$(document).ready(function(e) {
  $('iframe').attr('src','http://www.yourwebsite.com/pdf');
});
</script>

<body>
<iframe src="" />
</body>

Example here.

You can combine it with $.post to get the value serverside:

$.post('get-iframe-src.php', function(data) {
  $('iframe').attr('src',data);
});

You can even load iframe itself to some element like:

$.post('get-iframe.php', function(data) {
  $('#element_id').html(data);
});
1
  • are you saying you can't access the pdf source in the source code? because you can...
    – Sam
    Jul 18, 2014 at 10:00
0

Using an iframe to show a PDF will not work in all browsers because some will attempt to download the actual file.

You should have a look a PDFObjects.

This is how you would use it:

 <object data="myfile.pdf" type="application/pdf" width="100%" height="100%">

  <p>It appears you don't have a PDF plugin for this browser.
  you can <a href="myfile.pdf">click here to
  download the PDF file.</a></p>


</object>

You can put the URL of the file into the data attribute.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.