-
Notifications
You must be signed in to change notification settings - Fork 10k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
examples/node/pdf2png example fails when using any other file other than the helloworld.pdf example file #8489
Comments
Same problem for me |
I am having a similar issue. Does the PDF need be generated by GNUpdf only? |
The issue appears to be related in some way to the fontLoader; I would guess it's in some way connected to having a custom embedded font in the PDF, but I'm still investigating. The actual location of the exception is:
You can find this yourself by using Bluebird, setting |
I find a workaround in #7929 :
|
What about documents with images?
|
any idea how to solve it for documents with images? |
I'm seeing the same error as @nicholaswmin with a different (very simple/small) document. A couple of data points:
|
So I chased these problems a bit today, and here's what I've found so far: First of all, you don't need Bluebird to get the full stack of unhandled exceptions, just add this at the top of your script:
The examples are written in typescript andI drive this in Google Cloud Functions, so I require import { PDFJSStatic, PDFDocumentProxy, PDFSource, PDFPageProxy } from 'pdfjs-dist'
const Canvas = require('canvas-prebuilt')
const pdfjs = require('pdfjs-dist') as PDFJSStatic OK, let's start..
const source = {
data: pdfBuffer,
nativeImageDecoderSupport: 'none',
disableFontFace: true
} as PDFSource
pdfjs.getDocument(source).then(result => {
The stub can be empty, as the only point where it is used is this instance of: (the comment even states that this does not work in node..) Lines 2115 to 2116 in 25bbff4
This could actually be fixed quite easily just by checking if // typeof check is needed in node.js, see issue #8489
if ((typeof HTMLElement === 'function' && imgData instanceof HTMLElement) || !imgData.data) { |
This change fixes "Unhandled rejection ReferenceError: HTMLElement is not defined" issue that is discussed in more detail in mozilla#8489.
Opened PR to address the HTMLElement issue, see #9588 |
This change fixes "Unhandled rejection ReferenceError: HTMLElement is not defined" issue that is discussed in more detail in mozilla#8489.
This change fixes "Unhandled rejection ReferenceError: HTMLElement is not defined" issue that is discussed in more detail in mozilla#8489. (cherry picked from commit c20426e)
This change fixes "Unhandled rejection ReferenceError: HTMLElement is not defined" issue that is discussed in more detail in mozilla#8489.
Test file: gal-trace.pdf
Configuration:
Steps to reproduce the problem:
gal-trace.pdf
file inexamples/helloworld/
folderpdfURL
inexamples/node/pdf2png/pdf2png
to point toexamples/helloworld/gal-trace.pdf
pdf2png.js
exampleWhat is the expected behavior?
gal-trace.pdf
What went wrong? (add screenshot)
The text was updated successfully, but these errors were encountered: