How to Start Convert PDF Read PDF Build PDF Work with PDF Modules PDF Document PDF Pages Text Image Graph & Path Annotation, Markup & Drawing Redaction Security Digital Signature Forms Watermark Bookmark Link File Attachment File Metadata Printing Work with Other SDKs Barcode read Barcode create OCR Twain

Using C# PDF SDK
C# PDF Library: how to change pdf page size (width, height) using c#


C# Demo Code to change pdf page size (width, height) using c#













Change size of a specified page


String inputFilePath = Program.RootPath + "\\" + "1.pdf";
String outputFilePath = Program.RootPath + "\\" + "1_new.pdf";

//  open the file
PDFDocument doc = new PDFDocument(inputFilePath);
//  get the 2nd page
PDFPage page = (PDFPage)doc.GetPage(1);
//  set crop region: start point (100, 100), width = 300, height = 400
RectangleF cropArea = new RectangleF(100, 100, 300, 400);
//  crop the page
page.Crop(cropArea);

//  output the new document
doc.Save(outputFilePath);




Change size for all pages in a document


String inputFilePath = Program.RootPath + "\\" + "1.pdf";
String outputFilePath = Program.RootPath + "\\" + "1_new.pdf";

//  open the file
PDFDocument doc = new PDFDocument(inputFilePath);
//  set crop region: start point (100, 100), width = 300, height = 400
RectangleF cropArea = new RectangleF(100, 100, 300, 400);
//  crop pages
doc.CropAllPages(cropArea);

//  output the new document
doc.Save(outputFilePath);