It may be obvious but can someone help. The project compiles fine the error occurs at run-time:
12-02 06:56:36.871: I/dalvikvm(1121): Could not find method org.docx4j.openpackaging.packages.WordprocessingMLPackage.createPackage,
referenced from method com.example.datadevheadlines.DeclerationCreator.makeIt
12-02 06:56:36.871: W/dalvikvm(1121): VFY: unable to resolve static method 9664: Lorg/docx4j/openpackaging/packages/WordprocessingMLPackage;.createPackage ()
Lorg/docx4j/openpackaging/packages/WordprocessingMLPackage;
12-02 06:56:36.881: D/dalvikvm(1121): VFY: replacing opcode 0x71 at 0x002c
12-02 06:56:36.881: W/dalvikvm(1121): VFY: unable to resolve exception class 1281 (Lorg/docx4j/openpackaging/exceptions/InvalidFormatException;)
12-02 06:56:36.881: W/dalvikvm(1121): VFY: unable to find exception handler at addr 0x42
12-02 06:56:36.881: W/dalvikvm(1121): VFY: rejected Lcom/example/datadevheadlines/DeclerationCreator;.makeIt (Landroid/view/View;)V
12-02 06:56:36.921: W/dalvikvm(1121): VFY: rejecting opcode 0x0d at 0x0042
12-02 06:56:36.921: W/dalvikvm(1121): VFY: rejected Lcom/example/datadevheadlines/DeclerationCreator;.makeIt (Landroid/view/View;)V
12-02 06:56:36.921: W/dalvikvm(1121): Verifier rejected class Lcom/example/datadevheadlines/DeclerationCreator;
12-02 06:56:36.921: W/dalvikvm(1121): Class init failed in newInstance call (Lcom/example/datadevheadlines/DeclerationCreator;)
All docx4j and dependency jars are all in a user library.
I think I have solved the error by copying the jars into the /lib folder now I get the following error:
Conversion to Dalvik format failed with error 1. The code I am attempting to run is:
WordprocessingMLPackage wordMLPackage = null;
try {
wordMLPackage = WordprocessingMLPackage.createPackage();
} catch (InvalidFormatException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
wordMLPackage.getMainDocumentPart().addParagraphOfText("Hello Word!");
try {
String path = Environment.getExternalStorageDirectory().toString() + "/HelloWord1.docx";
File file = new File(path);
try {
file.createNewFile();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
wordMLPackage.save(file);
} catch (Docx4JException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
UPDATE!!!!!!!!!!!!
I gave up on doc4jx and didn't want to pay for itext and so used PrintedPdfDocument as the document I want is a fixed template it is sufficient enough for my needs. Anything dynamic be a problem. Basically used a layout frame as a canvas and positioned all my texts and headings as relevant and then printed it to a pdf.
A problem I found was that having the text at a visible size meant on a A4 pdf one word would cover a big chunk of the page so I had to make the text 4sp and 7sp so that it would fit perfectly and had to have a centeralised layout frame that didn't fill the activity frame.
Anybody know a easier way of scaling the layout to an A4 size without having to shrink it into a zoomed out preview?