athenapdf icon indicating copy to clipboard operation
athenapdf copied to clipboard

Weaver microservice not rendering styles/images

Open supermanzer opened this issue 6 years ago • 6 comments

I have the weaver implementation of AthenaPDF running in a docker container as a service in a multi-service application. One aspect of my application involves generating PDFs from rendered HTML code. I have created end points that render the page exactly as I would like it displayed in the PDF. I am making extensive use of Bootstrap 4 style classes as well as some static images. To be clear, these are all coming from a local directory, no CDNs.

When I pass the URL of the page I wish to render to my AthenaPDF microservice, it creates a PDF of the text (including those elements that are hidden when the page is rendered in the browser) but none of the styles are rendered and the image is omitted. What is the best way to ensure styling is considered when the PDF is generated?

supermanzer avatar Mar 01 '18 17:03 supermanzer

I'm having a similar issue, sometimes none of the styling appears, sometimes times a single banner is not rendered, but most of the time is completely fine. Did you end up figuring out what the issue was?

kurtlnz avatar Jul 12 '19 02:07 kurtlnz

@lim-code I'd run the CLI in debug mode on your local machine to see how things generally render.

MrSaints avatar Jul 12 '19 07:07 MrSaints

Thanks for the quick response. Possibly a config issue on my end but running the CLI in debug mode is making the conversion time out. I've tried increasing the worker timeout but still same results.

Any idea what might be causing this?

It's possible the initial issue is concurrency related as there are two of the essentially the same pdf generated in succession, one comes out fine and the other intermittently has issues with rendering styling/images.

kurtlnz avatar Jul 15 '19 06:07 kurtlnz

Possibly a config issue on my end but running the CLI in debug mode is making the conversion time out.

It sounds like you may be running it in a headless environment. You'll need to run it outside of Docker (unless you can mount your display), in an environment (e.g. your local machine) that's able to show graphical user interfaces. Alternatively, try opening your page on Chrome, and printing it. How it shows up in the print preview should be fairly indicative of how it shows up as a PDF (minus handling of print styles, and potential asynchronous JavaScript).

MrSaints avatar Jul 15 '19 08:07 MrSaints

Ah that makes sense, we are running it headless.

I discovered when we're deploying the athena container we're not actually passing in a few of the weaver env variables, only the athena_cmd. Was just wondering if the defaults are set to the following (taken from config.go)?

WEAVER_MAX_WORKERS=10 WEAVER_MAX_CONVERSION_QUEUE=50 WEAVER_WORKER_TIMEOUT=90 WEAVER_CONVERSION_FALLBACK=false

kurtlnz avatar Jul 16 '19 05:07 kurtlnz

@lim-code The defaults should work out of the box :) If you have a HTML or a live URL of your page somewhere, I could perhaps look into what's wrong.

MrSaints avatar Jul 16 '19 07:07 MrSaints