Using wkhtmltopdf to create PDFs.

Here is the situation: I have a View that lists all of the "machines" for sale. Each sales person has a different "markup" that is applied to the price. I am doing this through jQuery. I need to be able to print and create a PDF of this View. Soooo.... when I go to mysite.com/print/view-url the jQuery does it's thing and the prices are changed accordingly. BUT.... when I go to mysite.com/print_pdf/view-url the View is output as a PDF but none of the prices are changed.

In troubleshooting I put $('.price').hide(); in the header of the print.tpl.php template in my template folder. Again with the print(html) version, the prices were hidden. In the PDF version, no effect. So it seems as though the jQuery is not being "fired" on the PDF version.

Here is what is really weird. I have A LOT of jQuery for other nodes that do much more complicated calculations and manipulations of the page and they all function properly and without issue on the print and PDF versions.

Thanks for your time and for the great module!

Comments

2ndmile’s picture

StatusFileSize
new17.09 KB
new21.61 KB
new20.57 KB

Because visual aids are fun...

When print/view-url or print_pdf/view-url are used a 10% mark-up should be applied.

- original_prices.jpg shows a screen capture of the view itself with the original prices
- print_html_version_markup_applied.jpg - mysite.com/print/view-url - 10% markup applied as it should be (all if well)
- PDF_version_no_markup.jpg - mysite.com/print_pdf/view-url output - no markup - hmmm???

jcnventura’s picture

Status: Active » Postponed (maintainer needs more info)

Hi,

What PDF generation tool are you using? The only one that fully supports Javascript is wkhtmltopdf, as that's the only one which actually is a Web browser. The others are simple imitations of a web browser, so their HTML, CSS and Javascript support varies.

João

2ndmile’s picture

Using wkhtmltopdf to create PDFs.

2ndmile’s picture

Status: Postponed (maintainer needs more info) » Active

Setting to active...

jcnventura’s picture

Status: Active » Postponed (maintainer needs more info)

Hi,

Well, if it works in the print HTML version, that's the page that gets passed to wkhtmltopdf, so I really have no idea what could be done in the module to fix it.

I suspect it's either a problem in your Javascript or in wkhtmltopdf. Can you provide a URL to that page?

João

2ndmile’s picture

Status: Postponed (maintainer needs more info) » Active

This site is completely behind a username and password. I sent you a message via the d.o contact form. I am willing to pay to get this fixed.

Again... I do think it is my javascript because even a simple .hide(); is not working. But on nodes, all the javascript works as expected. It is just plain weird.

2ndmile’s picture

Status: Active » Closed (fixed)

Updated to latest dev... now I have other problems... so closing this one.

christiaan_’s picture

I had similar issues with exposed filters not being applied to the printed view. The issue was with using AJAX on the view I was printing.
set Use AJAX: No and everything started working perfectly.