I am trying to use this library (Free Spire.pdf for Java v4.4.1) to convert PDFs to SVG. I am able to successfully load the file through pdf.loadFromBytes, however when I then try saveToStream with a new byte array output stream, that new output stream remains empty.
- Code: Select all
private byte[] convertPdfToSvg(byte[] pdfBytes) { //this byte array comes from a MultipartFile (multipartFile.getBytes())
PdfDocument pdf = new PdfDocument();
pdf.loadFromBytes(pdfBytes);
ByteArrayOutputStream out = new ByteArrayOutputStream();
pdf.saveToStream(out, FileFormat.SVG); //out does not change
byte[] retBytes = out.toByteArray();
pdf.close();
return retBytes;
}
Any assistance is appreciated, thank you.