Margins per page and tables

Hi there,

I've used the following code to use a .jpg as the background for my PDF.

PdfDocument document = new PdfDocument();
document.PageSettings.Margins.All = 0;
document.PageSettings.Size = PdfPageSize.A4;
PdfPage page = document.Pages.Add();
//
PdfGraphics graphics = page.Graphics;
PdfImage backgroundImage = PdfImage.FromImage(Resources.briefpapier_2007);
page.Graphics.DrawImage(backgroundImage, 0, 0, page.GetClientSize().Width, page.GetClientSize().Height);
// Use this to make sure we don't go past a certain point
page.Section.PageSettings.Margins.Bottom = 100;

I'm not sure if this is right, but I'm using the PageAdded event to make sure every other page is getting another background.

PdfPage page = args.Page;
page.Section.PageSettings.Margins.All = 0;
PdfImage backgroundImage = PdfImage.FromImage(Resources.briefpapier_2007_vervolg);
page.Graphics.DrawImage(backgroundImage, 0, 0, page.GetClientSize().Width, page.GetClientSize().Height);
// Set new margins
page.Section.PageSettings.Margins.Bottom = 20;
page.Section.PageSettings.Margins.Top = 200;

I've set the top margin really high. But when I add a table to page 1, the top margin isn't working. Row 1-x is shown on page 1, but from row x to the end is shown on page 2, but immediately at the extreme top of the page.

Any idea how to solve this? Thanks


1 Reply

SS Sri Subhashini M Syncfusion Team July 22, 2008 06:48 AM UTC

Hi,

Thank you for your interest in Syncfusion PDF.

Top margin is not working properly.

I was able to view the condition which is mentioned here. We have resolve the problem by commenting the all Margin values as 0 statement (PageSettings.Margins.All = 0;). Please do find the sample from the below specified location and let me know if this helps.

http://www.syncfusion.com/support/user/uploads/Sample_3e0c6412.zip

Regards,
Suba




Loader.
Up arrow icon