DinkToPdf icon indicating copy to clipboard operation
DinkToPdf copied to clipboard

img and embed tags with svg extension does not load

Open isabella-riquetti opened this issue 3 years ago • 2 comments

SVG format images are not converted to PDF. Other image formats such as .png and .jpg load correctly, but .svg loads in HTML if used in a browser, but is not rendered in PDF.

Exptected result (svg and jpg are loaded): image

DinkToPdf result (only the jpg image is loaded): image

        [HttpGet]
        [Route("pdf-bug")]
        public IActionResult Bug()
        {
            var html = @"
                        <html>
                            <head></head>
                            <body>
                                <img src='https://www.flaticon.com/svg/static/icons/svg/784/784558.svg' height='30px'>
                                <img src='https://img-authors.flaticon.com/freepik.jpg' height='30px'>
                            </body>
                        </html>";

            var doc = new HtmlToPdfDocument()
            {
                GlobalSettings =
                {
                    ColorMode = ColorMode.Color,
                    Orientation = Orientation.Portrait,
                    PaperSize = PaperKind.A4,
                    DocumentTitle = "Bug"
                },
                Objects =
                {
                    new ObjectSettings()
                    {
                        HtmlContent = html
                    }
                }
            };

            byte[] file = _converter.Convert(doc);
            return File(file, "application/pdf");
        }

isabella-riquetti avatar Nov 19 '20 18:11 isabella-riquetti

@isabella-riquetti How did you solve it ,thax

wangengzheng avatar Jun 09 '21 08:06 wangengzheng

Hi Team,

Any solution on loading the svg files in the pdf?

Thanks In Advance

itzmepraveenkumar avatar Sep 01 '21 04:09 itzmepraveenkumar