Description:
getting Errors while processing the file Econophysics_all.docx
Econophysics_anon.docx (356.9 KB)
while converting Word to pdf.
dependency:
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-total</artifactId>
<version>23.8</version>
<type>pom</type>
</dependency>
amd64/eclipse-temurin:11-jre-alpine
code snippet:
byte[] bufBytes = inputStream.readAllBytes();
com.aspose.words.FileFormatInfo info = com.aspose.words.FileFormatUtil.detectFileFormat(new ByteArrayInputStream(bufBytes));
if (info.isEncrypted())
{
createAlertPageForEncryptedFile(directoryPath, actualFileName, outputFileName, MICROSOFT_WORD_LOCK_PNG_PATH);
return;
}
com.aspose.words.Document document = new com.aspose.words.Document(new ByteArrayInputStream(bufBytes));
FontSettings fontSettings = new FontSettings();
fontSettings.setFontsFolder(getFontDirectory(), true);
document.setFontSettings(fontSettings);
com.aspose.words.PdfSaveOptions pdfSaveOptions = new com.aspose.words.PdfSaveOptions();
pdfSaveOptions.setUseCoreFonts(true);
pdfSaveOptions.setUpdateFields(false);
pdfSaveOptions.setOptimizeOutput(true);
pdfSaveOptions.setMemoryOptimization(true);
document.save(directoryPath + PATH_SEPARATOR + outputFileName, pdfSaveOptions);