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

PDF generated despite an error on an image #867

Closed
JBR69 opened this issue Nov 8, 2017 · 8 comments
Closed

PDF generated despite an error on an image #867

JBR69 opened this issue Nov 8, 2017 · 8 comments
Milestone

Comments

@JBR69
Copy link
Contributor

JBR69 commented Nov 8, 2017

Hi,

I have a problem with the alpah.15 version (but I don't know since which version this problem exists).
Previously when there was an error on an image, the generation of the PDF was interrupted.
Today, in the logs I can have this error
ErrorNotification.js:122 [node-error 8:33:59 AM] asciidoctor: ERROR: could not embed image: F:/Documentations/asciidoc/sources/fr/resources/images/EVO-AA/image052.png; PNG uses unsupported interlace method
but the PDF file is still generated.

Is this a desired evolution or a bug?
Where should I make changes so that the generation hangs in case of error?

Thank you.
Jérôme

@aoyawale
Copy link

running into the same issue.

@mojavelinux
Copy link
Member

I strongly encourage you to use the gmagick integration documented here https://github.com/asciidoctor/asciidoctor-pdf#supporting-additional-image-file-formats when working with PNG images. Prawn only has rudimentary support for PNG by default.

Where should I make changes so that the generation hangs in case of error?

The policy of the Asciidoctor processor is not halt because of a content error. Right now you have to check for warnings on stderr, but in the future we'll have a logging and document errors facility.

@JBR69
Copy link
Contributor Author

JBR69 commented Mar 12, 2018

Thank you for your answer but prawn-gmagick is limited to Linux and OSX and I'm using windows.

@mojavelinux
Copy link
Member

In this case, it's really just a warning...and may not affect the image at all. Just verify that the image looks correct. If you want to make the warning go away, just reencode the image without interlace support, or reencode it to jpg.

@mojavelinux mojavelinux added this to the support milestone Mar 19, 2018
@JBR69
Copy link
Contributor Author

JBR69 commented Mar 20, 2018

Yes this is what I am doing.
But my problem is that I want to halt the PDF generation.
We generate about 80 documents every night (with jenkins job) and we quickly know if an image is not good.
The solution I found (and that works) for the moment is to replace (in inline_image_arranger.rb)

warn% (asciidoctor: ERROR: could not embed image: # {image_path}; # {e.message})

by

raise :: IOError,% (asciidoctor-pdf: ERROR: could not embed image: # {image_path}; # {e.message})

Jérôme

@mojavelinux
Copy link
Member

mojavelinux commented Mar 20, 2018

This traces back to asciidoctor/asciidoctor#44.

It's Asciidoctor's policy not to throw errors on conversion of a document for a warning or error...because that puts a road block in the writing process (I'm talking about content errors here, not program errors). But once we collect errors and warnings (instead of just printing them), then we have the ability to provide gates that can control how to handle this condition. But I'm not going to make a change for this one issue when the discussion is much broader.

@mojavelinux
Copy link
Member

What I encourage you to do right now is capture the stdout coming from Asciidoctor and fail the build if there are messages printed. There are several projects out there that provide a script for this.

@mojavelinux
Copy link
Member

Asciidoctor PDF now uses the Asciidoctor logger. So if you want to fail on warnings, you can check if any warnings were logged and fail. The Maven plugin happens to have a hook for this.

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

3 participants