Attach (recommended) or Link to PDF file here:
Configuration:
Steps to reproduce the problem:
Create Ellectron app with angular 6 + pdfjs
What is the expected behavior? (add screenshot)
PDF gets displayed
What went wrong? (add screenshot)
ERROR Error: Uncaught (in promise): DataCloneError: Failed to execute 'postMessage' on 'Worker': TypeError: https.request is not a function could not be cloned.
Error: Failed to execute 'postMessage' on 'Worker': TypeError: https.request is not a function could not be cloned.
In Google Chrome everything works fine.
VadimDez/ng2-pdf-viewer#326
app with angular 6
This looks like a duplicate of issue #9166, which was caused by a bug in Angular (rather than PDF.js); please refer to https://github.com/angular/zone.js/pull/980.
This issue is related to non-existent PDF - I have an existing PDF, and the error only occurs in electron app. In Google Chrome everything works fine in my case.
I don't think we can do anything on the PDF.js side without more information, most notably a running demo that shows the issue. Moreover, make sure zone.js
is updated per the issue above.
Closing since no information shows that this is caused by PDF.js itself. All signs point to the Angular issue mentioned above, and there have been more reports of it there.
The issue is not what the error message says, it's actually something else. Since error handling faced another exception while reporting, things got messed up.
The reason for the issue is, Http module misses "require" method to be precise both Http and Https modules are empty.
When using pdf.js in Chrome browser, it uses PDFFetchStream to read data whereas when using pdf.js in Electron it uses PDFNodeStream. When in Electron, to resolve Http request PDFNodeStream uses Node's Http module ( require('http') ), somehow the http variable got overwritten.
Moving Http import inside PDFNodeStreamFullReader and PDFNodeStreamRangeReader solves the issue that we face.
I don't know why http variable got overwritten or who is responsible for this issue as am very new to frontend development but it would be helpful if someone helps us out to resolve this problem.
@giridharkannan I have same issue but I don't know how to move Http report to both PDFNodeStreamFullReader and PDFNodeStreamRangeReader.
@Farbod29
It's been long and I forgot the context, but I can share my working code snippet. Hope this will be helpful
``typescript
if(isElectronBuild()) {
pdfjsDisplayAPI.setPDFNetworkStreamFactory((params) => {
return new PDFFetchStream(params);
});
task = getDocument(pdfUrl);
} else {
task = getDocument(pdfUrl);
}
@giridharkannan thanks for prompt response,I just added task = getDocument(pdfUrl); here but I don't really know how PDF.js working didn't fix yet.
@Farbod29 If it's not a overkill, please do share your code snippet to my mail id. And the code snippet that I gave is not be added on pdf.js's code base, rather on your code.