We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to customize paper length when saving Mht format stream as Aspose.Word Document

Hi. I have an mht format Memorystream. I want to load it as a Aspose.Words.Document. The problem is that there is no ‘page’ concept in mhtml file. If the mht file is long, the output document should have more than 1 normal size page. But I wonder if there is a way to customize the page length when loading mht as a Document so that finally the document has only one page. Thanks!

Hi,


Thanks for your inquiry. There is no page concept in Microsoft Word application either. Pages are created by Microsoft Word on the fly and it allows 22 inches max height/width of a Page. So, if your MHT’s height is larger than 22 inches, there will be more than one pages in Word document.

Here is how you can change the width and height of generated document:

Document doc = new Document(MyDir + @“in.mht”);

doc.FirstSection.PageSetup.PageWidth = 22 * 72;

doc.FirstSection.PageSetup.PageHeight = 22 * 72;

doc.Save(MyDir + @"15.9.0.docx");


Hope, this helps.

Best regards,

Yes. It works well. Thanks a lot!