Re: Error trying pdf convert

1,148 views
Skip to first unread message

Angelo zerr

unread,
May 8, 2013, 11:20:14 AM5/8/13
to xdocr...@googlegroups.com
Hi,

I think you have a bad vesrion of ODFDOM in your classpath. Are you sure you use only the JARs provides in the zip samples https://code.google.com/p/xdocreport/downloads/list

Regards Angelo


2013/5/8 Vicent Blanes <r.pol...@gmail.com>
Hi all,

Am writting this because i were trying the example of your page to conver to pdf and am getting an error.
This is the example am trying: http://code.google.com/p/xdocreport/wiki/ODFDOMConverterPDFViaIText

First i get a syntax error that requires a cast (OdfTextDocument document =  OdfTextDocument.loadDocument(in);) then, when program start running i get the following error:

run:
Exception in thread "main" java.lang.VerifyError: (class: org/odftoolkit/odfdom/dom/DefaultElementVisitor, method: visit signature: (Lorg/odftoolkit/odfdom/dom/element/number/NumberDateStyleElement;)V) Incompatible argument to function
    at org.odftoolkit.odfdom.converter.pdf.PdfConverter.processStyles(PdfConverter.java:89)
    at org.odftoolkit.odfdom.converter.pdf.PdfConverter.doConvert(PdfConverter.java:61)
    at org.odftoolkit.odfdom.converter.pdf.PdfConverter.doConvert(PdfConverter.java:43)
    at org.odftoolkit.odfdom.converter.core.AbstractODFConverter.convert(AbstractODFConverter.java:42)
    at proves.convertirPDF.main(convertirPDF.java:37)
Java Result: 1

 
I have imported all JARS from XDocReport version (ex : 1.0.0) including iText library and it still not working. Probably i have a very basic error because am new to this but i don't found it yet. Apreciate any help :D

PD: Sorry for my bad english and congratulatios for XDocReport, so great tool.

Regards from Spain

--
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/groups/opt_out.
 
 

Message has been deleted

Vicent Blanes

unread,
May 8, 2013, 2:56:38 PM5/8/13
to xdocr...@googlegroups.com
Hi,

I was using other ODFDOM library as you said but now am getting an other error:
Using one of the converter samples "ConvertODTResumeToPDF"

 
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
 
import org.odftoolkit.odfdom.converter.pdf.PdfConverter;
import org.odftoolkit.odfdom.converter.pdf.PdfOptions;
import org.odftoolkit.odfdom.doc.OdfTextDocument;
 
import fr.opensagres.xdocreport.samples.odt.converters.Data;
 
public class ConvertODTResumeToPDF
{
 
    public static void main( String[] args )
    {
        long startTime = System.currentTimeMillis();
 
        try
        {
            // 1) Load odt with ODFDOM
            OdfTextDocument document = OdfTextDocument.loadDocument( Data.class.getResourceAsStream( "/tmp/enter.odt" ) );
 
            // 2) Convert ODFDOM OdfTextDocument 2 PDF with iText
            File outFile = new File( "/tmp/exit.pdf" );
            outFile.getParentFile().mkdirs();
 
            OutputStream out = new FileOutputStream( outFile );
            PdfOptions options = null;// PDFViaITextOptions.create().fontEncoding( "windows-1250" );
            PdfConverter.getInstance().convert( document, out, options );
        }
        catch ( Throwable e )
        {
            e.printStackTrace();
        }
 
        System.out.println( "Generate ODTResume.pdf with " + ( System.currentTimeMillis() - startTime ) + " ms." );
    }
}



am getting
java.lang.NullPointerException
Generate ODTResume.pdf with 95 ms.
    at org.odftoolkit.odfdom.pkg.StreamHelper.stream(StreamHelper.java:73)
    at org.odftoolkit.odfdom.pkg.StreamHelper.transformStream(StreamHelper.java:48)
    at org.odftoolkit.odfdom.pkg.OdfPackage.initializeZip(OdfPackage.java:313)
    at org.odftoolkit.odfdom.pkg.OdfPackage.<init>(OdfPackage.java:220)
    at org.odftoolkit.odfdom.pkg.OdfPackage.loadPackage(OdfPackage.java:275)
    at org.odftoolkit.odfdom.doc.OdfDocument.loadDocument(OdfDocument.java:219)
    at org.odftoolkit.odfdom.doc.OdfTextDocument.loadDocument(OdfTextDocument.java:150)
    at proves.convertirPDF.main(convertirPDF.java:25)

And if i change the  OdfTextDocument document = OdfTextDocument.loadDocument( Data.class.getResourceAsStream( "/tmp/enter.odt" ) ); for
 OdfTextDocument document = OdfTextDocument.loadDocument("/tmp/enter.odt");

I got this error


run:
May 08, 2013 11:50:52 AM org.odftoolkit.odfdom.pkg.OdfXMLFactory newOdfAttribute
INFO: None-ODF attribute created for style:contextual-spacing
May 08, 2013 11:50:52 AM org.odftoolkit.odfdom.pkg.OdfXMLFactory newOdfAttribute
INFO: None-ODF attribute created for style:contextual-spacing
May 08, 2013 11:50:52 AM org.odftoolkit.odfdom.pkg.OdfXMLFactory newOdfAttribute
INFO: None-ODF attribute created for style:contextual-spacing
May 08, 2013 11:50:52 AM org.odftoolkit.odfdom.pkg.OdfXMLFactory newOdfAttribute
INFO: None-ODF attribute created for style:contextual-spacing
May 08, 2013 11:50:52 AM org.odftoolkit.odfdom.pkg.OdfXMLFactory newOdfAttribute
INFO: None-ODF attribute created for style:contextual-spacing
May 08, 2013 11:50:52 AM org.odftoolkit.odfdom.pkg.OdfXMLFactory newOdfAttribute
INFO: None-ODF attribute created for style:contextual-spacing
May 08, 2013 11:50:52 AM org.odftoolkit.odfdom.pkg.OdfXMLFactory newOdfAttribute
INFO: None-ODF attribute created for style:contextual-spacing
May 08, 2013 11:50:52 AM org.odftoolkit.odfdom.pkg.OdfXMLFactory newOdfAttribute
INFO: None-ODF attribute created for style:contextual-spacing
May 08, 2013 11:50:52 AM org.odftoolkit.odfdom.pkg.OdfXMLFactory newOdfAttribute
INFO: None-ODF attribute created for style:contextual-spacing
May 08, 2013 11:50:52 AM org.odftoolkit.odfdom.pkg.OdfXMLFactory newOdfAttribute
INFO: None-ODF attribute created for style:contextual-spacing
May 08, 2013 11:50:52 AM org.odftoolkit.odfdom.pkg.OdfXMLFactory newOdfAttribute
INFO: None-ODF attribute created for style:contextual-spacing
May 08, 2013 11:50:52 AM org.odftoolkit.odfdom.pkg.OdfXMLFactory newOdfAttribute
INFO: None-ODF attribute created for style:contextual-spacing
May 08, 2013 11:50:52 AM org.odftoolkit.odfdom.pkg.OdfXMLFactory newOdfAttribute
INFO: None-ODF attribute created for style:contextual-spacing
May 08, 2013 11:50:52 AM org.odftoolkit.odfdom.pkg.OdfXMLFactory newOdfAttribute
INFO: None-ODF attribute created for style:contextual-spacing
May 08, 2013 11:50:52 AM org.odftoolkit.odfdom.pkg.OdfXMLFactory newOdfAttribute
INFO: None-ODF attribute created for officeooo:paragraph-rsid
May 08, 2013 11:50:52 AM org.odftoolkit.odfdom.pkg.OdfXMLFactory newOdfAttribute
INFO: None-ODF attribute created for style:contextual-spacing
May 08, 2013 11:50:52 AM org.odftoolkit.odfdom.pkg.OdfXMLFactory newOdfAttribute
INFO: None-ODF attribute created for style:contextual-spacing
May 08, 2013 11:50:52 AM org.odftoolkit.odfdom.pkg.OdfXMLFactory newOdfAttribute
INFO: None-ODF attribute created for style:contextual-spacing
May 08, 2013 11:50:52 AM org.odftoolkit.odfdom.pkg.OdfXMLFactory newOdfAttribute
INFO: None-ODF attribute created for style:contextual-spacing
May 08, 2013 11:50:52 AM org.odftoolkit.odfdom.pkg.OdfXMLFactory newOdfAttribute
INFO: None-ODF attribute created for officeooo:paragraph-rsid
May 08, 2013 11:50:52 AM org.odftoolkit.odfdom.pkg.OdfXMLFactory newOdfAttribute
INFO: None-ODF attribute created for officeooo:rsid
org.odftoolkit.odfdom.converter.core.ODFConverterException: java.lang.NullPointerException
Generate ODTResume.pdf with 2853 ms.
    at org.odftoolkit.odfdom.converter.pdf.PdfConverter.doConvert(PdfConverter.java:82)

    at org.odftoolkit.odfdom.converter.pdf.PdfConverter.doConvert(PdfConverter.java:43)
    at org.odftoolkit.odfdom.converter.core.AbstractODFConverter.convert(AbstractODFConverter.java:42)
    at proves.convertirPDF.main(convertirPDF.java:33)
Caused by: java.lang.NullPointerException
    at org.odftoolkit.odfdom.converter.pdf.internal.ElementVisitorForIText.<init>(ElementVisitorForIText.java:136)
    at org.odftoolkit.odfdom.converter.pdf.PdfConverter.processBody(PdfConverter.java:114)
    at org.odftoolkit.odfdom.converter.pdf.PdfConverter.doConvert(PdfConverter.java:65)
    ... 3 more
BUILD SUCCESSFUL (total time: 3 seconds)

And a corrupted pdf on my /tmp/ folder.
Am still searching for a solution. Thanks for your time and sorry for my double post.

Regars Vicent.

Jan Hahnisch

unread,
May 8, 2013, 3:44:14 PM5/8/13
to xdocr...@googlegroups.com
hi, 

I think it is at your pdfoptions. You have to give an instance of pdfoptions ( even an empty one) And not null. (you got an npe because of this).

The rest seems to be valid.

Kind regards

Jan 

Vicent Blanes

unread,
May 8, 2013, 3:57:26 PM5/8/13
to xdocr...@googlegroups.com
Thank you, it works :D (was so blind with this null)
I appreciate so much the quickness you all respond.

Regards, Vicent
Reply all
Reply to author
Forward
0 new messages