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

Free Support Forum - aspose.com

Importing HTML to Landscape Problems

This is some what related to my post in

When I try to add html to a pdf document using the code below. The generated pdf margin gets messed up and the html startes at a negative top margin. I guess the problem is the page width and height remain the same after changing page orientation to landscape.

It works fine in portrait.

private static void Addhtml()

Aspose.Pdf.License licence = new Aspose.Pdf.License();
string html = @"


ASDASd sadasd



HtmlLoadOptions htmlLoadOptions = new HtmlLoadOptions();
Document doc2 = new Document();
Document doc = new Document(new MemoryStream(Encoding.UTF8.GetBytes(html)), htmlLoadOptions);
var previous = doc2.Pages.Count;
doc2.PageInfo.IsLandscape = true;
doc.PageInfo.Margin.Top = 100;
doc.PageInfo.Margin.Left = 100;
doc2.Pages[previous + 1].Paragraphs.Add(Header("test"));

//Save PDF file


Thanks for contacting support.

In order to accomplish your requirement, please try updating page dimensions.


Document doc = new
//original page is A4<o:p></o:p>

doc.Pages[1].Rect = new Rectangle(0, 0, 421, 595); // A5 size


PS, the PageInfo.IsLandscape property returns the page orientation value.