Convert Docx to PDF

551 views
Skip to first unread message

Maurice Tadros

unread,
Aug 28, 2014, 6:17:08 PM8/28/14
to xdocr...@googlegroups.com
Hello all,

With the following code fails when I pass an docx file.  The variable file is of type File and contains the file of interest.

import fr.opensagres.xdocreport.converter.ConverterTypeTo;
import fr.opensagres.xdocreport.converter.Options;
import fr.opensagres.xdocreport.converter.docx.poi.itext.XWPF2PDFViaITextConverter;
import fr.opensagres.xdocreport.core.document.DocumentKind;



   
  FileInputStream in = new FileInputStream(file);


 
Options options = Options.getFrom(DocumentKind.DOCX).to(ConverterTypeTo.PDF);


   
ByteArrayOutputStream out = new ByteArrayOutputStream();
   
   
// Fails here
   XWPF2PDFViaITextConverter
.getInstance().convert(in, out, options);


   
byte[] bytes = out.toByteArray();
   
out.close();



Any suggestions.  Cheers,
Maurice

Angelo zerr

unread,
Aug 28, 2014, 6:41:15 PM8/28/14
to xdocr...@googlegroups.com
Hi Maurice,

Please give us your stack trace. 

"code fails" is not really helpful.

Regard's Angelo


--
You received this message because you are subscribed to the Google Groups "xdocreport" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xdocreport+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Maurice Tadros

unread,
Aug 28, 2014, 8:40:13 PM8/28/14
to xdocr...@googlegroups.com
Hi Angelo,

Thank you for your quick response.  Sorry you are correct I should have attached my stack trace.  I also attached the file I'm trying to convert.  

Cheers


Error handler 
  • e = {java.lang.NoSuchMethodError@19743}"java.lang.NoSuchMethodError: com.lowagie.text.pdf.PdfPRow.getCells()[Lcom/lowagie/text/pdf/PdfPCell;"
  • detailMessage = {java.lang.String@21461}"com.lowagie.text.pdf.PdfPRow.getCells()[Lcom/lowagie/text/pdf/PdfPCell;"
  • cause = {java.lang.NoSuchMethodError@19743}"java.lang.NoSuchMethodError: com.lowagie.text.pdf.PdfPRow.getCells()[Lcom/lowagie/text/pdf/PdfPCell;"
  • stackTrace = {java.lang.StackTraceElement[0]@21462}
  • suppressedExceptions = {java.util.Collections$UnmodifiableRandomAccessList@21463} size = 0 

Stack
  • ():300, Hashtable {java.util} 
  • init():149, OPCPackage {org.apache.poi.openxml4j.opc} 
  • ():141, OPCPackage {org.apache.poi.openxml4j.opc} 
  • ():54, Package {org.apache.poi.openxml4j.opc} 
  • ():82, ZipPackage {org.apache.poi.openxml4j.opc} 
  • open():228, OPCPackage {org.apache.poi.openxml4j.opc} 
  • open():39, PackageHelper {org.apache.poi.util} 
  • ():120, XWPFDocument {org.apache.poi.xwpf.usermodel} 
  • convert():66, XWPF2PDFViaITextConverter {fr.opensagres.xdocreport.converter.docx.poi.itext}
Example_of_a_word_document.docx

Angelo zerr

unread,
Aug 28, 2014, 8:50:06 PM8/28/14
to xdocr...@googlegroups.com
Are you sure that you are using iText 2.1.7?

I suggest you that you download our sample at https://code.google.com/p/xdocreport/downloads/list and you use the same library than you will find in the zip.

Maurice Tadros

unread,
Aug 28, 2014, 10:20:13 PM8/28/14
to xdocr...@googlegroups.com
I am using iText 2.1.0

I'll update the new version and give it a try.  Thanks.
Reply all
Reply to author
Forward
0 new messages