Document viewer issues

Community Driven Extensions Project
Post Reply
GLee
Posts: 18
Joined: 10 Nov 2014, 17:47

03 Oct 2020, 18:55

I love the document viewer, but it's very picky about where the URL comes from. Even if I have a PDF servlet running on the same server where the app with the document viewer is running, it complains that I it's unable to load files because of CORS. I solved that by adding a HTTP header on the servlet for Access-Control-Allow-Origin, it's now complaining that it's not permitted to open the file because ??? I have no idea, because the error messages are so terse. All it says is "not permitted to load." Great! That helps. I think it might be because the servlet's URL is http and the main app's URL is https.

So, I've decided to give up and just load PDF files from the operating system. Can somebody supply some code that will allow me to load PDF files dynamically into the document viewer without using anything on the network? It't too difficult to debug otherwise.

Melloware
Posts: 2291
Joined: 22 Apr 2013, 15:48

04 Oct 2020, 00:18

Yep this example has 3 tabs.

http://primefaces.org/showcase-ext/sect ... /basic.jsf

You want either the Resource example:

Code: Select all

<pe:documentViewer height="500" library="books" name="hood.pdf"/>
Or the streamed content example:

Code: Select all

 <pe:documentViewer height="500" value="#{basicDocumentViewerController.content}" download="#{basicDocumentViewerController.downloadFileName}"/>
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 8.0.3 / PF Extensions 8.0.4

GLee
Posts: 18
Joined: 10 Nov 2014, 17:47

07 Oct 2020, 16:34

Well, isn't the library="books" name="hood.pdf" actually loading a file from the application (war file) rather than the OS?

I need the ability to load files from the OS by supplying a path since the files will be changing all the time. It would be impossible to imbed all these files within the application.

Melloware
Posts: 2291
Joined: 22 Apr 2013, 15:48

07 Oct 2020, 16:36

The use the resource example then you can load whatever you want from the OS:

Code: Select all

 <pe:documentViewer height="500" value="#{basicDocumentViewerController.content}" download="#{basicDocumentViewerController.downloadFileName}"/>
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 8.0.3 / PF Extensions 8.0.4

Post Reply

Return to “Extensions”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 4 guests