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

Free Support Forum - aspose.com

Page Contents don't fit on page


I have been attempting several things in order to simply get html contents to fit on a letter size page. As you will see from the attached PDF they seem to be shifted over to the right.

var basePath = “C:/Users/Administrator/Desktop/html/”;
var loadOptions = new HtmlLoadOptions(basePath);

//load the file
doc = new Document(“C:/Users/Administrator/Desktop//html/smalltest.html”, loadOptions);

foreach (Page page in doc.Pages)
page.SetPageSize(612, 792);
page.PageInfo.IsLandscape = false;



Hi Grant,

Thanks for your inquiry. Please note SetPageSize() works for existing PDF. you need to use PageInfo property of HtmlLoadOptions to control the page size of new PDF as following.

var basePath = “C:/Users/Administrator/Desktop/html/”;<o:p></o:p>

var loadOptions = new HtmlLoadOptions(basePath);

loadOptions.PageInfo.Width = 900;

loadOptions.PageInfo.Height = 590;

//load the file

doc = new Document("C:/Users/Administrator/Desktop//html/smalltest.html", loadOptions);


Please feel free to contact us for any further assistance.

Best Regards,