aspose file tools*
The moose likes Java in General and the fly likes How to convert word doc byte array into pdf programatically in struts action Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to convert word doc byte array into pdf programatically in struts action" Watch "How to convert word doc byte array into pdf programatically in struts action" New topic
Author

How to convert word doc byte array into pdf programatically in struts action

Mintu Mmazumder
Greenhorn

Joined: Aug 17, 2011
Posts: 10

Hi All,

I am facing a problem right now.I need idea/code snippet on how to convert word doc to pdf programatically.Here,We can't use pdf generation line by line usinmg itext or can't directly by setting 'application/pdf' in response object.




Mintu Mazumder
Cognizant - kolkata
Shahzad Latif
Greenhorn

Joined: Apr 28, 2011
Posts: 28
You may try Aspose.Words for Java. This component allows you to convert doc/docx files to PDF with the help of a couple of code lines.

As you want to load the doc from a byte array, you may convert it to Input Stream and use the other constructor of Document class with InputStream parameter. The API is very simple and can be used in any type of Java application easily. The output PDF file quality is quite good as well. Please try it at your end and see if it helps in your scenario.

Developer Evangelist @ Aspose. I love to explore and learn new technologies and help other developers along the way.
Ankur Kapoor
Greenhorn

Joined: Sep 13, 2006
Posts: 11

You can try iText (http://sourceforge.net/projects/itext/files/ ) Java library to accomplish your task. Any issues while coding using it .. do share.


Ankur Kapoor

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41899
    
  63
iText has already been ruled in the original post for unknown reasons. It would be useful to know why it has been ruled out if we are to make further suggestions.


Ping & DNS - my free Android networking tools app
Mintu Mmazumder
Greenhorn

Joined: Aug 17, 2011
Posts: 10

Thanks for reply..one question : Can we get converted pdf from word as inputstream/byte array rather than saving in physical drive using doc.save.I am trying to use it.but if you have any idea please let me shame with


regards,
Mintu
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12789
    
    5
It will be easier to debug your application if you make use of a temporary disk file.

With the entire pdf in a file, you will be able to set the content-length header - in my experience it makes client browsers much happier if they get a content-length.

Bill
Mintu Mmazumder
Greenhorn

Joined: Aug 17, 2011
Posts: 10

As per situation & requirement,we are not in way to use temporary disk files.please suggests.We can't use external jar which have costs.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to convert word doc byte array into pdf programatically in struts action