I have tried to upload it simply through the media library ,but it didnt display correctly (very low resolution) and some users couldnt even see it (just an empty space) ,so I used an iframe tag in a page and uploaded the pdf directly to the server.

<iframe frameborder="1" height="200" name="frame1" scrolling="yes" src="/wp-content/themes/abc/images/catalog.pdf" width="550"></iframe>

now it displays correctly but takes a lot of time to load the pdf to the page. now for to users to dowmload the pdf I put a text "right-click for print or save as". I wish I could switch it with some kind of a button --download--.

perhaps I shouldnt upoload the pdf as is (25MB) and just upload images of the catalog.pdf pages ?,it will sure weigh less.but what will I do with the download,it will really slow down the website if all the users will download 25MB file.

I dont know if it is the right way to display and enable download for large pdf files,and try to minimize the use of plugins.

what is the best way to do it ? thank you

  • Can you reupload it to the media library and provide a link please? That is the preferred way to do it as it lets the browser use its own built in tools to display the pdf instead of you actually trying to stream it from the server or upload it to google. – Andrew Bartel Mar 1 '14 at 22:46

If you're using Apache, you can add something like this in your .htaccess file

AddType application/octet-stream .pdf

This will force everything with a .pdf extension to download instead of display in the browser.

If however you are not using Apache or if you want only certain files to download and others to display directly, you could use PHP to do this.

<?php header("Content-disposition: attachment; filename=myfile.pdf"); header("Content-type: application/pdf"); readfile("myfile.pdf");

You could then link to this php file to download the PDF.

  • hi but I need first to display it and also have an option to download it – take that Mar 1 '14 at 18:46
  • In that case, you should take the PHP route. Link to the file directly to view it and link to the PHP file to force a download of the same file. – DerLola Mar 2 '14 at 17:58

Why don't you use Google Docs Viewer?
With it you can embedded PDF, XLS, DOC, etc...


<iframe src="http://docs.google.com/viewer?url=http%3A%2F%2Fwww.pfsense-br.org%2Fblog%2Fwp-content%2Fuploads%2F2011%2F10%2FTutorial-Squid-PFsense.pdf&embedded=true" width="600" height="780" style="border: none;"></iframe>
  • thank you I will check this right now, what about the 25MB download is there any solution for this ? – take that Mar 1 '14 at 18:49
  • Yea the solution is to have a web-optimized PDF embedded and let them download the 25MB file if they want to. – Aibrean Jan 26 '16 at 21:14

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.