GM
Geetha M
Syncfusion Team
April 5, 2012 07:27 AM UTC
Hi Dan,
Thank you for your continued interest in Syncfusion products.
If you want not to merge the documents but to draw them as images with watermark and border, you can achieve it using the following code snippet:
PdfMargins margins = document.PageSettings.Margins;
SizeF dSize = new SizeF(document.PageSettings.Width - (margins.Left + margins.Right), document.PageSettings.Height - (margins.Top + margins.Bottom));
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 56f);
PdfBrush brush = PdfBrushes.Black;
PdfSection section = document.Sections.Add();
// Top border
PdfPageTemplateElement template1 = new PdfPageTemplateElement(new RectangleF(30, 30, dSize.Width + 20, 5));
template1.Graphics.DrawRectangle(PdfBrushes.Blue, new RectangleF(PointF.Empty, template1.Size));
section.Template.Top = template1;
// Left border
template1 = new PdfPageTemplateElement(new RectangleF(30, 30, 5, dSize.Height + 20));
template1.Graphics.DrawRectangle(PdfBrushes.Blue, new RectangleF(PointF.Empty, template1.Size));
section.Template.Left = template1;
// Bottom border
template1 = new PdfPageTemplateElement(new RectangleF(30, 30 + dSize.Height + 20, dSize.Width + 20, 5));
template1.Graphics.DrawRectangle(PdfBrushes.Blue, new RectangleF(PointF.Empty, template1.Size));
section.Template.Bottom = template1;
// Right border
template1 = new PdfPageTemplateElement(new RectangleF(30 + dSize.Height + 20, 30, 5, dSize.Height + 20));
template1.Graphics.DrawRectangle(PdfBrushes.Blue, new RectangleF(PointF.Empty, template1.Size));
section.Template.Right = template1;
// Add page to the section and then draw the contents.
PdfPage page = section.Pages.Add();
SizeF size = page.GetClientSize();
PdfImage image = PdfImage.FromFile(imageFilePath);
PdfLayoutFormat format = new PdfLayoutFormat();
format.Layout = PdfLayoutType.Paginate;
image.Draw(page, PointF.Empty, format);
// Add Watermark in the page.
PdfGraphicsState state = page.Graphics.Save();
page.Graphics.SetTransparency(.2f);
page.Graphics.RotateTransform(-45);
page.Graphics.DrawString("Document 1", font, brush, new PointF(-size.Width / 3, size.Height / 2));
page.Graphics.Restore(state);
Please try this and let me know if you have any questions.
Regards,
Geetha