Free Support Forum -

Image truncation issue

Image got truncated from right side. we had converting the html file to pdf file.
I’m attaching the html file and converted pdf file.tarun.srivastava@genpact.digital_27-11-2020_07-18-20.pdf (175.5 KB)FW_ Issue (252.9 KB)

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);


After working with sample code and source file provided by you, it seems to be an issue related to Aspose.Email while truncating the right side image when saving to MHTML. A ticket with ID EMAILJAVA-34784 has bee created to further investigate and resolve the issue.

You have shared MSG file where as you are using EmlLoadOptions(). You need to use MsgLoadOptions() for MSG file. Is this the case with you in another thread where you have reported InvalidOperation Exception issue?

Thanks for update. We are reading the outlook and process the eml file for conversion.
If I used below code than it’s correct right?
mailMsg = MailMessage.load(docInputStream, new EmlLoadOptions());

I have the eml file that causing the InvalidOperarion exception issue. If you want, I can share with (34.4 KB)


There is no InvalidOperarion exception issue with the new file shared by you as well on our end. I have shared the output and used sample code with you for this in another thread as well where you have shared the same thing. (2.1 KB)


Can you provide any tentative date or ETA for issue EMAILJAVA-34784.



I regret to share that at present the issue is still unresolved and we request for your patience. We will share the good news with you as soon as the issue will be addressed.