2016-03-24 18 views
0

pdfファイルを作成せずに、docx/txtまたは任意の形式のバイト配列をpdf形式のバイト配列に直接変換する方法はありますか?docx形式のバイト配列をpdf形式のバイト配列に直接変換する

+1

これは矛盾しています。 "docxからpdfへの変換" *は "pdfファイルの作成"です。あなたはちょうどそれをディスクに保存しませんでした... – Fildor

+0

はい、あなたは** ByteArrayOutputStream **に書き込んで、バイト配列を取ることができます。変換ライブラリが必要です。 –

答えて

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()); 

file formats that you can currently convert to PDF(バイト配列をまたはディスクに保存)をご確認くださいAspose.Words for Javaのを使用。私はAsposeとDeveloper Evangelistで働いています。

関連する問題