1

if I have some report and i wanna before the user download this report through (Export to pdf file)to make a specific action (like add a watermark to this pdf).

How to handle the export button?


note : i wanna some generic way cause i have a lot of reports , and i don't want to repeat the code . i wanna just to execute specific behavior to the pdf file before downloading it.

Anyname Donotcare
  • 11,113
  • 66
  • 219
  • 392

3 Answers3

2

Assuming you have the original PDF without a watermark already accessible:

Implement something like this;

How can I insert an image with iTextSharp in an existing PDF?

Redirect or binary download watermarked file.

Done.

Community
  • 1
  • 1
ChrisBint
  • 12,773
  • 6
  • 40
  • 62
1

Simplest way would be a static class with a method that takesa pdf file and and perhaps the watermark image, sorts it out and passes it back.

If you want something more generic, e.g. you wanted to say password protect and or watermark a pdf, or you had non pdf reports you wanted to do something with.

Then Interface IPrepareForExport and implement it on the various types of "report", or perhaps use a decorator pattern and some attibutes.

Tony Hopkinson
  • 20,172
  • 3
  • 31
  • 39
0

Now this is not a easy solution to implement. But it is totally generic.

You should implement a Custom Report Renderer.

By creating a renderer for Reporting Services, you can render reports into the format of your choice.

It will be available whereever you have a report export.

Take a look at this blog: PDF watermark/background Rendering Extension for SSRS

He has already made an extention for what you want to do.

You can then remove the existing rendering option that you don't wish to support by editing the RSReportServer.Config file.

Your number of reports don't matter, because this is a one place configuration change.

nunespascal
  • 17,584
  • 2
  • 43
  • 46