How to do an action on a specific file before downloading it?


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.

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.