Open Source Software Forum

Issue with Docx conversion to image

Hello Team,
we recently procured Aspose.Word for Java and are facing issues with document conversion to image (png/jpeg)

We are performing the below steps to generate JPEG, however, the image produced does not render the text fetched via bookmarks, it only renders the actual content of the docx file.

public static void main(String[] args) throws Exception {
//ExStart:LoadAndSaveToStream

    //ExStart:OpenFromStream
    // The path to the documents directory.
    String dataDir = Utils.getDataDir(LoadAndSaveToStream.class);
    // Open the stream. Read only access is enough for Aspose.Words to load a document.
    InputStream stream = new FileInputStream(dataDir + "Document.doc");
    // Load the entire document into memory.
    Document doc = new Document(stream);
    // You can close the stream now, it is no longer needed because the document is in memory.
    stream.close();
    //ExEnd:OpenFromStream



    // ... do something with the document
    // Convert the document to a different format and save to stream.
    ByteArrayOutputStream dstStream = new ByteArrayOutputStream();
    doc.save(dstStream, SaveFormat.RTF);
    FileOutputStream output = new FileOutputStream(dataDir + "Document Out.rtf");
    output.write(dstStream.toByteArray());
    output.close();
    //ExEnd:LoadAndSaveToStream



    System.out.println("Document loaded from stream and then saved successfully.");
}

We are also using Aspose.Words for .Net and the docx is getting converted to image properly using memstream. However, with Java we are facing issue in conversion to image.

Would appreciate your assistance.

Thanks.

This topic has been moved to the related forum: https://forum.aspose.com/t/issue-with-docx-conversion-to-image/229847