danfickle / openhtmltopdf

An HTML to PDF library for the JVM. Based on Flying Saucer and Apache PDF-BOX 2. With SVG image support. Now also with accessible PDF support (WCAG, Section 508, PDF/UA)!
https://danfickle.github.io/pdf-templates/index.html
Other
1.92k stars 358 forks source link

SVG rendering issues with batik-1.9 #99

Open thekeenmonk opened 7 years ago

thekeenmonk commented 7 years ago

I found that the same SVG code that renders fine with batik 1.8 does not render properly with batik 1.9. No errors are visible in logs but the rendering is incomplete. I need to integrate with an existing project that uses batik-1.9 jars. Is there a known incompatibility with batik 1.9?

Output with batik-1.8 (correct):

screen shot 2017-05-31 at 5 01 19 pm

Output with batik-1.9 (incomplete):

screen shot 2017-05-31 at 5 01 27 pm
danfickle commented 7 years ago

Hi @ketanmpandya

The project hasn't been debugged with batik 1.9, although it looks like it could be a clipping problem. I'd suggest using the maven shade plugin to repackage batik in a custom svg-support pom. The closest I could come to find a guide on how to do this is at the below link. https://www.elastic.co/blog/to-shade-or-not-to-shade

If you do get this working (or not), please let us know so others can learn. Good luck.

rototor commented 7 years ago

@ketanmpandya This is rather an issue with pdfbox-graphics2d than with openhtmltopdf, as the SVG rendering runs through pdfbox-graphics2d. I've opend an issue and will investigate whats going wrong here. A sample SVG file to reproduce the bug would awesome.

rototor commented 7 years ago

@ketanmpandya I can confirm that upgrading batik to 1.9 breaks the SVG rendering with pdfbox-graphics2d.

rototor commented 7 years ago

I've created the pull request #104 which fixes that bug. My PDFBox-Graphics2D adapter had a bug with getClip() and clip(Shape). I've released a fixed version 0.5. You can wait till @danfickle merges this pull request and releases a fixed version or you can just add this dependency to your project

<dependency>
    <groupId>de.rototor.pdfbox</groupId>
    <artifactId>graphics2d</artifactId>
    <version>0.5</version>
</dependency>