Landscape PDF

I’m using the .Net PDF generator, and I’m trying to create a landscape page. When I run the following, i get a null exception. If I swap the page height and width, the code works.

MemoryStream ms = new MemoryStream();
Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
Aspose.Pdf.Generator.Section section = pdf.Sections.Add();

section.PageInfo.PageHeight = 100;
section.PageInfo.PageWidth = 250;
section.IsLandscape = true;

pdf.Save(ms);
return ms.ToArray();


This message was posted using Page2Forum from How to - Set page orientation according to image dimensions - Aspose.Pdf for .NET

Hi Dsegan,

Thanks for your interest in our products.

Thank you for sharing the source code. We have found your mentioned issue after an initial test. We will further look into the details of this problem and notify you via this forum thread regarding any update against your reported issue.

We apologize for your inconvenience.

Thanks & Regards,

Hi Dsegan,


Thanks for your patience.

I am pleased to share that the issue reported earlier has been resolved and its resolution will be included in upcoming release version of Aspose.Pdf for .NET 7.8.0. Furthermore, I would also suggest you to use new DOM approach and use Document class to generate the PDF file. You may try using the following code snippet to accomplish your requirement.

[C#]

Document doc = new
Document();<o:p></o:p>

Page page = doc.Pages.Add();

page.PageInfo.Height = 100;

page.PageInfo.Width = 250;

page.PageInfo.IsLandscape = true;

doc.Save("c:/pdftest/Resultant file.pdf");

The issues you have found earlier (filed as PDFNEWNET-33119) have been fixed in Aspose.Pdf for .NET 7.8.0update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.