when running my code it gives the following error: Could not find docmosis.properties. I've placed this file in the root folder of my project. I'm using Netbeans. Here's my code:
SystemManager.initialise();
TemplateIdentifier templateId = new TemplateIdentifier("test");
ConversionInstruction instruction = new ConversionInstruction();
instruction.setConverterGroupName("batch1");
instruction.setConversionFormats(new ConversionFormat[]{
ConversionFormat.FORMAT_PDF,});
instruction.setOutputFileName("out.pdf");
DataProviderBuilder dpb = new DataProviderBuilder();
// add the name of the project
dpb.add("hallo", "Deisel Institute");
File out = new File("template/out.pdf");
FileOutputStream fos = new FileOutputStream(out);
try {
DocumentProcessor.renderDoc(templateId, dpb.getDataProvider(), instruction, fos);
SystemManager.release();
} catch (IOException ex) {
Logger.getLogger(pdfGen.class.getName()).log(Level.SEVERE, null, ex);
} catch (ProcessingException ex) {
Logger.getLogger(pdfGen.class.getName()).log(Level.SEVERE, null, ex);
} catch (TemplateStoreException ex) {
Logger.getLogger(pdfGen.class.getName()).log(Level.SEVERE, null, ex);
}
- Select your project and right-click -> Properties
- Select Sources then click Add Folder
- go into src folder and find the folder containing docmosis.properties, then click Open
- You should see the folder added to your Source Package Folders
- Click ok
- Run your project
- <pre>
- // one-off initialise
- SystemManager.initialise();
- // do lots of renders
- DataProviderBuilder dpb = new DataProviderBuilder();
- dpb.add("hallo", "Deisel Institute");
- File templateFile = new File("/projectA/AnalysisTemplate.doc");
- File resultFile = new File("/projectA/AnalysisResult.pdf");
- DocumentProcessor.renderDoc(templateFile, resultFile, dpb.getDataProvider());
- // one-off release
- SystemManager.release();
- </pre>
- Your code doesn't show you "registering" the template so this example won't work as it stands. You can either use the abbreviated code above, or follow the pattern in the example in the JavaDoc for the DocumentProcessor class (see the API in the Docmosis Support Area)
- in normal use you wouldn't call
SystemManager.release()after rendering a single document. You should only call that when your application is exiting. - don't forget to close your your FileOutputStream (
fos)
Hi,
Your 6 points solution that you give for Netbeans is ok to add docmosis properties source folder (example : src\app\resources in my case).
But after, this not work at run time whit this :
java -splash:splash1.png -cp dist/SAFdemo.jar;app/resources/ app.App -Xms32m -Xmx512m -Xss32m
The program start. All is ok. But docmosis.properties file is never found !
Any solution ? Thanks.
What platform are you using?
If it is unix/linux/mac, then your -cp looks wrong. You should use the ":" character not the ";" character to separate entries.
Is this the problem?
I use Windows XP.
Finally this work with the line below :
java -splash:splash1.png -Xms32m -Xmx512m -Xss32m -cp .;SAFdemo.jar app.App
but docmosis files are "out of the jar" for modifications facilities (in Netbeans packaging: **/*.java,**/*.form,*.properties,*.xml) and must be in the root of the distribution.
Thanks for your answer.
Docmosis looks for the docmosis.properties (and converterPoolConfig.xml) file in the ROOT of any entry of the class path. This means you can put the docmosis.properties file into the current directory, a specified directory or inside a jar file, as long as the matching location is in your classpath.
For example, if you build your resource files into resources.jar, and you made sure docmosis.properties was inside the resources.jar file (at the "top level") then Docmosis will find it if you have "-cp resources.jar;..." on the java command line.
Also, in the original example, as long as "app/resources" contains docmosis.properties and "app/resources" was visible from where you are running the java command, the command will work. Perhaps you needed to literally qualify the path:
java -splash:splash1.png -cp dist/SAFdemo.jar;c:/myfolder/app/resources -Xms32m -Xmx512m -Xss32m app.App
