This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Mintu Mmazumder
Greenhorn
Posts: 10
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.


 
Shahzad Latif
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ankur Kapoor
Greenhorn
Posts: 11
Java Postgres Database Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can try iText (http://sourceforge.net/projects/itext/files/ ) Java library to accomplish your task. Any issues while coding using it .. do share.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Mintu Mmazumder
Greenhorn
Posts: 10
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13061
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic