• Hi,
    Thanks for a powerful plugin. I’ve been using it for a few years and it has been working great for me. Now I am trying to upgrade to the latest version but got the error listed in the title.
    I am curious as to why this constraint has been added, and what is the recommended way to fix this problem.

    FYI, I am not using the short code but rather for my need I generate an anchor with an href pointing directly to viewer.php, e.g.
    Read More
    With the previous versions, when the user clicks on the link, the PDF file is brought up in a lightbox.

    Thanks for the help.

    dragonrd3

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hey mate getting the same

    “This file was called improperly. Do not call directly.”

    We are using TCPDF dynamic pdf generator that generates a file on button click, uploads to the uploads folder and then pushes the file back to the user via a popup using the URL structure below.

    https://domain.com/wp-content/plugins/pdfjs-viewer-shortcode/pdfjs/web/viewer.php?file=https://domain.com/wp-content/uploads/pdf/document-1234.pdf

    Was an unexpected change after the upgrade, keen to understand the reasons for this limitation.

    Not sure what it means by the error either, don’t side-step the shortcode?

    So this has been a fun unnecessary crisis lol

    Couldn’t find a rollback of the plugin but found a forked / enhanced version of the original code

    https://github.com/rexrana/pdfjs-viewer-shortcode

    Thread Starter dragonrd3

    (@dragonrd3)

    Hi dwaynetorn,
    The new shortcode generates code that refers to viewer.php with a version number. This file checks for the version number and if it doesn’t exist, it issues that error. I think you’re right that bypassing the shortcode seems to be discouraged.
    Until this problem is resolved for me, I rolled back to version 1.3 which works.
    Thanks for the pointer to the new plugin. Is that available on WordPress?

    Plugin Author Thomas McMahon

    (@twistermc)

    The issue is that you’re calling the PDF embed file without any variables in the URL. Add the version back in and it’ll be fine.

    I chose to add a version number into the URL so that we can break caching. Additionally, it’s a way to try and add a bit of security, although it’s not the best.

    I’ll consider removing the requirement for the variable, but also, if you could update your code to add in a variable, that’d be easiest. Is it a custom solution or is another plugin integrating with ours that I’m not aware of?

    Thread Starter dragonrd3

    (@dragonrd3)

    Hi Thomas,
    Thanks for the reply, very much appreciated. Mine is a custom solution and no other plugins are involved.
    I did try calling viewer.php directly with a variable, like so:
    …/pdfjs-viewer-shortcode/pdfjs/web/viewer.php?file=filename.pdf&dButton=true&pButton=true&oButton=false&v=1.5.1#zoom=auto
    but this didn’t work as there were messages in the console saying certain variables were not defined.
    I then tried to provide my own shortcode handler, and that works. However, this approach requires me to go back and fix all the existing posts which is a lot of work.
    It would be great if I can call viewer.php directly. Please kindly let me know the right way to do this.

    Plugin Author Thomas McMahon

    (@twistermc)

    The latest version should fix your issue. Give it a whirl.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Error: This file was called improperly. Do not call directly.’ is closed to new replies.