0

I am using the SVG to PDF example posted at https://itextpdf.com/demos/convert-svg-to-pdf-free-online, but in a simple test, I find that the fonts in the SVG document are not embedded.

Looking for some help, I find Itext embed font in a PDF as a potential solution, but the solution discussed applies to a consdiderably older version of iText.

If I were adding text paragraphs to the PDF, I find examples at How to use Fonts in iText PDF and https://kb.itextpdf.com/home/it7kb/examples/itext-7-building-blocks-chapter-1-pdffont-examples, but I have not been successful in adapting these to an SVG-PDF conversion.

While the sample code provided by iText is for .NET, I do have it adapted to PowerShell:

        [PdfWriter]$pdfWriter = [PdfWriter]::new($Output, [WriterProperties]::new().SetCompressionLevel(0))
        [PdfDocument]$doc = [PdfDocument]::new($pdfWriter)

        $doc.AddNewPage([PageSize]::LETTER.Rotate())

        [SvgConverterProperties]$ConverterProps = [SvgConverterProperties]::new().SetBaseUri($InputFile)

        [System.IO.FileStream]$FileStream = [System.IO.FileStream]::new($InputFile, [System.IO.FileMode]::Open, [System.IO.FileAccess]::Read, [System.IO.FileShare]::Read)
        [SvgConverter]::DrawOnDocument($FileStream, $doc, 1, $ConverterProps)

        $doc.Close()

I am expecting an output that resembles:

enter image description here

My current output is:

enter image description here

Tim AtLee
  • 917
  • 1
  • 10
  • 17

0 Answers0