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
http://www.aspose.com/community/forums/656355/changing-page-orientation-to-landscape-does-not-change-page-size/showthread.aspx#656355

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();
licence.SetLicense(@"C:\Projects\test\AposeTest\Aspose.Total.lic");
string html = @"

​asdasd

ASDASd sadasd

 

dasdas





";
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.Pages.Add(doc.Pages);
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
doc2.Save("C:\\temp\\HTML_Sample.pdf");
}


Hi,


Thanks for contacting support.

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

[C#]

Document doc = new
Document(“input.pdf”);
//original page is A4<o:p></o:p>

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

doc.Save("output.pdf");



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