I've been using the free version of Spire.Doc to convert from .Doc to .Pdf. The identical application seems to work on one server, but not on another. But are running Ubuntu 20.04.
At first I got an exception:
- Code: Select all
java.lang.NoSuchMethodError: 'com.spire.license.Assembly com.spire.license.LicenseProvider.validateVarAndGetInfo(java.lang.String)'
at com.spire.doc.Document.spr (Unknown Source)
at com.spire.doc.Document.<init>(Unknown Source)
But for some reason, I haven't seen this exception again.
I searched for the error and found a thread saying two spire products can't co-exist in the same project, I was using spire.xls and spire.doc (they seem to coexist on my project on another server though). So I switched to spire.office instead in the pom.xml. But this didn't help.
The code i'm using is following, it should transform a .doc to .pdf and let me download it, but it only saves a 0 byte .pdf file.
- Code: Select all
FileOutputStream outTmpStream = null;
com.spire.doc.Document document = new com.spire.doc.Document();
try {
String tmpPath = System.getProperty("java.io.tmpdir") +
"/tmp_pdf_export_"+ (int) Math.round(Math.random()*100000);
String outDocFilePath = tmpPath + ".doc";
outTmpStream = new FileOutputStream(outDocFilePath);
doc.write(outTmpStream);
outTmpStream.close();
doc.close();
document.loadFromFile(outDocFilePath);
document.saveToStream(out, FileFormat.PDF);
What could be causing this? Does the free version have some restrictions for example about the number of subdomains it can be used on?
Thanks