Skip to content
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

Is there a way to handle a warning? (e.g. 'Warning: getPathGenerator...') #11860

Closed
jsilveira opened this issue Apr 29, 2020 · 4 comments
Closed

Comments

@jsilveira
Copy link

Hi, I'm using version 2.4.456 in Node 12 to automatically render pdfs' pages to images. I've stumbled with many pdfs where Font errors of the form:

Warning: getPathGenerator - ignoring character: "Error: Requesting object that isn't resolved yet Helvetica_...."

occur, producing blank text. I went over lots of issues (such as #4244), and it seems the only workaround is using the option disableFontFace:false, which is nice but destroys the rest of the working PDFs. I'm trying to find a way to detect the getPathGenerator Warning and then using the disableFontFace:false flag only in those cases. I've tried ignoreErrors with no luck.

Do you have any idea if this is possible without forking the lib? Any tip will be highly appreciated!

@Snuffleupagus
Copy link
Collaborator

Duplicate of #11311

@jsilveira
Copy link
Author

Thanks for the quick reply, I've seen issue #11311 @Snuffleupagus. Even though the motivation for the issue is the same as mine, the broader issue in the library design I brought up is more general and perhaps is worth being discussed: Is it ok for a render error to be uncatchable? In my opinion, addressing this question could make pdf.js a more robust and helpful pdf viewer library.

@Snuffleupagus
Copy link
Collaborator

Snuffleupagus commented Apr 30, 2020

I've tried ignoreErrors with no luck.

That's an internal parameter, and trying to set it won't actually do anything; please see

pdf.js/src/display/api.js

Lines 134 to 137 in b6f69d4

* @property {boolean} [stopAtErrors] - Reject certain promises, e.g.
* `getOperatorList`, `getTextContent`, and `RenderTask`, when the associated
* PDF data cannot be successfully parsed, instead of attempting to recover
* whatever possible of the data. The default value is `false`.

Is it ok for a render error to be uncatchable?

That shouldn't actually be the case though, with stopAtErrors: true set when calling getDocument, since the RenderTask promise should be (and in my testing is) rejected as expected; see

pdf.js/src/display/api.js

Lines 2690 to 2696 in b6f69d4

/**
* Promise for rendering task completion.
* @type {Promise}
*/
get promise() {
return this._internalRenderTask.capability.promise;
}

@jsilveira
Copy link
Author

Ohhh 🤦‍♂️ totally my bad, I missed that option. I saw ignoreErrors on another issue and clearly missed that parameter (I even inspected part of the source code trying to confirm if there was actually another parameter that would do that). Sorry @Snuffleupagus, shame on me.

I can confirm stopAtErrors works as expected, making render errors catchable. Which leaves unresolved only the Font errors part of the issue, that is indeed a duplicate of #11311, so I'm closing this issue.

Thanks @Snuffleupagus and sorry for the wasted time 😅 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants