There is always challenge to convert Microsoft office document to PDF document through open source. I had also some issue when I was working one of the projects and converting Microsoft word doc or Microsoft power point document to pdf document through open source. Here are some steps to convert Microsoft word document or Microsoft power point document to pdf document through Java application and open source.
Prerequisite Requirements for conversion
1.) JDK(1.5+)
2.) Open office version-2.02+(Download from “http://www.openoffice.org/”)
3.) jodconverter2.2.2 (Download from “http://sourceforge.net/projects/jodconverter/files/”)
Here are steps:-
1.) install JDK(1.5+) and Open office version-2.02 in your local machine.
2.) Go to <Open office install folder>/ program/ folder
3.) Run this command through MS dos window.
soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard
4.) Now write the given java code and run
- import java.io.File;
- import com.artofsolving.jodconverter.DocumentConverter;
- import com.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection;
- import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection;
- import com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter;
- public class MsDocToPdfUtil {
- public static void convertDocToPdf(){
- try {
- File in = new File("C:/test.doc");
- OpenOfficeConnection connection = new SocketOpenOfficeConnection(8100);
- connection.connect();
- DocumentConverter converter = new OpenOfficeDocumentConverter(connection);
- File outPutFile = new File("C:/test.pdf");
- converter.convert(in,outPutFile);
- connection.disconnect();
- }catch(Exception ex){
- ex.printStackTrace();
- }
- }
- public static void main(String[] args) {
- try {
- convertDocToPdf();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- }

Rajnish Kumar, the CTO of Vanrish Technology, brings over 25 years of experience across various industries and technologies. He has been recognized with the “AI Advocate and MuleSoft Community Influencer Award” from the Salesforce/MuleSoft Community, showcasing his dedication to advancing technology. Rajnish is actively involved as a MuleSoft Mentor/Meetup leader, demonstrating his commitment to sharing knowledge and fostering growth in the tech community.
His passion for innovation shines through in his work, particularly in cutting-edge areas such as APIs, the Internet Of Things (IOT), Artificial Intelligence (AI) ecosystem, and Cybersecurity. Rajnish actively engages with audiences on platforms like Salesforce Dreamforce, World Tour, Podcasts, and other avenues, where he shares his insights and expertise to assist customers on their digital transformation journey.