What I want to do is create a PDF document of the current page programmatically.
I have taken a quick look at iTextSharp and it seems that is not what I am after - it looks like you have to output line by line to iText#
What I am looking for is a bit similar to how you may choose File, Print, select a PDF writer, enter some details (eg, filename, etc), but this should all be done with minimal user interaction. In other words, user clicks a submit button on the form, a pdf is created on the server and then sent to the user via email.
Is this possible?
Loading
Gary KingPosted Oct 11, 2011, 5:00 AM
Thank you for the code - it may be a step in the right direction, but the problem is that it contains the text to go to pdf "show this text as PDF".
What I need to do is provide a seperate page to be converted. And to possibly make matters more complex, I need the source page to be .aspx, not .html.
So for example, my Default.aspx page will load the output from "ConvertMe.aspx?ID=5" and create "ConvertMe.pdf"
Is this possible?
Amit ChoudharyPosted Oct 10, 2011, 1:18 PM
Prabhu RajaPosted Oct 10, 2011, 12:33 PM
I doesn't did this translation before, so i suggest the following articles.
Example 1
Example 2
Source Code 1
Javeed M ShaikhPosted Oct 10, 2011, 11:50 AM
Please download iTextSharp from the following link:
http://sourceforge.net/projects/itextsharp/
Reference the itextsharp.dll in your project, and use the following code to display your page in HTML:
Please do not forget to mark "Accepted Answer".
Gary KingPosted Oct 10, 2011, 9:30 AM
I have downloaded the code, but am struggling to get past the many, many errors in VS (Linq, var, etc).
Maybe it is because I am not running the latest version of the .net Framework?
Could you possibly help me out by writing the HTMLtoPDF conversion code that would output a pdf version of a givem html page (eg, "MyPage.html") in a way that would work with Framework 2.0?
Thanks
Gary
bharathi kPosted Oct 10, 2011, 8:18 AM
Here is the link is which is used to generate pdf using ITextsharp library.
http://www.4guysfromrolla.com/articles/030911-1.aspx.
But you have the change file path here
string contents = File.ReadAllText(Server.MapPath(Page.AppRelativeVirtualPath));
like this instead of below path
// Read in the contents of the Receipt.htm file...
string contents = File.ReadAllText(Server.MapPath("~/HTMLTemplate/Receipt.htm"));
Happy Programming