Unable to release the file, after conversion into PDF using Java

API: Java - Groupdocs conversion - 19.12 version
Problem Statement: To Convert a text file into pdf and use this pdf in other process.

Once the file is converted, it is unable to release to use into other process(and shows 0 kb). But once the whole process complete i can find the the converted pdf is of some KB(i.e 20kb).

Here, is my code for TXT to pdf conversion:

Blockquote
public static String convertToPdfAsFilePath(String fileName) {

ConvertedDocument convertedDocumentPath = null ;
String filePathOut = new File(Paths. get (fileName).getParent().toString(), new Random().nextInt(9999) + “_” + fileName.substring(fileName.lastIndexOf(’\’)+1, fileName.length())).getPath();
filePathOut = filePathOut.substring(0, filePathOut.lastIndexOf(".")+1);
try {
ConversionHandler conversionHandler = new ConversionHandler(GroupdocsUtils. getConfiguration ());
PdfSaveOptions saveOption = new PdfSaveOptions();
String guid = fileName;
convertedDocumentPath = conversionHandler. convert(guid, saveOption);
filePathOut = filePathOut + convertedDocumentPath.getFileType();
convertedDocumentPath.save(filePathOut);///fileName.substring(0, fileName.lastIndexOf(".")) + “.” + convertedDocumentPath.getFileType());

} catch (Exception e) {

e.printStackTrace();
}

finally {

if (convertedDocumentPath!= null ) {
convertedDocumentPath.dispose();
}
}

return filePathOut;
}

Blockquote

1 Like

@gsaini092,

We are investigating this. Your inestigation ticket ID is CONVERSIONJAVA-890. As there is any further update, you’ll be notified.

@gsaini092,

Your reported issue CONVERSIONJAVA-890 is now fixed in API version 20.2.1.