danfickle / danfickle/openhtmltopdf

Unable to use SVG Image in PDF using PdfRendererBuilder

Open
#945 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
2.2k
Forks
423
PR merge metrics
No merged PRs in 30d

Description

Im trying to add SVG image in HTML which will be later converted to HTML using PdfRendererBuilder class. But SVG image is not getting added in PDF.

Code :

final PdfRendererBuilder builder = new PdfRendererBuilder();

builder.withHtmlContent(content, null);
builder.useSVGDrawer(new BatikSVGDrawer());

try {
builder.toStream(
new FileOutputStream("C:\\Codebase\\spring\\pdf\\src\\main\\java\\pdfbox\\FinalSVG.pdf"));
builder.run();
} catch (final Exception e) {
e.printStackTrace();
}
HTML Code - is attached
Im using openhtmltopdf-pdfbox 1.0.5 & openhtmltopdf-svg-support 1.0.6 libraries.
Please any guidance would be of great help
[testhtmlcode.txt](https://github.com/danfickle/openhtmltopdf/files/12699937/testhtmlcode.txt)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.