How to adjust the page height of a pdf page in ITextsharp code
I have this asp.net page with export to pdf using ITextsharp. My challenges is that there is to much blank space after the data on the pdf.I would like to adjust the pdf page height so that it has little blank space,I do not want too much blank spaces,it makes the pdf page looks unprofessional

Sachin SinghRank #66 · 26.2K reputationPosted Sep 4, 2021, 7:04 PM EDT
Leon DRank #851 · 2.6K reputationPosted Sep 5, 2021, 9:11 PM EDT
You can install Free Spire.PDF via nuget and then use the following code to reset PDF page size.
using Spire.Pdf; using Spire.Pdf.Graphics; using System.Drawing; namespace ChangePDFpagesize { class Program { static void Main(string[] args) { PdfDocument pdf = new PdfDocument(); pdf.LoadFromFile("Sample.pdf"); PdfDocument newPdf = new PdfDocument(); foreach (PdfPageBase page in pdf.Pages) { PdfPageBase newPage = newPdf.Pages.Add(PdfPageSize.A1, new PdfMargins(0)); PdfTextLayout loLayout = new PdfTextLayout(); loLayout.Layout = PdfLayoutType.OnePage; page.CreateTemplate().Draw(newPage, new PointF(0, 0), loLayout); } newPdf.SaveToFile("Result.pdf"); } } }For more information, visit this link:
https://www.e-iceblue.com/Tutorials/Spire.PDF/Spire.PDF-Program-Guide/Page-Setting/How-to-change-PDF-page-size-in-C.html