Hi,
I have aspx page in which I loaded tables and other info dynamically, now i want to convert this current page content into pdf, is it possible..
How to convert current aspx content to pdf
Page 1 of 17 Replies - 2252 Views - Last Post: 19 September 2012 - 07:21 AM
Replies To: How to convert current aspx content to pdf
#2
Re: How to convert current aspx content to pdf
Posted 03 June 2010 - 12:09 AM
Yup it's possible (with 3rd party components), but unfortunately we're not going to show you the code until after you show us the effort you've taken to accomplish this task
#3
Re: How to convert current aspx content to pdf
Posted 03 June 2010 - 07:14 AM
PsychoCoder, I've seen this question asked so many times before...
I've never tried it myself though.
What 3rd party components would you recommend people check out to achieve this?
-Frinny
I've never tried it myself though.
What 3rd party components would you recommend people check out to achieve this?
-Frinny
#4
Re: How to convert current aspx content to pdf
Posted 14 September 2012 - 01:05 AM
Hi ,
Even am trying to convert aspx page to pdf. I used iTextsharp to do that. But the problem is my page has text boxes and the pdf file does not show the text box data. am sharing my code. Kindly gv me the solution.
Even am trying to convert aspx page to pdf. I used iTextsharp to do that. But the problem is my page has text boxes and the pdf file does not show the text box data. am sharing my code. Kindly gv me the solution.
protected void Page_Load(object sender, EventArgs e)
{
}
protected void SendMail()
{
var userName = "n-4@gmail.com";
var toAddress = YourEmail.Text.ToString();
const string Password = "Mypassword"
string subject = YourSubject.Text.ToString();
string body = "From: " + YourName.Text + "\n";
body += "Email: " + YourEmail.Text + "\n";
body += "Subject: " + YourSubject.Text + "\n";
body += "Question: \n" + Comments.Text + "\n";
var smtp = new System.Net.Mail.SmtpClient();
{
smtp.Host = "10.238.52.200";
smtp.Port = 25;
smtp.EnableSsl = false;
smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtp.Credentials = new NetworkCredential(userName, Password);
smtp.Timeout = 20000;
}
smtp.Send(userName, toAddress, subject, body);
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=TestPage.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw);
this.Page.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 100f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
Response.Write(pdfDoc);
try
{
SendMail();
DisplayMessage.Text = "Your Comments after sending the mail";
DisplayMessage.Visible = true;
YourSubject.Text = "";
YourEmail.Text = "";
YourName.Text = "";
Comments.Text = "";
pdfDoc.Close();
Response.End();
}
catch (Exception) { }
#5
Re: How to convert current aspx content to pdf
Posted 14 September 2012 - 01:44 AM
Will all objects and data inside the page be part of the pdf? Have you tried looking into crystalreports or reportviewer?
#6
Re: How to convert current aspx content to pdf
Posted 18 September 2012 - 12:57 PM
A while back, I wrote a web service that uses EvoPDF to generate .pdfs from a dynamically generated asp page. It isn't free, so if that's what you're looking for, you'll have to start searching. EvoPDF was the best value that I found for our needs, and has a really simple (but very configurable) API.
EDIT: Evo's trial is fully functional and unlimited with regards to time. If this is for a project that you aren't trying to earn money from, then it might be a viable option.
EDIT: Evo's trial is fully functional and unlimited with regards to time. If this is for a project that you aren't trying to earn money from, then it might be a viable option.
This post has been edited by h4nnib4l: 19 September 2012 - 07:22 AM
#7
Re: How to convert current aspx content to pdf
Posted 18 September 2012 - 10:37 PM
Use this .NET PDF Component,it can convert webpage of ASPX,HTML and HTM to PDF by below code:
namespace ASPX to PDF
{
class Program
{
[STAThread]
static void Main(string[] args)
{
//Create a pdf document.
PdfDocument doc = new PdfDocument();
String url = "ASPX URL";
doc.LoadFromHTML(url, false, true, true);
//Save pdf file.
doc.SaveToFile("sample.pdf");
doc.Close();
}
}
}
#8
Re: How to convert current aspx content to pdf
Posted 19 September 2012 - 07:21 AM
You failed to point out that that isn't a free solution, either.
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote




|