pe:documentViewer got error when upload file with p:fileUpload

Community Driven Extensions Project
Post Reply
bangngo1508
Posts: 3
Joined: 20 Jul 2017, 06:47

20 Jul 2017, 07:06

I am currently use p:fileUpload to upload a file then show it up in a pe:documentViewer. The form look like this:

Code: Select all

<h:form id="form">
	<p:fileUpload value="#{data.uploadedFile}" skinSimple="true" auto="true"/>
	<pe:documentViewer height="500" value="#{data.printingFileContent}"/>
</h:form>
then whenever I chose a file then I got this errror

Code: Select all

Uncaught TypeError: Cannot read property 'parentNode' of null
    at ProgressBar (eval at <anonymous> (jquery.js?ln=primefaces&v=5.3:14), <anonymous>:10342:24)
    at Object.get loadingBar [as loadingBar] (eval at <anonymous> (jquery.js?ln=primefaces&v=5.3:14), <anonymous>:12952:15)
    at Object.pdfViewProgress [as progress] (eval at <anonymous> (jquery.js?ln=primefaces&v=5.3:14), <anonymous>:13268:26)
    at WorkerTransport.getDocumentProgress [as progressCallback] (eval at <anonymous> (jquery.js?ln=primefaces&v=5.3:14), <anonymous>:13045:12)
    at WorkerTransport.transportDocProgress (eval at <anonymous> (jquery.js?ln=primefaces&v=5.3:14), <anonymous>:6369:16)
    at Worker.messageHandlerComObjOnMessage (eval at <anonymous> (jquery.js?ln=primefaces&v=5.3:14), <anonymous>:2952:19)
ProgressBar @ VM1339:10342
get loadingBar @ VM1339:12952
pdfViewProgress @ VM1339:13268
getDocumentProgress @ VM1339:13045
transportDocProgress @ VM1339:6369
messageHandlerComObjOnMessage @ VM1339:2952

Uncaught TypeError: Cannot read property 'parentNode' of null
    at ProgressBar (eval at <anonymous> (jquery.js?ln=primefaces&v=5.3:14), <anonymous>:10342:24)
    at Object.get loadingBar [as loadingBar] (eval at <anonymous> (jquery.js?ln=primefaces&v=5.3:14), <anonymous>:12952:15)
    at Object.pdfViewProgress [as progress] (eval at <anonymous> (jquery.js?ln=primefaces&v=5.3:14), <anonymous>:13268:26)
    at WorkerTransport.getDocumentProgress [as progressCallback] (eval at <anonymous> (jquery.js?ln=primefaces&v=5.3:14), <anonymous>:13045:12)
    at WorkerTransport.transportDocProgress (eval at <anonymous> (jquery.js?ln=primefaces&v=5.3:14), <anonymous>:6369:16)
    at Worker.messageHandlerComObjOnMessage (eval at <anonymous> (jquery.js?ln=primefaces&v=5.3:14), <anonymous>:2952:19)
ProgressBar @ VM1339:10342
get loadingBar @ VM1339:12952
pdfViewProgress @ VM1339:13268
getDocumentProgress @ VM1339:13045
transportDocProgress @ VM1339:6369
messageHandlerComObjOnMessage @ VM1339:2952
pdf.worker.js:215 Error: Invalid XRef stream header
pdf.worker.js:217     at error (http://localhost:8081/ivy/faces/javax.faces.resource/documentviewer/pdf.worker.js?ln=primefaces-extensions&v=4.0.0:217:15)
    at XRef_readXRef [as readXRef] (http://localhost:8081/ivy/faces/javax.faces.resource/documentviewer/pdf.worker.js?ln=primefaces-extensions&v=4.0.0:6378:13)
    at XRef_parse [as parse] (http://localhost:8081/ivy/faces/javax.faces.resource/documentviewer/pdf.worker.js?ln=primefaces-extensions&v=4.0.0:5975:28)
    at PDFDocument_setup [as setup] (http://localhost:8081/ivy/faces/javax.faces.resource/documentviewer/pdf.worker.js?ln=primefaces-extensions&v=4.0.0:5264:17)
    at PDFDocument_parse [as parse] (http://localhost:8081/ivy/faces/javax.faces.resource/documentviewer/pdf.worker.js?ln=primefaces-extensions&v=4.0.0:5144:12)
    at LocalPdfManager_ensure [as ensure] (http://localhost:8081/ivy/faces/javax.faces.resource/documentviewer/pdf.worker.js?ln=primefaces-extensions&v=4.0.0:4698:24)
    at LocalPdfManager.BasePdfManager_ensureDoc [as ensureDoc] (http://localhost:8081/ivy/faces/javax.faces.resource/documentviewer/pdf.worker.js?ln=primefaces-extensions&v=4.0.0:4634:19)
    at http://localhost:8081/ivy/faces/javax.faces.resource/documentviewer/pdf.worker.js?ln=primefaces-extensions&v=4.0.0:37225:22
    at <anonymous>
pdf.worker.js:200 Warning: Unsupported feature "unknown"
VM1339:1765 Warning: Unsupported feature "unknown"
pdf.worker.js:4704 XRefParseException
    at XRefParseExceptionClosure (http://localhost:8081/ivy/faces/javax.faces.resource/documentviewer/pdf.worker.js?ln=primefaces-extensions&v=4.0.0:410:34)
    at pdfjsWrapper (http://localhost:8081/ivy/faces/javax.faces.resource/documentviewer/pdf.worker.js?ln=primefaces-extensions&v=4.0.0:415:3)
    at http://localhost:8081/ivy/faces/javax.faces.resource/documentviewer/pdf.worker.js?ln=primefaces-extensions&v=4.0.0:42284:4
pdf.worker.js:200 Warning: Indexing all PDF objects
pdf.worker.js:4704 Error
    at InvalidPDFExceptionClosure (pdf.worker.js:361)
    at pdfjsWrapper (pdf.worker.js:365)
    at pdf.worker.js:42284
VM1339:1355 #loading_error is undefined.
getL10nData @ VM1339:1355
get @ VM1339:1521
getDocumentError @ VM1339:13055
VM1339:1355 #error_version_info is undefined.
getL10nData @ VM1339:1355
get @ VM1339:1521
pdfViewError @ VM1339:13204
getDocumentError @ VM1339:13074
VM1339:1355 #error_message is undefined.
getL10nData @ VM1339:1355
get @ VM1339:1521
pdfViewError @ VM1339:13209
getDocumentError @ VM1339:13074
VM1339:13230 Uncaught (in promise) TypeError: Cannot read property 'removeAttribute' of null
    at Object.pdfViewError [as error] (eval at <anonymous> (jquery.js?ln=primefaces&v=5.3:14), <anonymous>:13230:17)
    at getDocumentError (eval at <anonymous> (jquery.js?ln=primefaces&v=5.3:14), <anonymous>:13074:14)
    at <anonymous>
pdfViewError @ VM1339:13230
getDocumentError @ VM1339:13074
for further information whenever I choose a file I see that it request to load the pdf.worker.js?ln=primefaces-extensions&v=4.0.0

bangngo1508
Posts: 3
Joined: 20 Jul 2017, 06:47

20 Jul 2017, 13:59

I just found an answer here: https://stackoverflow.com/questions/398 ... ile-upload
so we can not use pe:documentViewer with any file upload that use input[type=file]

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

21 Jul 2017, 01:30

Thanks for posting. What if you move DocumentViewer into its own form outside the file handling the file upload?
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

bangngo1508
Posts: 3
Joined: 20 Jul 2017, 06:47

21 Jul 2017, 04:27

It does not work. PDFJS registers an event listener with 'change' by window.addEventListener('change', anonymousFunction); it is global event listener. By that way we can not change or override https://www.w3schools.com/jsref/met_ele ... stener.asp (take a look at the note). The error happens because in that function they look up for some elements but they are not available.

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

21 Jul 2017, 23:26

That makes sense. Thanks for the explanation.
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

Post Reply

Return to “Extensions”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 8 guests