Friday, May 29, 2009

Convert word,excel an power point to PDF using JAVA API

Today i will Let you guys now how to convert the word,powerpoint,excel formats to PDF.
Apache has a Java API, called POI, that allows you to access Microsoft formats from within Java. It looks handy, but I found some people complaining about the complexity of it. Some further searching turned up mention of something called JODConverter. This is a fantastic project.
JODConverter is essentially a Java library that utilizes OpenOffice’s conversion engine to convert to and from any format that OpenOffice supports. This includes Word, Excel, PowerPoint, RTF, Plain Text, etc.
I decided to see how easy it was going to be to use this library. Let’s face it, a lot of these open source projects claim to do all kinds of great things, but do not provide the greatest results. So, I created a small test project and wrote a simple class. Here’s what it looks like:
public class convertFile {
public static void main(String[] args) {
File inputFile = new File("resume-2.doc");
      File outputFile = new File("resume-2.pdf");
     OpenOfficeConnection connection = new SocketOpenOfficeConnection(8100);
     try {
        connection.connect();
     } catch(Exception e) {
     }

DocumentConverter converter = new OpenOfficeDocumentConverter(connection);
     converter.convert(inputFile, outputFile);

connection.disconnect();

}
}

Obviously, there’s error-checking that is lacking. For example, the convert() method should be wrapped to ensure that a failed conversion doesn’t blow up your application, and something should be done if an exception is caught on the connection. However, this is the basic skeleton. Pretty cool.
Basically, all this does is open a connection to OpenOffice, create a converter, and pass in the files to convert. JODConverter and OpenOffice handle everything else.
The only caveat to this is that OpenOffice must be installed on the server and must be running as a headless app (the JODConverter README file explains how to do this). While that may not be ideal, it’s probably worth it for the amazing results this library provides.
Great tool, highly recommended.

Regards,
Ali Vajahat
Software Engineer
Software Innovations
Lahore Pakistan

45 comments:

Anonymous said...

Hey,

When ever I surf on web I come to this website[url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips].[/url]vajahatalee.blogspot.com really contains lot of useful information. Do you pay attention towards your health?. Are you really serious about your weight?. Recent Scientific Research shows that almost 80% of all USA grownups are either chubby or weighty[url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips].[/url] Therefore if you're one of these people, you're not alone. In fact, most of us need to lose a few pounds once in a while to get sexy and perfect six pack abs. Now next question is how you can achive quick weight loss? Quick weight loss can be achived with little effort. You need to improve some of you daily habbits to achive weight loss in short span of time.

About me: I am webmaster of [url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips]Quick weight loss tips[/url]. I am also health expert who can help you lose weight quickly. If you do not want to go under painful training program than you may also try [url=http://www.weightrapidloss.com/acai-berry-for-quick-weight-loss]Acai Berry[/url] or [url=http://www.weightrapidloss.com/colon-cleanse-for-weight-loss]Colon Cleansing[/url] for effective weight loss.

Miral said...

Also if you keep your excel column narrow it will not print to pdf those hidden text

Anonymous said...

With havin so much content do you ever run into
any issues of plagorism or copyright violation? My blog has a lot of unique content I've either written myself or outsourced but it appears a lot of it is popping it up all over the internet without my permission. Do you know any ways to help prevent content from being stolen? I'd definitely appreciate it.
Here is my website :: click the next webpage

Anonymous said...

Have you ever thought about publishing an ebook or guest authoring on other websites?
I have a blog based upon on the same ideas you discuss and would really like to
have you share some stories/information. I know my
readers would value your work. If you're even remotely interested, feel free to send me an e-mail.
Also visit my homepage : porn

Anonymous said...

Magnificent beat ! I wish to apprentice while you amend your site, how could i subscribe for a blog web site?
The account aided me a acceptable deal. I had been tiny bit acquainted of this your broadcast provided bright clear concept
my page > Another Outstanding Teen Ass

Anonymous said...

Do you have a spam issue on this site; I also am a blogger,
and I was wanting to know your situation; we have created some nice methods and we are looking
to exchange solutions with other folks, why not shoot me an email if interested.
Also visit my web page ... cam star porn

Anonymous said...

Do you have a spam issue on this site; I also am a blogger, and I was wanting to
know your situation; we have created some nice methods and
we are looking to exchange solutions with other folks,
why not shoot me an email if interested.
my site :: cam star porn

Anonymous said...

Hi to all, the contents existing at this website are truly remarkable for people knowledge, well, keep up the nice work fellows.
Also see my webpage: http://www.daily-wet-tshirt.com/

Anonymous said...

you're in reality a good webmaster. The web site loading pace is incredible. It seems that you are doing any distinctive trick. Also, The contents are masterwork. you have performed a magnificent activity in this matter!
My web-site ; free teen porn

Anonymous said...

First of all I want to say superb blog! I had a quick question in which I'd like to ask if you do not mind. I was interested to find out how you center yourself and clear your mind prior to writing. I have had difficulty clearing my mind in getting my ideas out there. I truly do enjoy writing but it just seems like the first 10 to 15 minutes are usually lost just trying to figure out how to begin. Any recommendations or tips? Thank you!
My web blog ; nude teens

Anonymous said...

I'm not sure why but this site is loading incredibly slow for me. Is anyone else having this problem or is it a problem on my end? I'll check back later on and see
if the problem still exists.
Also see my site > naked girls

Anonymous said...

My brother suggested I might like this website. He was totally right.
This post truly made my day. You cann't imagine simply how much time I had spent for this information! Thanks!
Also see my web site - Orlando Fl contractor

Anonymous said...

Excellent goods from you, man. I have keep in mind your stuff
prior to and you are just extremely great. I
really like what you have obtained right here, certainly like what you're saying and the way by which you assert it. You're making it enjoyable and
you continue to care for to keep it wise. I can not wait to learn far more
from you. This is really a wonderful site.
my web site: Orlando fl hookah lounge

Anonymous said...

Heya! I understand this is sort of off-topic but I had to
ask. Does running a well-established website like yours take a large amount
of work? I am brand new to blogging but I do write in my diary every day.
I'd like to start a blog so I can share my personal experience and views online. Please let me know if you have any suggestions or tips for brand new aspiring bloggers. Thankyou!
Also visit my page - lanautica

Anonymous said...

Malaysia & Singapore & brunei ultimate on the internet
blogshop for wholesale & quantity korean add-ons, accessories, earstuds,
choker, rings, bangle, hair & trinket accessories.

Promotion 35 % wholesale markdown. Ship Worldwide
Also see my webpage: brain games iphone

Anonymous said...

Malaysia & Singapore & brunei finest on the internet blogshop for
wholesale & supply korean add-ons, earrings, earstuds, pendant,
rings, bracelet, hair & trinket add-ons. Deal 35
% wholesale rebate. Ship Worldwide
Also see my web page :: locksmith slc

Anonymous said...

gay dating app http://loveepicentre.com/articles.php over 50 women on line dating

Anonymous said...

I really like what you guys tend to be up too.
This kind of clever work and reporting! Keep up the very
good works guys I've incorporated you guys to my blogroll.
My web page Luis Souto ecommerce projects handled lanautica.com

Anonymous said...

great points altogether, you just gained a new reader.
What may you suggest about your put up that you made some days ago?
Any positive?
My page: Luis Souto ecommerce projects handled charter

Anonymous said...

Amazing blog! Do you have any hints for aspiring writers?
I'm hoping to start my own site soon but I'm a little lost on everything.

Would you advise starting with a free platform like Wordpress or go for a
paid option? There are so many choices out there
that I'm totally confused .. Any recommendations? Thanks a lot!
My page :: Gambling

Anonymous said...

After getting more than 10000 visitors/day to my website I thought your vajahatalee.blogspot.com website also need unstoppable flow of traffic...

Use this BRAND NEW software and get all the traffic for your website you will ever need ...

= = > > http://get-massive-autopilot-traffic.com

In testing phase it generated 867,981 visitors and $540,340.

Then another $86,299.13 in 90 days to be exact. That's $958.88 a
day!!

And all it took was 10 minutes to set up and run.

But how does it work??

You just configure the system, click the mouse button a few
times, activate the software, copy and paste a few links and
you're done!!

Click the link BELOW as you're about to witness a software that
could be a MAJOR turning point to your success.

= = > > http://get-massive-autopilot-traffic.com

Anonymous said...

care of praying mantis young ebook http://audiobookscollection.co.uk/es/Shenghua-Xu/m116530/ the lovely bones free ebook [url=http://audiobookscollection.co.uk/it/Sanit-pubblica/c3079/?page=4]ebook store canada[/url] educational filp ebook

Anonymous said...

ebook raw http://audiobookscollection.co.uk/Book-3-Shopaholic-Ties-the-Knot-Shopaholic/p19596/ ebook how to draw mickey mouse [url=http://audiobookscollection.co.uk/fr/George-J-Rhino-Thompson/m42627/]sony connect ebook promotion codes[/url] free ebook the new revelations

Anonymous said...

ipod ebook maker http://audiobooksworld.co.uk/Rama-II/p206656/ free online ebook charlotte's web [url=http://audiobooksworld.co.uk/Come-Dio-Comanda/p222744/]ebook mobi drm[/url] new moon stephenie meyer free ebook

Anonymous said...

ebook torrent search http://audiobooksworld.co.uk/David-E-Runkle-Cfa/m26614/ limites a los hijos ebook moreno [url=http://audiobooksworld.co.uk/T-Colin-Campbell/m122178/]computational fluid dynamics ebook[/url] itil v3 torrent ebook

Anonymous said...

If you want to get a good deal from this article then you have to apply these methods to your won
website.

Feel free to surf to my webpage ... Visit site

Anonymous said...

[url=http://onlinemedistore.com/products/frozen--energy-and-libido-enhancer-.htm][img]http://onlinemedistore.com/12.jpg[/img][/url]
fallons pharmacy schenectady ny http://onlinemedistore.com/products/innopran-xl.htm lake underhill pharmacy [url=http://onlinemedistore.com/products/coumadin.htm]pharmacy for pet medicine[/url]
pharmacy techican second edition http://onlinemedistore.com/products/crestor.htm giant food store pharmacy [url=http://onlinemedistore.com/products/baclofen.htm]baclofen[/url]
pharmacy boric acid http://onlinemedistore.com/products/leukeran.htm pharmacy and therapeutics [url=http://onlinemedistore.com/products/imuran.htm]strength of guardian pharmacy[/url]
ia board of pharmacy http://onlinemedistore.com/products/sinemet.htm online pharmacy zocor [url=http://onlinemedistore.com/products/bystolic.htm]bystolic[/url]

Anonymous said...

I needed to thank you for this great read!

! I definitely enjoyed every little bit of it. I have got you saved as a favorite to
look at new things you post…

My webpage ... "destroyer"

Anonymous said...

I used to be able to find good advice from your articles.


Also visit my webpage: tour packages in thailand

Anonymous said...

I've been surfing online more than 3 hours nowadays, but I never discovered any interesting article like yours. It's lovely
price sufficient for me. Personally, if all webmasters and
bloggers made good content as you did, the net will likely be much
more useful than ever before.

Review my website: www.learnpaintlessdentremoval.com

Anonymous said...

Hi there very nice web site!! Guy .. Excellent .. Wonderful .
. I will bookmark your web site and take the feeds additionally?

I'm satisfied to seek out a lot of useful info right here within the put up, we want work out more techniques in this regard, thank you for sharing. . . . . .

My blog - www.learnpaintlessdentremoval.com

Anonymous said...

Now that I've just spent five hours on your website reading your posts, I'm absolutely hοоked on yоur blοg.
I saved it as a fаvorіte it to my bookmaгk websіte list and will be checking back in the near future.
Check out my own peгsonal blοg іf уou get the chance and give me уоur
thoughtѕ..

Mу homepage :: judicature

Anonymous said...

I really like your blog.. very nice colors & theme. Did you design
this website yourself or did you hire someone to do it for you?
Plz reply as I'm looking to construct my own blog and would like to know where u got this from. thank you

My page; Ass Videos Free XXX Videos

Anonymous said...

Greetings! This is my 1st comment here so I just wanted to give a quick shout
out and say I genuinely enjoy reading your blog
posts. Can you suggest any other blogs/websites/forums that go over the same subjects?
Many thanks!

Here is my website: roboticsworld.org

Anonymous said...

Hey very interesting blog!

Feel free to surf to my web blog VigRX Oil

Anonymous said...

I'm now not sure where you're getting your
information, however great topic. I needs to spend some time studying more or understanding more.
Thank you for excellent info I was on the lookout for this information for my mission.


My website ... http://www.69videosporno.net/amateur-teen-babes-hot-horny-three-way/

Anonymous said...

hello!,I like your authorship extremely so a great deal!
proportion we be in contact much more approximately your article on AOL?
I require an expert on this space to fix my problem.

Possibly that's you! Having a look forward to see you.

Feel free to surf to my site earning money online

Anonymous said...

I enjoy reading through a post that can make men and women think.
Also, many thanks for allowing me to comment!



Also visit my web-site; hair removal

Anonymous said...

Hello There. I discovered your weblog using msn.
That is an extremely smartly written article.
I'll be sure to bookmark it and come back to learn extra of your helpful info. Thanks for the post. I will definitely comeback.

my blog post http://www.babesflick.com/video/10760/webcam-babe-rubbing-her-juicy-wet-slit-for-fans.html

Anonymous said...

wow, awesome posting, I was curious simple tips to
cure acne naturally and found your site. many
userful information below, right now i'm a chunk obvious. I've bookmark your site.
keep you up-to-date.

Feel free to visit my page; Acne Pimple Natural Treatment

Anonymous said...

I simply could not go away your website before suggesting that I really
loved the usual information a person provide to your guests?

Is gonna be again incessantly in order to investigate cross-check new posts

Also visit my blog post http://www.sbwire.com/press-releases/the-truth-about-cellulite-review-kick-butt-cellulite-redux-new-information-released-247680.
htm - -

Anonymous said...

Please let me know if you're looking for a article writer for your weblog. You have some really good posts and I think I would be a good asset. If you ever want to take some of the load off, I'd really like to write some articles for your blog in exchange for
a link back to mine. Please blast me an email if interested.
Regards!

My webpage; dermefface fx7 [http://www.click4article.com/article.php?id=40300]

Zarfishan Zahid said...

There is another great converter that i have come ac-crossed is Aspose.Cells for Java using which you can convert your excel document to pdf in java.

George Mousavi said...

Excel training NY is known for its best teaching for Ms Excel. They clear each basics of their students.

Ramiro Arizpe said...

Hi,
Whant can I do to this error?

java.net.ConnectException: connection failed: socket,host=localhost,port=8100,tcpNoDelay=1: java.net.ConnectException: Connection refused: connect

I don't have idea what connection is talking about.

Thanks, Regards.