8 Replies Latest reply: Jun 23, 2012 9:03 AM by Ben Pleysier RSS

    PDFs

    Jeffrey54 Lane Community Member

      When you make a link to a PDF file that is in your own site root, how can you make a link back with out having to use the back arrow on the browser, can any one help please thanks Jeff

        • 1. Re: PDFs
          Ben Pleysier CommunityMVP

          The most elegant way is to force a download similar to what would happen if you had a linked Word document.

           

          If you have access to PHP, have a look here or if you want to use JS have a look at this answer http://stackoverflow.com/questions/365777/starting-file-download-with-javascript

           

          Gramps

           

          Sorry, here is the PHP link http://webdesign.about.com/od/php/ht/force_download.htm

           

          Message was edited by: Altruistic Gramps

          • 2. Re: PDFs
            Jeffrey54 Lane Community Member

            Hi Altruistic I looked at the java option I think it might be a bit complicated for me at the moment, you don’t seem to have put the link for the PHP option.

             

            Thanks Jeff

            • 3. Re: PDFs
              Ben Pleysier CommunityMVP

              Sorry, I modified the original post to include the link. But if you are happy with a PHP solution, I will certainly help you.

               

              Gramps

              • 4. Re: PDFs
                Jeffrey54 Lane Community Member

                Hi Gramps By the way I became a Gramps myself about three weeks ago my first grandson, “great feeling”. Anyway just to make sure we are singing from the same song sheet, what I want to do is, is create an accessories page using small pdf files to contain the items, so basically I will make a list of links, with a short name/reference and maybe a thumb nail picture by it, so the customer can click the link to go to the pdf and after their finished can click another link back to the original link, and so on, on my tips and trick page I have created on the third link down, a link to a pdf files, but I can’t work out how to get back without using the back arrow on the browser.

                 

                Thanks Jeff

                • 5. Re: PDFs
                  Ben Pleysier CommunityMVP

                  Congratulations, I enjoy the grandkids more than I did my own kids, mainly because have more time on my hands.

                   

                  I know that PDF files do open in a browser window, but for years now, I have claimed that a PDF file should open in its native document window because its behaviour is different to an HTML document. There is nothing more confusing to us oldies then to click on a PDF link only to find that we have lost our original page. The PDF page looks different and we do not realise that we have to click the back button to return to the original page. If we click a Word link, we are taken to Word to show the document. The same applies to an Excel link, then why not a PDF link.

                   

                  If you go to http://pleysier.com.au/jeffrey/ you will see what I mean. Try in different browsers to see how each reacts differently.

                   

                  The document markup can be seen when you view the source code. The script for pdf_dl.php is as follows

                   

                  <?php
                  if (isset($_GET['file'])) {
                      $pdffile = $_GET['file'];
                      header('Content-disposition: attachment; $pdffile.pdf');
                      header('Content-type: application/pdf');
                      readfile(''.$pdffile.'.pdf');
                  }
                  ?>
                  

                   

                  Gramps

                  • 6. Re: PDFs
                    Ben Pleysier CommunityMVP

                    Sorry I made a booboo with the PHP file. It should read

                     

                    <?php
                    if (isset($_GET['file'])) {
                        $pdffile = $_GET['file'];
                        header('Content-disposition: attachment; filename='.$pdffile.'.pdf');
                        header('Content-type: application/pdf');
                        readfile(''.$pdffile.'.pdf');
                    }
                    ?>
                    

                     

                    Gramps

                    • 7. Re: PDFs
                      Jeffrey54 Lane Community Member

                      Hi Gramps I just looked at the pdf example you gave me the link for, when I clicked it and the save as screen came up to see it I had to down load it, will the customers have to do this every time. Jeff

                      • 8. Re: PDFs
                        Ben Pleysier CommunityMVP

                        I don't know which browser you used, but in FF it shows as

                        _Capture.jpg

                        In IE it shows as

                        _Capture.jpg

                        in Chrome

                        _Capture.jpg

                        in Safari it is also very similar.

                         

                        Gramps