Hello,
I’ve got an issue for some Word files that when I save it as PDF, it just adds in the middle an empty file.
I can’t share with you the problematic file, but maybe you know about the issue, we got no errors on the server side (aws, linux, java, aspose-pdf: 25.2)?
That’s the code:
@CrossOrigin
@PostMapping(“/createPdf”)
public String createPdf(@RequestHeader(value = “X-API-KEY”, required = false) String apiKey,
@RequestBody FileData_v5 fileData) throws Exception {
Path requestDirectory = null;
try {
LOGGER.info(“********************** New PDF Request V5 *************************”);
LOGGER.info(fileData.toString());
if (apiKey == null || apiKey.isBlank() || apiKey.isEmpty()) {
LOGGER.error("No API key in request");
} else if (!X_API_KEY.equals(apiKey)) {
LOGGER.error("API Key is invalid");
throw new BadCredentialsException("API Key is invalid");
}
requestDirectory = Utils.createRequestDirectory(fileData);
Document pdfDocument = pdfInit(fileData);
addDocumentPrivilege(fileData.getDocumentState(), pdfDocument, fileData.getObjId());
pdfDocument.save(Path.of(requestDirectory.toString(), fileData.getFileId().concat(".pdf")).toString());
String pdfId = uploadPdfToSF(fileData, false);
Utils.deleteDirectory(requestDirectory);
LOGGER.info("*************************** PDF created successfully! ***************************");
JSONObject response = new JSONObject();
response.put("pdfId", pdfId);
return response.toString();
} catch (Exception e) {
LOGGER.error("Generate PDF error for file - {}.{} The error- {}", fileData.getFileId(),
fileData.getExtension(), e.getMessage());
LOGGER.error(Arrays.toString(e.getStackTrace()));
Utils.deleteDirectory(requestDirectory);
throw e;
}
}
Thanks !!
Ayelet