I would like to draw a vector image in a PDF file using Apache PDFBox.
This is the code I use to 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 you use svg or wmf image instead of png, then the resulting PDF document will be damaged.
The main reason I want the image to be a vector image is because it looks awful with PNG or JPG, I think it is somehow compressed, so it looks bad. This should not happen with vector images (well, when I export SVG paths as PDF to Inkscape, this does not happen, vector paths are saved).
Is there a way to draw svg or wmf (or another vector) in a PDF using Apache PDFBox?
I am currently using PDFBox 1.8, if that matters.
source share