[英]Using PdfBox, how do I retrieve contents of PDDocument as a byte array?
I am currently using PdfBox as the driver for a pdf-file editor application. 我目前正在使用PdfBox作为pdf文件编辑器应用程序的驱动程序。 I need the contents of the PdfBox representation of a pdf file (PDDocument) as a byte array. 我需要pdf文件(PDDocument)的PdfBox表示的内容作为字节数组。 Does anyone know how to do this? 有谁知道如何做到这一点?
I hope it's not too late... 我希望现在还为时不晚......
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
document.save(byteArrayOutputStream);
document.close();
InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
And voila! 瞧! You've got both input streams! 你有两个输入流!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.