ppo*_*off 2 java pdf bytearray aspose aspose.pdf
我需要将aspose.pdf for java库生成的pdf文档保存到内存中(不使用临时文件)
我正在查看文档,但没有找到save具有适当签名的方法.(我一直在寻找某种输出流,或者至少是字节数组).
可能吗?如果是,我该如何管理呢?
谢谢
Aspose.Pdf for Java支持将输出保存到文件和流.请检查以下代码段,它将帮助您完成任务.
byte[] input = getBytesFromFile(new File("C:/data/HelloWorld.pdf"));
ByteArrayOutputStream output = new ByteArrayOutputStream();
com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document(new ByteArrayInputStream(input));
pdfDocument.save(output);
//If you want to read the result into a Document object again, in Java you need to get the
//data bytes and wrap into an input stream.
InputStream inputStream=new ByteArrayInputStream(output.toByteArray());
Run Code Online (Sandbox Code Playgroud)
我是Aspose的开发者传道者Tilal Ahmad.