49617

Java byteArray[] to docx

Question:

doc file in byte[] type. Is it possible to convert it from byte[] into .docx file.

tried just change file extension programilly but it does not work. any suggestions?

I generate report using BiRT eclipse code of saving doc:

options = new RenderOptionBase(); ByteArrayOutputStream bos = new ByteArrayOutputStream(); options.setOutputStream(bos); options.setOutputFormat("doc"); if(parameters != null){ task.setParameterValues(parameters); } task.setRenderOption(options); task.run(); return bos.toByteArray() //IRunAndRenderTask task;

problem is that we use BIRT 3.7 which not support DocxRenderOption

Answer1:

Take a look at Aspose.Words for Java -- <a href="http://www.aspose.com/java/word-component.aspx" rel="nofollow">http://www.aspose.com/java/word-component.aspx</a>

It has really good doc too -- <a href="http://www.aspose.com/docs/display/wordsjava/load+or+create+a+document" rel="nofollow">http://www.aspose.com/docs/display/wordsjava/load+or+create+a+document</a>

Code will be as simple as

// Open a document.

Document doc = new Document("input.doc");

// Save document.

doc.save("output.docx");

Step1: save the doc file Step2: using this lib convert the file and save as docx file.

Recommend

  • Java byteArray[] to docx
  • Android MediaRecorder to AudioTrack, Recording and Playback
  • Facing difficulty while sending mp3 file from Android to Server
  • Need to send Byte Array through Webservice in jmeter
  • Use String as Variable Name Python
  • Change System.in and read System.out programmly on the fly (Jsch)
  • Map SQL Query to Business object in Nhibernate
  • Sending large files Client to Server
  • Finding empty folders recursively and delete them recursively
  • Why gzip compressed buffer size is greater then uncompressed buffer?
  • JSCH Channel Shell, Input / Output
  • android mediarecorder error (MediaRecorder start failed : -19)
  • Angularjs modal acting weird with checkboxes
  • How to use MediaRecorder to capture video on Android?
  • Is it a real date
  • Using a UUID as a Database Primary Key, Java type is a byte[]
  • Yii2: Config params vs. const/define
  • NetLogo BehaviorSpace - Measure runs using reporters
  • Spring security and special characters
  • How to make a tree having multiple type of nodes and each node can have multiple child nodes in java
  • Modifying destination and filename of gulp-svg-sprite
  • JSON with duplicate key names losing information when parsed
  • 'TypeError' while using NSGA2 to solve Multi-objective prob. from pyopt-sparse in OpenMDAO
  • Linker errors when using intrinsic function via function pointer
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • NSLayoutConstraint that would pin a view to the bottom edge of a superview
  • C# - Getting references of reference
  • LevelDB C iterator
  • How can i traverse a binary tree from right to left in java?