PDFmyURL and SVG issues

PDFmyURL and complicated SVGs

PDFmyURL is a quick tool to convert dynamic HTML content to PDFs.

Recently we ran into issue on a project where it could not render complicated SVGs (these SVGs were floorpans with multiple layers/plans in each).

The issue:

The page technically finished loading before the content could draw – but because PDFmyURL had a successful page load it created the PDF while the SVGs drew – which produced incomplete looking PDFs.

The fix:

A quick (but workable) fix was to get the file contents of the SVG, remove the unnecessary layers and then base64 the leaner SVG in an <img> tag like so:

<img src='data:image/svg+xml;utf8,<svg ... > ... </svg>'>

Not ideal but it worked, PDFs now generated as expected.

Leave a Reply

Your email address will not be published. Required fields are marked *