Dear all,
I am working in a tool that should be generating a OpenDocument Reports
and some custom documentation from templates.
Currently I need insert (include) a document to be inserted in another
document.
I wrote that below function,
public void includeFile (String filePath) throws Exception {
OdfPackageDocument newDocument;
try {
newDocument =
OdfPackageDocument.loadDocument(filePath);
insertDocument(newDocument, "");
} catch (Exception exception) {
throw new Exception ("Failed to include the file:
" + filePath, exception);
}
}
When I executed it gives me the following exception:
java.lang.IllegalArgumentException: The internalPath given by parameter is
an empty string!
at org.odftoolkit.odfdom.pkg.OdfPackage.normalizeFilePath(
OdfPackage.java:1832)
at org.odftoolkit.odfdom.pkg.OdfPackage.insert(
OdfPackage.java:1375)
at org.odftoolkit.odfdom.pkg.OdfPackage.insertDocument(
OdfPackage.java:1095)
at org.odftoolkit.odfdom.pkg.OdfPackageDocument.insertDocument(
OdfPackageDocument.java:269)
at com.ibm.docgen.odf.workproduct.TextWorkProduct.includeFile(
TextWorkProduct.java:147)
I don't know what path I should include for the insertDocument () call
what should be this path? The documentation of the insertDocument is as
following:
/**
* Embed an OdfPackageDocument to the current OdfPackageDocument.
All the
* file entries of child document will be embedded as well to the
current
* document package.
*
* @param newDocument the OdfPackageDocument to be embedded.
* @param documentPath to the directory the ODF document should be
inserted
* (relative to the root of this document).
*/
public void insertDocument(OdfPackageDocument newDocument, String
documentPath) {
newDocument.flushDoms();
mPackage.insertDocument(newDocument,
mDocumentPathInPackage + documentPath);
}
But I still didn't understand which directory I should include its path or
what should be the documentPaht value? Is it the full path of the
sourceFile, or is it the directory of the destination document.
On the other hand, when I modified the call to this method to be
insertDocument(newDocument, "Introduction");
The document created but it didn't show the inserted contents of the
inserted document. When I opened the generated document using Zip tool,
there was a new folder created called (Introduction) and it includes its
contents.
So how should I make the contents inserted to appear? What am I missing?
Thanks & Best Regards / السلام عليكم
Ahmed Ibrahim
MBA ,Senior IT Architect, SWG Cairo Lab Services
BPM Client Solution Manager, MEA
IT Architect Egypt Profession Lead
Mobile: +20 100 1615 506