Converting MSG file to (MHTML to) PDF, text / table are cut off on right side

Hi Team,

We are facing issue when converting MSG file to (MHTML to ) PDF, text / table are cut off on right side but other msg files are being converted fine. To fix the issue, we tried below snippet but it doesn’t work.

Note - If the same msg file is being saved from some other outlook client, PDF conversion works fine so I am not sure if attached MSG file itself is corrupted / incompatible.

            // auto fit tables to page
            NodeCollection tables = doc.getChildNodes(NodeType.TABLE, true);
            for (Table table : (Iterable<Table>) tables)
                table.autoFit(AutoFitBehavior.AUTO_FIT_TO_WINDOW);

            // Prevent embedded images from being cut off
            NodeCollection shapes = doc.getChildNodes(NodeType.SHAPE, true);
            for (com.aspose.words.Shape shape : (Iterable<Shape>) shapes) {
                if (shape.getShapeType() == ShapeType.IMAGE) {
                    if (doc.getFirstSection().getPageSetup().getPageWidth() < shape.getWidth()) {
                        double scale = (doc.getFirstSection().getPageSetup().getPageWidth() - 140) /
                                shape.getWidth();
                        shape.setWidth(doc.getFirstSection().getPageSetup().getPageWidth() - 140);
                        shape.setHeight(shape.getHeight() * scale);
                    }
                }
            }

I have attached the respective msg & pdf file below.
Msg with converted PDF.zip (300.2 KB)

Please let me know if additional details are required. Thanks.

@mkyadavAtvera,
Welcome to our community! Thank you for posting the query. Aspose.Email does not change HTML content of messages when converting MSG to MHTML. You can verify this in the following way:

MailMessage eml = MailMessage.load("Supercharge.msg");
eml.save("Supercharge_out.mhtml", SaveOptions.getDefaultMhtml());

Result: Supercharge_out.zip (10.4 KB)

I moved this thread to Aspose.Words forum. Our support team will help you further.

@mkyadavAtvera

We have tested the scenario and managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-22713. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

A post was split to a new topic: Table is cut off after MSG to PDF conversion