There is a gap between the footer added to the PDF and the bottom of the page

I use Aspose.pdf for NET 25.8 to add a footer to a PDF. There is always a gap between the added footer and the bottom of the page

void Main()
{
	InitCoreComponent();

	// Open PDF document
	var document = new Aspose.Pdf.Document(@"C:\Users\54390\Desktop\demo.pdf");

	for (var i = 1; i <= document.Pages.Count; i++)
	{
		// Create footer text
		var footerText = new Aspose.Pdf.Text.TextFragment("footer");
		footerText.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Center;

		// Create footer 
		var footer = new Aspose.Pdf.HeaderFooter();
		footer.Paragraphs.Add(footerText);

		// Set footer margin
		footer.Margin = new Aspose.Pdf.MarginInfo
		{
			Left = 0,
			Bottom = 0
		};

		document.Pages[i].Footer = footer;
	}

	// Save PDF document
	document.Save(@"C:\Users\54390\Desktop\inxun\2\output.pdf");
}

Demo file

demo.pdf (452.9 KB)

output.pdf (479.5 KB)

Screenshot

2025-08-29_224358_164.png (75.7 KB)

@sullivan

It sounds like you’re experiencing an issue with the footer positioning in your PDF. The gap between the footer and the bottom of the page is often caused by the default margins or padding settings.

To resolve this, you can adjust the MarginInfo settings for the footer. Specifically, set the Bottom margin to a negative value to pull the footer closer to the bottom of the page. Here’s how you can modify your code:

void Main()
{
    InitCoreComponent();

    // Open PDF document
    var document = new Aspose.Pdf.Document(@"C:\Users\54390\Desktop\demo.pdf");

    for (var i = 1; i <= document.Pages.Count; i++)
    {
        // Create footer text
        var footerText = new Aspose.Pdf.Text.TextFragment("footer");
        footerText.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Center;

        // Create footer 
        var footer = new Aspose.Pdf.HeaderFooter();
        footer.Paragraphs.Add(footerText);

        // Set footer margin
        footer.Margin = new Aspose.Pdf.MarginInfo
        {
            Left = 0,
            Bottom = -10 // Adjust this value as needed
        };

        document.Pages[i].Footer = footer;
    }

    // Save PDF document
    document.Save(@"C:\Users\54390\Desktop\inxun\2\output.pdf");
}

In this example, I’ve set the Bottom margin to -10. You can adjust this value further based on your specific needs.

Next steps: Please implement the changes in your code and test the output PDF to see if the footer positioning meets your requirements. If you continue to experience issues, feel free to reach out for further assistance.

Let me know if this solution works for you!

I set the value of Bottom, but there is still a gap

@Professionalize.Discourse

@sullivan

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFNET-60562

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.