I have an SVG image generated by Bokeh (link here) with labels on the left and bottom of the chart.
The image itself shows the text within the chart just fine, however, when converting to PDF through Weasyprint, the text is lost.
Has anyone else encountered a similar issue? I'm not sure how to debug this as there are no errors when converting.
A snippet of my export function:
html = HTML(string=html_string)
result = html.write_pdf('./tmp/example.pdf', stylesheets=[css],
font_config=font_config)
Within the HTML template, I use css to embed the image as a background image as so:
html body article#columns section#linechart{
width: 100%;
background: url(./tmp/linechart.svg) no-repeat center;
background-size: contain;
margin: 0;
height: 500px;
overflow: visible;
}
Thanks in advance!
Current version info:
CairoSVG = 2.4.2
Weasyprint = 51
Python = 3.73
I'm not sure if this is related to Cairo or Weasyprint- however, I found that the problem occurred as a result of how the SVG had it's font's styled. Apparently Bokeh uses styling within the actual text element as follows:
<text fill="#444444" stroke="none" font-family="helvetica" font-size="13px" font-style="normal" font-weight="normal" text-decoration="normal" x="472.67919921875" y="58" text-anchor="start" dominant-baseline="central">Opportunities</text>
where as- most other plotting libraries use normal styling through either classes or inline as follows:
<text class="title plot_title" x="400.0" y="26">Opportunities entered YTD</text>
To solve- I opted to use Pygal (another awesome repo by Kozea) and this fixed my issue.