Closed sgavathe closed 1 year ago
This library is an HTML renderer, not a JS renderer. So getting something like this to work is completely out of scope for this project.
Please consider to convert the chart to an image in JS, then embed it into a html document, and then convert it to PDF.
@timoludwig Thanks. I was hoping it would work this way, since all the other options are fading, especially all the major ones python libraries to export image from html.
i understand previously said it's html template i'm getting terrible results when i try to convert a page, colors, structure and everything, it's html x jinja2 template with bootstrap css loaded via cdn or staticfiles. i see photos loaded, and text rendered via jinja but the colors and placement of divs are too wrong ! can actually xhtml2pdf do that job or should i search for another solution ?
if you adjust the jinja2 template correctly, xhtml2pdf would do a decent job of aligning divs, tables, tags right. Just keep playing with your output and adjust it.
@coda7777 This library can convert HTML + CSS to PDF. It has no idea what do to with JS code and will just ignore it. Also, it doesn't understand templating languages (such as Jinja2), so you need to render your template to html first (via whichever framework you're using) and then have to pass the html code to this library.
About bootstrap: There are quite a few css features that are not supported by this library (check out the existing issues), so if you have another specific feature that's missing and does not yet have an issue, feel free to open a feature request.
@coda7777 This library can convert HTML + CSS to PDF. It has no idea what do to with JS code and will just ignore it. Also, it doesn't understand templating languages (such as Jinja2), so you need to render your template to html first (via whichever framework you're using) and then have to pass the html code to this library.
About bootstrap: There are quite a few css features that are not supported by this library (check out the existing issues), so if you have another specific feature that's missing and does not yet have an issue, feel free to open a feature request.
i removed every CSS, JS calls in the template and used pure divs / css. it doesn't work, for example
<h5 class="text-left" style="background-color: #ffc107b3; padding: 12px 6%; margin: 15px -5%;">
The background color is showing pink instead of the actual color orange-ish
these screenshot from same template rendered once as html webpage and the right one is the pdf created version of it, also notice the marked circle, that color is supposed to be grey-ish color
<div class="row" style="background-color: #c56b0008; padding: 20px">
that's hardcoded in the template no dependancy on CSS (color wise)
https://pasteboard.co/lxcP5dRYWvrT.png
Edited Update : while the issue above presist i figured out what's the reason. xhtml2pdf doesn't accept 8 digits hex color. meaning the transperancy value is not considered and it only renders 6 digits hex. that's why the color goes way off charts.
Describe the Bug
I am seeing a weird issue where the html has a script tag and a chart. It's not rendering a chart. But I can clearly see a chart when I open the html page. Is there an issue with the script tags for it to export?
Minimal Example to Reproduce
Expected Behavior
I would have expected a PDF with a rendered html that I provided as I see it under html page itself.
Actual Behavior
Display a chart fully rendered in the final pdf.
Additional Information
chart that I see it under html page.
System Information
ubuntu
OS version: Python version: 3.8.10 XHTML2PDF version: 0.2.6