Free Support Forum -

Section Background Image

I have a requirement to put a background image for the pdf and i am trying to add the attached one.

Code looks like

Aspose.Pdf.Section section = new Aspose.Pdf.Section();
section.IsLandscape = true;
section.PageInfo.Margin = ReportHelper.Pdf.Margin(15.5f, 27.2f, 36, 36);
section.PageInfo.PageWidth = Aspose.Pdf.PageSize.LetterWidth;
section.PageInfo.PageHeight = Aspose.Pdf.PageSize.LetterHeight;
section.BackgroundImageFile = backGroundImagePath;
section.BackgroundImageFixedWidth = Aspose.Pdf.PageSize.LetterWidth;
section.BackgroundImageType = Aspose.Pdf.ImageFileType.Png;
When i run the site, i am getting this error
Image top or bottom margin is too large 0,0


Thanks for contacting support.

I have tested the scenario using Aspose.Pdf for .NET 7.9.0 in Visual Studio 2010 application and I am unable to notice any issue. Image is properly being added as section background. Furthermore, I have observed that you are using code snippet which belongs to legacy Aspose.Pdf for .NET (versions released prior to MergedAPI). I would suggest you to please try using the latest release versions as they include lots of new features and resolution of issues reported earlier. For your reference, I have also attached the resultant PDF file which is generated over my end. We are sorry for this inconvenience.


pdf = new Aspose.Pdf.Generator.Pdf();<o:p></o:p>

Aspose.Pdf.Generator.Section section = pdf.Sections.Add();

section.IsLandscape = true;

section.PageInfo.Margin = new Aspose.Pdf.Generator.MarginInfo { Top = 15.5f, Bottom = 27.2f, Left = 36, Right = 36 };

section.PageInfo.PageWidth = Aspose.Pdf.Generator.PageSize.LetterWidth;

section.PageInfo.PageHeight = Aspose.Pdf.Generator.PageSize.LetterHeight;

section.BackgroundImageFile = "c:/pdftest/CF_Gradient.png";

section.BackgroundImageFixedWidth = Aspose.Pdf.Generator.PageSize.LetterWidth;

section.BackgroundImageType = Aspose.Pdf.Generator.ImageFileType.Png;

//add sample text paragraph

section.Paragraphs.Add(new Aspose.Pdf.Generator.Text("Hello World ... "));


You may consider visit the following links for further information on


Thanks for your reply.

I saw the attachment and see that the page got resized to the size of the image.
Is it possible to keep the size of the page to say Letter and resize the image accordingly?


Hi Sudheer,

Thanks for your inquiry. After initial investigation, I’ve logged the requirement of background image height setting as PDFNEWNET-35248 in our issue tracking system for further investigation and resolution. As a workaround you can add image as a stamp to page. please check following code snippet. Hopefully it will serve the purpose.

Document pdfDocument = new Document();
//create image stamp
ImageStamp imageStamp = new ImageStamp(myDir + “CF_Gradient.png”);
imageStamp.Background = true;
imageStamp.XIndent = 0;
imageStamp.YIndent = 0;
// converting inches to point, as point is basic measuring unit and 1 inch=72 points
imageStamp.Height = 11.9672;
imageStamp.Width = 8.2672;
// imageStamp.Opacity = 0.5;
//add stamp to particular page

//save output document

Please feel free to contact us for any further assistance.

Best Regards,