We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Adding documents to a report as an image not merged

Thread ID:

Created:

Updated:

Platform:

Replies:

103142 Apr 4,2012 05:05 PM Apr 5,2012 03:27 AM ASP.NET Web Forms (Classic) 1
loading
Tags: PDF
dan
Asked On April 4, 2012 05:05 PM

I might be lacking PDF knowledge, but currently we use TIFF files to store merged documents that are scanned in. We want to create reports that will have data, say a grid of current employees that we create with .NET and then show the contents of a couple documents (say an email and a pdf). For example an employee list and email or word document approval saying to hire the person and maybe a pdf of their w2.
Now, I don't want to just merge the documents together, I sort of want to make it a smaller size or in a frame saying from where that document came from like, Page 1 of 2 from Document X.

I'm not sure if you've run into a similar situation. Maybe the watermark and border would be of use. Maybe I should convert them to images and then add the images to the report.


Geetha M [Syncfusion]
Replied On April 5, 2012 03:27 AM

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


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;