How to add an SVG to a PDF using iText7

后端 未结 1 2017
谎友^
谎友^ 2020-12-19 17:04

I need to add an SVG graphic into PDF file.

Is it that possible using iText7?

Using iText5:

BufferedReader in = new BufferedReader(new InputS         


        
相关标签:
1条回答
  • 2020-12-19 17:31

    Coincidentally, we're releasing our SVG implementation today. We don't support the full feature set just yet, we're still working on that in Q2 and beyond, but you can use it already. The artifact is on Maven. The repository is on Github. And the documentation is on our public wiki.

    Code samples will be put on the web site, but it's a very simple API, similar to how pdfHtml works. There's an SvgConverter utility class that offers multiple ways to convert to PDF or PDF XObjects.

    PdfDocument doc = new PdfDocument(
      new PdfWriter(pdfOutputStream, 
        new WriterProperties().setCompressionLevel(0)));
    doc.addNewPage();
    SvgConverter.drawOnDocument(svg, doc, 1);
    doc.close();
    

    Source: I'm an iText developer working on the SVG implementation

    0 讨论(0)
提交回复
热议问题