相关疑难解决方法(0)

将pdf转换为svg

我想将PDF转换为SVG,请建议一些能够有效执行此操作的库/可执行文件.我使用apache PDFBox和Batik库编写了自己的java程序 -

PDDocument document = PDDocument.load( pdfFile );
DOMImplementation domImpl =
    GenericDOMImplementation.getDOMImplementation();

// Create an instance of org.w3c.dom.Document.
String svgNS = "http://www.w3.org/2000/svg";
Document svgDocument = domImpl.createDocument(svgNS, "svg", null);
SVGGeneratorContext ctx = SVGGeneratorContext.createDefault(svgDocument);
ctx.setEmbeddedFontsOn(true);

// Ask the test to render into the SVG Graphics2D implementation.

    for(int i = 0 ; i < document.getNumberOfPages() ; i++){
        String svgFName = svgDir+"page"+i+".svg";
        (new File(svgFName)).createNewFile();
        // Create an instance of the SVG Generator.
        SVGGraphics2D svgGenerator = new SVGGraphics2D(ctx,false);
        Printable page  = document.getPrintable(i);
        page.print(svgGenerator, document.getPageFormat(i), …
Run Code Online (Sandbox Code Playgroud)

pdf svg batik pdfbox

50
推荐指数
3
解决办法
5万
查看次数

标签 统计

batik ×1

pdf ×1

pdfbox ×1

svg ×1