Convert EXCEL,DOC,JPEG,PPT,BMP to PDF format using java code.

Category: , , , , ,

Perquisite to run this code,


1-Use Eclipse and java 1.5 or later
2-Download JODConvertor from the URL
3-http://code.google.com/p/jodconverter/downloads/list
4-Add all the jar file in lib directory of JODconvertor to your project.
5-Download Openoffice 3.0 from URL http://download.openoffice.org/other.html#tested-full
5-Install the Openoffice 3.0

Limitation
A:- It cannot be multi-threaded.
B:- It cannot convernt MULTI-TIFF images to PDF but it can convert single page TIFF to PDF.

import java.io.*;
import org.artofsolving.jodconverter.OfficeDocumentConverter;
import org.artofsolving.jodconverter.OfficeDocumentConverter.*;
import org.artofsolving.jodconverter.office.*;
import org.artofsolving.*;
import org.artofsolving.jodconverter.document.*;
import org.artofsolving.jodconverter.process.*;
import org.artofsolving.jodconverter.util.*;
public class Main {
public static void main(String[] args) throws Exception {
conversion();
}
public static void conversion(){
OfficeManager officeManager = new DefaultOfficeManagerConfiguration().buildOfficeManager();
officeManager.start();
OfficeDocumentConverter converter = new OfficeDocumentConverter(officeManager);
converter.convert(new File("C:/Temp/first.doc"), new File("C:/Temp/Doctest.pdf"));
officeManager.stop();
System.out.println("Hellow WOrld , its done");
}

Ask me if you are not able to run it.

Happy Conversion.

Comments (7)

did everything mentioned here, but the error is coming when the compiler is searching for the packages that you have included in the beginning

Mohit

How did you include all the packages to your project, if you right click on the project in eclipse and click on properties, it will open a window where you need to go into java build menu->lib tab , click on add external jar files and browse where these jars are and select all of them , it should work than. Let me know, i can send you the demo project if you need.

You can convert all the documents that you have mentioned in your topic using Aspose Online Converter in java and also in other languages. You can Convert excel file to PDF in java also using this converter.

You have shared an excellent way to convert JPG to PDF . I want to recommend this JPG to PDF converter because it is quite easy to use and affordable.

if you need choose the PDF and image conversion tools,you can try this pdf to image SDK for C#!

Thanks for this article it is a very nice n helpful for all the learners keep sharing article
convert xls to pdf

Thanks for this article it is a very nice n helpful for all the learners keep sharing article
convert xls to pdf

Post a Comment