Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

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

 
Greenhorn
Posts: 10
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.


 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 11
Postgres Database Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 43028
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
eat bricks! HA! And here's another one! And a tiny ad!
The trailboss has a kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic