Page.Resize(RectangleF, PageContentHorizontalAlignment, PageContentVerticalAlignment) Method
Resizes the page content to fit the specified media box and aligns it according to the specified horizontal and vertical alignment settings.
Namespace: DevExpress.Docs.Pdf
Assembly: DevExpress.Docs.Pdf.v26.1.dll
Declaration
public void Resize(
RectangleF mediaBox,
PageContentHorizontalAlignment horizontalAlignment,
PageContentVerticalAlignment verticalAlignment
)
Parameters
| Name | Type | Description |
|---|---|---|
| mediaBox | RectangleF | The media box to which the page content should be resized. |
| horizontalAlignment | PageContentHorizontalAlignment | The horizontal alignment setting that specifies how the page content should be aligned horizontally within the media box. |
| verticalAlignment | PageContentVerticalAlignment | The vertical alignment setting that specifies how the page content should be aligned vertically within the media box. |
Example
How to: Rotate and Resize Pages in a PDF Document
The following code snippet rotates the first page by 90 degrees and resizes it to A4 size:
using DevExpress.Docs.Pdf;
using System.Drawing;
using System.IO;
using (PdfDocument pdfDocument = new PdfDocument(new FileStream(@"Document.pdf", FileMode.OpenOrCreate, FileAccess.ReadWrite)))
{
// Rotate the first page and resize it to A4.
Page page = pdfDocument.Pages[0];
page.Rotation = PageRotationAngle.Clockwise90;
page.Resize(
new RectangleF(0, 0, 595.28f, 841.89f),
PageContentHorizontalAlignment.Center,
PageContentVerticalAlignment.Center);
pdfDocument.Save(new FileStream("Result.pdf", FileMode.Create, FileAccess.Write));
}
See Also