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

Support for using headless chrome instead of wkhtmltopdf. #733

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

erikaxel
Copy link

Hi,

This pull request is a WIP and a starter for discussion on how wicked_pdf can support headless chrome in addition to wkhtmltopdf.

This might be useful to people since wkhtmltopdf has stagnated and is using a very old version of webkit.

We use this code in production, so it is battle tested, but probably needs some cleanup and documentation before it can be merged.

I also previously did a version with phantomjs #619 but since phantomjs is also abandoned, this pull request supersedes it. However, many of the discussions in the previous pull is probably also relevant here.

Any comments more than welcome!

@morellan
Copy link

Hi @erikaxel, any chance you can rebase to the latest master and fix the CI problem?, it looks like the problem is here:

Error: test_should_call_after_action_instead_of_after_filter_when_able(PdfHelperTest): Mocha::NotInitializedError: Mocha methods cannot be used outside the context of a test

@erikaxel erikaxel force-pushed the master branch 2 times, most recently from dc99ae3 to a70b987 Compare September 6, 2018 19:14
@erikaxel
Copy link
Author

erikaxel commented Sep 6, 2018

Rebased, and checks green.

@morellan
Copy link

morellan commented Sep 6, 2018

Thanks @erikaxel, I used your solution with Elastic Beanstalk and added a new config to setup the puppeteer executablePath on launch options, you can see it here morellan@576c041

It was easier for me to deploy it on AWS Elastic Beanstalk Amazon AMI using a custom executable path.

@mynameisnotbruce
Copy link

Is there any hope for this feature? We're considering using grover (which uses headless Chrome via puppeteer), but that comes with a boatload of Node dependencies which we would love to avoid.

@erikaxel
Copy link
Author

@unixmonkey Hi, I rebased this on the latest changes so it doesn't have merge conflicts anymore. PS: We are using this in production and have for the last couple of years, so it is quite stable. However, the code is perhaps not the most beautiful so let me know if you would like to get it in shape to actually be merged into this project.

@dixpac
Copy link

dixpac commented Apr 25, 2021

@erikaxel how satisfied are you with switch from the wkhtmltopdf to puppeter? Researching to migrate also.
I'm aware that headless will be easier to work with regarding; css and dependency management, what are your production experiences in terms of performance and scalability?

@erikaxel
Copy link
Author

We are very happy with this. wkhtmltopdf is using such an old version of the renderer and with puppeteer we get the latest version whenever we want. We have used two versions, first we used one where we included Chrome in our docker build and then ran puppeteer locally. This fix does this and we used it for along time. Downside is that your image becomes quite a bit larger because of Chrome. So we have recently pulled this out and is serving it as an internal microservice instead, sending HTML, running puppetter and returning the PDF.

@imlunek
Copy link

imlunek commented Jan 2, 2024

I am not sure if this is the fully working compatible code. But its very disappointing that this feature is still not merged or doesn't have similar update for using other than wkhtmltopdf.

Or if there really is a way to use something other than wkhtmltopdf, it should be documented and also let us know here.

@mileszs
Copy link
Owner

mileszs commented Apr 29, 2024

But its very disappointing that this feature is still not merged or doesn't have similar update for using other than wkhtmltopdf.

I'm not the primary maintainer of this library at this point, which is certainly obvious for anyone who has been involved. However, I want to chime in here.

Part of what makes maintaining this gem more taxing than one would think is fielding questions that are primarily about wkhtmltopdf as opposed to about the Ruby code itself that is essentially just setting up a call to that CLI tool. We don't have close ties to the wkhtmltopdf tool, but @unixmonkey especially wants to be as helpful as possible figuring out issues with it AND WickedPDF.

@imlunek I hear you on being disappointed. However, we have not felt prepared to field questions about wkhtmltopdf, puppeteer, and wicked_pdf. I'm sure you've seen OSS Issues lists in which the maintainers are very hardline about which types of issues they will entertain, and they otherwise close without answer anything outside those categories. We would normally not like to take such a hardline stance, but we would probably have to if it came to it.

I am currently considering the possibility of forking WickedPDF to create a gem that is the same API as WickedPDF but uses puppeteer, or hell maybe I fork WickedPDF and bring this PR over. The reason for forking would be so that no one who is currently very involved here feels like they have to also answer questions about Puppeteer (unless they for some reason want to).

No decisions made. Just wanted to give an update. I intend to let this PR remain open indefinitely so that it is visible for those who might want it now.

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

Successfully merging this pull request may close these issues.

7 participants