gpt4 book ai didi

java - 使用 PdfBox,如何将 PDDocument 的内容检索为字节数组?

转载 作者:太空狗 更新时间:2023-10-29 23:04:00 26 4
gpt4 key购买 nike

我目前使用 PdfBox 作为 pdf 文件编辑器应用程序的驱动程序。我需要将 pdf 文件 (PDDocument) 的 PdfBox 表示形式的内容作为字节数组。有谁知道如何做到这一点?

最佳答案

我希望现在还不算太晚......

ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
document.save(byteArrayOutputStream);
document.close();
InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());

瞧!你有两个输入流!

关于java - 使用 PdfBox,如何将 PDDocument 的内容检索为字节数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11593116/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com