将docx格式的字节数组直接转换为pdf格式的字节数组

时间:2016-03-24 12:45:47

标签: java aspose

是否有任何可能的方法将docx / txt或任何格式的字节数组直接转换为pdf格式的字节数组,而无需创建pdf文件。

1 个答案:

答案 0 :(得分:0)

我相信,您可以使用以下Aspose.Words for Java代码来实现此目的:

ByteArrayInputStream inStream = byte array of DOCX/TXT;
// Load Document from inStream
Document doc = new Document(inStream);

/* Perform any document processing tasks here */

// Save the modified document into out stream
ByteArrayOutputStream baos = new ByteArrayOutputStream();
doc.save(baos, SaveFormat.PDF);

// You can then get the PDF document back into the InputStream as follows
InputStream inputStream = new ByteArrayInputStream(baos.toByteArray());

还请使用Aspose.Words for Java检查file formats that you can currently convert to PDF(字节数组或保存到磁盘)。我和Aspose一起担任开发者布道者。

相关问题