Create Blank Page

Creating a blank PDF page refers to generating a page within a PDF document that contains no content, no texts, images, or graphics. This can be done intentionally for various purposes, such as adding space for notes, separating sections of a document, or aligning content in a specific layout.

Creating a PDF with a blank page using IronPDF is straightforward. For detailed guidance on using IronPDF to generate PDF documents, visit the IronPDF Official Documentation. Simply supply two integers for width and height to the PdfDocument constructor to create a PDF with a blank page.

Here's an example in C# on how this can be done:

// Import the necessary IronPdf namespace
using IronPdf;

class Program
{
    static void Main(string[] args)
    {
        // Define the dimensions for the blank page
        int width = 210;  // Width in millimeters (A4 width)
        int height = 297; // Height in millimeters (A4 height)

        // Create a new PdfDocument with one blank page of specified dimensions
        PdfDocument pdfDoc = new PdfDocument(width, height);

        // Optionally, save the PDF to a file
        pdfDoc.SaveAs("BlankPage.pdf");

        // Indicate that the PDF has been created
        Console.WriteLine("PDF with a blank page has been created and saved as 'BlankPage.pdf'.");
    }
}
// Import the necessary IronPdf namespace
using IronPdf;

class Program
{
    static void Main(string[] args)
    {
        // Define the dimensions for the blank page
        int width = 210;  // Width in millimeters (A4 width)
        int height = 297; // Height in millimeters (A4 height)

        // Create a new PdfDocument with one blank page of specified dimensions
        PdfDocument pdfDoc = new PdfDocument(width, height);

        // Optionally, save the PDF to a file
        pdfDoc.SaveAs("BlankPage.pdf");

        // Indicate that the PDF has been created
        Console.WriteLine("PDF with a blank page has been created and saved as 'BlankPage.pdf'.");
    }
}
$vbLabelText   $csharpLabel

Explanation

  • Width and Height: The dimensions for the PDF page are defined in millimeters. In this example, it uses the dimensions of an A4 page, which are 210 mm in width and 297 mm in height.
  • PdfDocument Constructor: The PdfDocument class from the IronPDF library takes two integers as arguments for width and height and creates a new PDF document containing one blank page with those dimensions.
  • SaveAs Method: This method is used to save the newly created PDF to the file system. In this example, the PDF is saved with the filename "BlankPage.pdf".
  • Console Output: A simple message is printed to the console indicating that the PDF creation process is complete.

This code needs the IronPDF library, so ensure that you have the IronPDF NuGet package installed in your project.