I’m having a problem with Aspose.Words version 19.2 when trying to convert from docx to pdf, it throws the exception “com.aspose.words.zzZL1 cannot be cast to com.aspose.words.zzZ3H” in both updatePageLayout() and save() functions.
This is my testing code:
public class Test01
{
public static void main(String[] args)
{
// testing:
Path wiki_path = Paths.get("D:\\sample.docx");
try
{
byte[] wikiArray = Files.readAllBytes(wiki_path);
Test01 oef = new Test01();
byte[] outFile = oef.pdfConverter(wikiArray);
Path path = Paths.get("D:\\sample.pdf");
Files.write(path, outFile);
}
catch (Exception e)
{
System.out.println(e);
}
}
public byte[] pdfConverter(byte[] archivo) throws IOException, Exception
{
License license = new com.aspose.words.License();
license.setLicense("Aspose.Words.lic");
// Save the document in PDF format.
try (OutputStream out = new ByteArrayOutputStream())
{
// Load the document from disk.
try (InputStream fis = new ByteArrayInputStream(archivo))
{
Document doc = new Document(fis);
PdfSaveOptions options = new PdfSaveOptions();
options.setDisplayDocTitle(false);
options.setCompliance(PdfCompliance.PDF_15);
doc.updateWordCount();
doc.updateListLabels();
doc.updateTableLayout();
doc.updatePageLayout(); // Exception!
doc.save(out, options); // Exception too!
}
return ((ByteArrayOutputStream)out).toByteArray();
}
}
I’m attaching the file that causes this problem:
sample.zip (119.6 KB)