Page 1 of 1

Converting Docx to PDF

PostPosted: Thu Aug 21, 2008 12:16 pm
by kayithala
While converting docx to PDF i am getting following exception.I added all required jars.

java.lang.NoClassDefFoundError: org/docx4j/openpackaging/packages/WordprocessingMLPackage

Source code is:

String inputfilepath = "c:/temp/DocxToPdfTest.docx";
FileOutputStream fos1=new FileOutputStream(inputfilepath);
fos1.write(byteArr);
fos1.close();
File file = new java.io.File("c:/temp/DoctoPDF2007.docx");
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(file);
String out="c:/temp/DocxToPdfTest.pdf";
java.io.File temp = new File(out);

OutputStream os = new java.io.FileOutputStream(temp);

wordMLPackage.pdf(os);
os.close();
com.sun.pdfview.PDFViewer pv = new com.sun.pdfview.PDFViewer(true);

pv.openFile(temp);


Please anyone help me where is the problem ..This is urgent for me.

Ramesh.K

Re: Converting Docx to PDF

PostPosted: Fri Aug 22, 2008 2:32 am
by jason
Hi Ramesh, The docx4j jar file needs to be on your classpath. .. Jason

Re: Converting Docx to PDF

PostPosted: Fri Aug 22, 2008 3:17 am
by kayithala
Hi jason,
Thankx for ur reply.
we have already set this jar (docx4j) in the classpath.but still its not recognizing.
we are using JDK1.5 will there any problem with this jdk version.my class not able to recognoze this "WordprocessingMLPackage" class

Regards
Ramesh.K

Re: Converting Docx to PDF

PostPosted: Fri Aug 22, 2008 6:17 am
by jason
we are using JDK1.5 will there any problem with this jdk version


currently there are a couple of problems with using JDK 1.5.

the first is that fop-fonts-0.1.jar was compiled targeting 1.6.

the second is that NamespacePrefixMapper imports com.sun.xml.internal.bind.marshaller (which is in 1.6).

If you must use 1.5, you'll need to use the svn sources, and put JAXB 2.0 or 2.1.6 on your classpath, then change the bind.marshaller package name.

If you are going to do this, I'll see if i can rebuild the fop-fonts-0.1.jar for you

Re: Converting Docx to PDF

PostPosted: Wed Nov 05, 2008 12:25 pm
by Alexandr-N
jason wrote:If you must use 1.5, you'll need to use the svn sources, and put JAXB 2.0 or 2.1.6 on your classpath, then change the bind.marshaller package name.

If you are going to do this, I'll see if i can rebuild the fop-fonts-0.1.jar for you


Hello jason!
I have to use java 1.5 in my current project, so I'm folowing your instructions and put JAXB 2.1 on my classpath, etc. :)
But i cant make it work because of two jars - commons-vfs-patched-1.1.jar and fop-fonts-0.1.jar.
Can you please rebuild these libs on java 1.5 for me?

Thanks in advance!

Re: Converting Docx to PDF

PostPosted: Fri Nov 07, 2008 8:50 am
by jason
Hi Alexandr. Quick note to say that fop-fonts-0.2.jar is now in our maven repository. You'll need to be working with current docx4j svn sources to use it. I'm still to convert commons-vfs-patched.jar, but hope to do that in the next day or so. cheers, Jason

Re: Converting Docx to PDF

PostPosted: Sat Nov 08, 2008 9:07 am
by jason
The docx4j pom now points to commons-vfs-patched v1.9.1 in webdavclient4j's m2 repository, which I believe was built with Java 1.5.

So docx4j should now work with Java 1.5. Let me know if you have any issues.

cheers

Jason