Free Support Forum -

Avoid Cutting / Distortion of Auto-Fit Table Content during EML MSG or MHTML to PDF File Conversion using Java

I have attached the pdf file.

  • PDF- Header logo is not formatted correctly.

  • Content is not converted properly. Some of the information (right side) got cut.

TST2_ITA_AEReporting@pfizer.com_13-01-2021_11-18-20.pdf (223.0 KB)


Could you please also share your sample code (that you are using) and input file (if any), so we could evaluate your issue precisely and help you through.

Due to compliance. I can’t share the actual file and code.
I have raised the concern with manager. once he approve, I will share the file and code.


Once you have the approval, please share the source file and working sample code reproducing the issue on your end so that we may help to serve you further.

Please find the source file and sample code.
private void removeAttachmentAndConvertEmlOrMsgFile(int asposeFormat, InputStream docInputStream, OutputStream os,
ByteArrayInputStream licenseFS, String timezone) throws Exception {
MailMessage mailMsg;
ByteArrayOutputStream arrayOutputStream = null;
MhtSaveOptions saveOptions; emailLicense = new;
mailMsg = MailMessage.load(docInputStream, new EmlLoadOptions());
arrayOutputStream = new ByteArrayOutputStream();
saveOptions = SaveOptions.getDefaultMhtml();
AttachmentCollection attachmentCollection = mailMsg.getAttachments();
if (attachmentCollection != null) {
int size = attachmentCollection.size();
for (int i = 0; i < size; i++) {
Attachment att = attachmentCollection.get_Item(i);
String attFileName = att.getName().replace(":", " “).replace(”\", " “).replace(”/", " “)
.replace(”?", “”).replace(">", “”).replace("<", “”).replace("|", “”);
att.setContentStream(new ByteArrayInputStream("".getBytes()));
mailMsg.setTimeZoneOffset(TimeZone.getTimeZone(timezone).getOffset(mailMsg.getDate().getTime()));, saveOptions);
ByteArrayInputStream bis = new ByteArrayInputStream(arrayOutputStream.toByteArray());
com.aspose.words.LoadOptions loadOptions = new com.aspose.words.LoadOptions();
com.aspose.words.PdfSaveOptions pso = new PdfSaveOptions();
Document doc = new Document(bis, loadOptions);

	// make inline image resize
	NodeCollection shapes = doc.getChildNodes(NodeType.SHAPE, true);
	int imageIndex = 0;
	for (Shape shape : (Iterable<Shape>) shapes)
	    if (shape.hasImage() && (shape.getWidth() > 700 || shape.getHeight() > 900))
	    	double largeDim= shape.getWidth() > shape.getHeight()? shape.getWidth(): shape.getHeight();
	    	double q= shape.getWidth() > shape.getHeight()? 700: 900;
	    	double divExp= q/largeDim;
	        String imageFileName = MessageFormat.format(
	                "Aspose.Images.{0}{1}", imageIndex, com.aspose.words.FileFormatUtil.imageTypeToExtension(shape.getImageData()

	}, pso);
	//, com.aspose.words.SaveFormat.PDF);
} (94.9 KB)


We have converted the MHTML to PDF using latest APIs of Aspose.Words and have 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-21715. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.


Can you provide any tentative date or ETA for this issue.



The issue depends on the resolution of an internal extremely complex issue (WORDSNET-832). Therefore, WORDSNET-21715 is postponed until at least WORDSNET-832 is resolved, we will review your issue after the resolution of WORDSNET-832. Unfortunately, there is no ETA available at the moment. We will inform you via this forum thread as soon as this issue will get resolved or any further updates may be available in future. We apologize for your inconvenience.