Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Ben Lawson

    (@falconerweb)

    You can ONLY load pdf files from the same server. Using the same webroot directory should work. I would think that using the unmasked file url would work, but try the masked one too.

    Check your file permissions!

    Using the WordPress upload functionality definitely works, consider doing that.

    The official documentation says the following about using external pdf files:

    Not by default, but it is possible. PDF.js runs with the same permissions as any other JavaScript code, which means it cannot do cross origin requests (see Same origin policy and example). There are some possible ways to get around this such as using CORS (and unsafe headers issue) or setting up a proxy on your server that will feed PDF.js the PDF file. Both workarounds are out of the scope of the PDF.js project and we will not provide code to do either.

    Thread Starter plakapong

    (@plakapong)

    Thanks for your reply, I will try what you suggested.

    Cheers

    I am having the very same problem. I am using WP 3.8. Here is the page I am building:

    https://354democrats.org/blog/?page_id=4

    Click on the Score tab to see the problem. Click on the Recording tab and then the link to see the pdf I am trying to show with the viewer.

    I did use the WordPress upload function to upload the pdf. The file permissions for web users are “Read” but not write or execute. Here is the shortcode string I used:

    [pdfjs-viewer url=”https://354democrats.org/blog/wp-content/uploads/2014/01/TaleSpin-Latest.pdf” viewer_width=600px viewer_height=700px fullscreen=true download=false print=false]

    I know the url is correct, because I can use it as a direct link on my page, but the PDF.js viewer keeps throwing a 404 File Not Found error.

    Thanks in advance for any suggestions.

    So now I have replaced PDF.js in my Score tab with the Google Embedded Docs viewer, which works fine with the same document. In the Test1 tab, I am using a different pdf viewer plugin (wp_pdfjs), which is pretty crude, but has no problem finding my document. In the Test2 tab, I am using PDF.js, with exactly the same problem as before – 404 File Not Found. I have looked at the page source, which looks good. I don’t get it. Why can’t PDF.js find my file (or any pdf file I have uploaded, for that matter), when every other pdf viewer can?

    Hi,

    go to Pulgin Folder and open this file name pdfjs-viewer.php.
    and Go to line Number 31

    Can You change This Line

    Old
    $viewer_base_url= “/wp-content/plugins/pdfjs-viewer-shortcode/web/viewer.php”;

    New

    $siteURL = home_url().”;$viewer_base_url= $siteURL.”/wp-content/plugins/pdfjs-viewer-shortcode/web/viewer.php”;

    now working you pulgin

    Plugin Author Ben Lawson

    (@falconerweb)

    I will implement the change to the base url code in the next version of the plugin.

    Hello, I am having the same problem as above

    “you don’t have permission to access /wp-content/plugins/pdfjs-viewer-shortcode/web/viewer.php on this server.”

    I have followed steps to change line 31, but since I downloaded yesterday, I think the change has been made at your end.

    The PDF is in the uploads directory, so no tricks there

    ‘[pdfjs-viewer url=https://www.early-reading.com/wp-content/uploads/2012/03/Sample_Book_01.pdf viewer_width=600px viewer_height=700px download=true print=true openfile=false]’

    Any ideas?

    Thanks

    I am trying to link a pdf file which is in my media file but can’t get the link to work – this is the message I get:

    The requested URL “https://dev.sheridanhabitat.org/wp-content/uploads/2014/06/Application-for-Housing.pdf” cannot be found or is not available. Please check the spelling or try again later.

    It worked fine when the site launched but not now. HELP

    I am trying to link a pdf file which is in my media file but can’t get the link to work – this is the message I get:

    The requested URL “https://dev.sheridanhabitat.org/wp-content/uploads/2014/06/Application-for-Housing.pdf” cannot be found or is not available. Please check the spelling or try again later.

    It worked fine when the site launched but not now. HELP

    The bug appears, when the siteurl is different to the homeurl of your site, which you set in the wordpress backend.

    You have to change the path in the pdfjs-viewer.php in the plugin directory
    $viewer_base_url= $siteURL.”/PUT-YOUR-HOME-DIRECTORY-HERE/wp-content/plugins/pdfjs-viewer-shortcode/web/viewer.php”;

    Thread Starter plakapong

    (@plakapong)

    Thanks jospBin I’ll give that a try.

    I’ve found this plugin useful – thanks for that – and once I ran into this issue I found this support thread useful, as well!

    I think a safer fix on line 32 of pdfjs-viewer.php would be to change home_url() to site_url() – this allows for cases where WordPress isn’t installed in the web root directory. This yields the same result as jospBin’s suggestion, but doesn’t require the plugin author to know where WordPress is installed, or users to have to edit this file to get around the 404 errors.

    So, lines 32 and 33 would end up being:

    $siteURL = site_url();
    $viewer_base_url= $siteURL."/wp-content/plugins/pdfjs-viewer-shortcode/web/viewer.php";

    Hope this is helpful – thanks again for the plugin!

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘404 error when using a pdf file in wordpress’ is closed to new replies.