Most of the questions in stackoverflow or in other forums, show how to generate views and sends them by email.
But my goal is to generate a PDF from a view with the media=print
format and sends it in attachment by email.
I have a view that displays a report. I use CSS Print to display this report in a print format. (Basically I display some elements and hide others).
How can I generate a PDF from this view (with format media=print
) and send it by e-mail in attachment.
I am using ActionMailer to send emails and iTextSharp to generate PDFs
I also had the same problem and did a lot of googling. but could not find a proper solution. There was a 3rd party dll called "PDFGenerator" but the output is not neat and nice. So I chose another solution. I created a report file(.rdlc) with the UI i want print it as a pdf by the code. Here is my sample code GitHub