Document with different page sizes

Hello, Is it possible to create a pdf, with different page sizes, for example, i wanted the first page of the pdf to be 1024 X 768 width and height in pixel, and the second page would be 1280 X 560 width and height in pixel.

Hi Arun,


Thanks for your inquiry. You can add pages with different dimensions in a PDF document as following.

Moreover please note that the basic measuring unit in Aspose.Pdf for .NET is point, where 1 inch = 72 points and 1 cm = 1/2.54 inch = 0.3937 inch = 28.3 points. The conversion from point to pixel depends on an image’s DPI (dots per inch) property. For example, if an image’s DPI is 96 (96 pixels for each inch), and it is 100 points high, its height in pixels is (100 / 72) * 96 = 133.3. The general formula is: pixels = ( points / 72 ) * DPI. Hopefully it will help you to convert pixel to point.

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

// Added page.

Aspose.Pdf.Page page1 = doc.Pages.Add();

PageInfo pageInfo = page1.PageInfo;

pageInfo.Width = 1024;

pageInfo.Height = 768;

page1.Paragraphs.Add(new TextFragment("test page 1"));

//Add the table into the paragraphs collection of section

Aspose.Pdf.Paragraphs paragraphs = page1.Paragraphs;

//Add content/data for the page

doc.ProcessParagraphs();

// Added New page.

Aspose.Pdf.Page page2 = doc.Pages.Add();

PageInfo pageInfo1 = page2.PageInfo;

pageInfo1.Width = 1280;

pageInfo1.Height = 560;

// add text fragment to paragraphs collection of Page object

page2.Paragraphs.Add(new TextFragment("test page 2"));

doc.ProcessParagraphs();

doc.Save(myDir + "PDF_diff_page_dim.pdf");

Please feel free to contact us for any further assistance.


Best Regards,