java - Drawing vector images on PDF with PDFBox -
i draw vector image on pdf apache pdfbox.
this code use draw regular images
pdpage page = (pdpage) document.getdocumentcatalog().getallpages().get(1); pdpagecontentstream contentstream = new pdpagecontentstream(document, page, true, true); bufferedimage _previmage = imageio.read(new fileinputstream("path/to/image.png")); pdpixelmap previmage = new pdpixelmap(document, _previmage); contentstream.drawxobject(previmage, prevx, prevy, imagewidth, imageheight);
if use svg
or wmf
image instead of png, resulting pdf document comes corrupted.
the main reason want image vector image png or jpg image looks horrible, think gets somehow compressed looks bad. vector images shouldn't happen (well, when export svg paths pdf in inkscape doesn't happen, vector paths preserved).
is there way draw svg or wmf (or other vector) pdf using apache pdfbox?
i'm using pdfbox 1.8, if matters.
i this, not directly. in first transform svg documents in pdf documents fop librairy , batik. https://xmlgraphics.apache.org/fop/dev/design/svg.html.
in second times, can use layerutility in pdfbox transform new pdf document in pdxobjectform. after that, needs include pdxobjectform in final pdf documents.
Comments
Post a Comment