Background color with landscape page


I can’t seem to get the background color of my page to completely fill a page when it’s in landscape mode. It looks like it’s only filling a portrait width of color. It leaves a large white background space to the right. It works fine in portrait. I attached an image of what it looks like.

Landscape_BackgroundColor.png (1.3 KB)

Landscape_BackgroundColor_Title.png (4.0 KB)

Relevant code

var license = new License();

var doc = new Document();
var output = new MemoryStream();

var blue = Color.FromRgb(System.Drawing.Color.FromArgb(0, 44, 86));
var white = Color.FromRgb(System.Drawing.Color.FromArgb(255, 255, 255));

// Pdf doc settings
doc.PageInfo.IsLandscape = true;
doc.Background = bamBlue;
doc.PageInfo.Margin.Left = 20;
doc.PageInfo.Margin.Right = 20;
doc.PageInfo.Margin.Top = 20;
doc.PageInfo.Margin.Bottom = 20;

var titleSection = doc.Pages.Add();
doc.Pages[1].Background = blue;

titleSection.PageInfo.IsLandscape = true;
titleSection.Background = blue;
titleSection.PageInfo.Margin.Left = 0;
titleSection.PageInfo.Margin.Right = 0;
titleSection.PageInfo.Margin.Top = 0;
titleSection.PageInfo.Margin.Bottom = 0;

var portfolioTitle = new TextFragment($@"{portfolio}")
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center
portfolioTitle.TextState.FontSize = 36;
portfolioTitle.TextState.ForegroundColor = white;
portfolioTitle.TextState.BackgroundColor = bamBlue;
portfolioTitle.TextState.Font = FontRepository.FindFont(“Arial”);


doc.Save(output, SaveFormat.Pdf);
return output.ToArray();

Are there other properties that need to be set to accomplish the whole landscape page to be a background color?


We were able to reproduce the issue in our environment while testing the scenario with Aspose.PDF for .NET 21.2. We further need to investigate the reasons behind this issue and check whether it can be achieved with some other workaround. For the purpose, an issue as PDFNET-49582 has been logged in our issue tracking system. We will further look into its details and keep you posted with the status of its correction. Please be patient and spare us some time.

We are sorry for the inconvenience.

Thank you. Any updates or a timeline about this? Would be fine with a work around.


We are afraid that we cannot share any ETA or work around at the moment as the ticket is not reviewed and investigated yet. It will be analyzed and fixed on a first come first serve basis and we will surely inform you as soon as it is resolved. Please give us some time.

We apologize for the inconvenience.

I am just noticing this as well. We would greatly appreciate some feedback, as it has been 6 months. I need to push something out to production. Is this going to be fixed? Some more feedback is that it paints only the standard 8.5x11 page in the lower left corner. If the page is standard size it works well Even is the page is not landscape, but if the page height is extended it will be painted in the lower left corner. I am sure that it is the right size. It just appears to be hard coded. I think it just need to respect the page size.


We really regret to inform that earlier logged ticket is not yet fully investigated due to other issues logged prior to it. However, we have recorded your concerns and will surely consider them during issue analysis. We will surely inform you in this forum thread as soon as the ticket is resolved. Please give us some time.

We are sorry for the inconvenience.

The issues you have found earlier (filed as PDFNET-49582) have been fixed in Aspose.PDF for .NET 21.10.