Is there any CDN url for PDFJS express library

Hi Team,

We are giving the web-viewer folder library path for rendering the pdf. In local it is working. But in our server we are getting path issue. In our angular project we are using only main.js.

Do you have CDN url for the library so that we don’t want to store the lib folder in our project and our path issue will be solved.

Regards,
Yuva

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:

Guides:APIs:Forums:

Hi there,

PDF.js Express does not have a CDN unfortunately. The reason for this is because Express leverages iframes, and loading assets inside an iframe from a 3rd party URL causes issues due to browser restrictions. It is highly recommended to load your assets from the same domain as your application.

Let me know if there’s anything I can do to help you with your path issues.

Thanks!
Logan

Thanks Logan for your reply.

In Adobe Experience Manager portal we have to store the PDF JS plugins folder. But it is not allowing to upload the files with 2 dots in the file name. Is there any possible to rename the files
Ex: webviewer.min.js to webviewer_min.js

Can you please help on this issue.

Below is the error message when upload the file with 2 dots in the file name.

Hi there,

Unfortunately this is a change we cannot make as it would be a breaking change for every other user. We also have a lot of other files that have multiple periods in their name, so renaming just webviewer.min.js won’t resolve your issue.

Thanks,
Logan

Thanks Logan for your reply,

We have stored the plugin in different domain, when the pdf loading we are getting cross origin domain.
I think iframe is blocking the API call.

We had some information from the PDFTRon site for cross origin,

We added domain in configorigin.txt in lib/ui folder. Still see the cross origin domain issue.
Did we miss anything from our end ?
Can you please help us in cross origin domain issue.

Hi there,

When using this approach you must use a config file to execute Express APIs. You cannot use the instance returned from the constructor promise when loading assets cross origin.

I believe you still see that first error message even when using a config file, but you can safely ignore it. To hide the error, you can append a catch call like so:

Express(
  {
    path: "https://yourwebsite/static/lib",
    config: '/static/config.js'
  },
  element
).catch(() => { })

Thanks,
Logan

Hi Logan,

As you suggested, we have created a config file to execute the view document API. (both application & plugin under cisco. com domain)

Our application : https://trustportal-nprd.cisco.com ( From this site on click of document, we are calling the pdfjs plugins)

We stored pdf js plugins : https://www-stage.cisco.com/web/fw/ctp/wv-resources/wv-resources/lib
under the lib folder we created config folder and mention file.js → this is the config file
From this config file we are calling the WebViewer, PDF document file to load.

But still we are getting CORS issue.

As we discussed in mail, please suggest do we are missing anything?

Do you have any working sample code it is good to validate from our end.

Please help us in this CORS issue. Thanks in advance.

Regards,
Yuva

Hi there,

Does your server www-stage-cisco have proper CORS headers set? Is trustportal-nprd allowed to make cross origin requests to it?

Can you send me a screenshot of the exact errors you are seeing?

Thanks,
Logan

(post deleted by author)