Hi all,
I try build project example GitHub - aspose-words-cloud/aspose-words-cloud-java: A Java library for communicating with the Aspose.Words Cloud API (I changed AppId & ApiKey).
When press button convert:
java.lang.NullPointerException: Attempt to invoke virtual method ‘java.lang.String com.google.gson.JsonElement.toString()’ on a null object reference
W/System.err: at com.aspose.words.cloud.ApiClient.handleResponse(ApiClient.java:877)
at com.aspose.words.cloud.ApiClient.execute(ApiClient.java:787)
at com.aspose.words.cloud.api.WordsApi.convertDocumentWithHttpInfo(WordsApi.java:860)
at com.aspose.words.cloud.api.WordsApi.convertDocument(WordsApi.java:837)
W/System.err: at com.example.asposewordscloudandroid.MainActivity$onActivityResult$1.run(MainActivity.kt:131)
Thanks for your inquiry. It seems servercreds.json file is missing in asset folder. Please find sample servercreds.jsonservercreds.zip (211 Bytes) file, update your aspose.cloud credentials in it and save to asset folder of the project. It will fix your above reported issue.
Thanks for your inquiry. Can you please share more details about your requirement? Because, PDF to DOC/DOCX conversion API already saving resultant DOC/DOCX file to storage.
It seems fine. However, please note SaveAs API method saves the result file to Cloud Storage. As we are passing a null parameter for storage so DOCX file is being saved to Aspose Cloud default storage. If you want to download the DOCX file to device storage then please use DownloadFile Method for the purpose.
DownloadFileRequest downloadRequest = new DownloadFileRequest(destName, null, null);
File outputFile = wordsApi.downloadFile(downloadRequest);
File dest = new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/"+destName);
Files.copy(outputFile.toPath(), dest.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING);