Hi,
I have two textboxes.I want to generate pdf file when clicking a button.Can any one help me?
Thanks in advance
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Joginder BangerRank #360 · 7K reputationPosted Mar 27, 2014, 10:42 AM EDT
Sreejesh SPRank #1,975 · 740 reputationPosted May 14, 2013, 2:01 AM EDT
Please explain your problem,and what u want
thanks
Sreejesh
Kavi sujaRank #6,237 · 272 reputationPosted May 14, 2013, 2:12 AM EDT
I have the following form.When user enters the contact details and click Convert to Pdf Button The PDF file will be generated.In that pdf the values are arranged properly as in following form.
In buttonclick i wrote the following code:
Document pdfDoc = new Document();
try
{
PdfWriter.GetInstance(pdfDoc, System.Web.HttpContext.Current.Response.OutputStream);
pdfDoc.Open();
//Set Font Properties for PDF File
Font fnt = FontFactory.GetFont("Times New Roman", 14);
PdfPTable PdfTable = new PdfPTable(1);
PdfPCell PdfPCell = null;
//Retrieve content from design side
string chk;
chk = "address";
string adr1 = txtadr1.Text;
PdfPCell = new PdfPCell(new Phrase(new Chunk(chk + adr1)));
PdfTable.AddCell(PdfPCell);
string adr2 = txtadr2.Text;
PdfPCell addrchk = new PdfPCell(new Phrase(new Chunk(adr2)));
PdfTable.AddCell(addrchk);
string adr3 = txtadr3.Text;
PdfPCell addrchk1 = new PdfPCell(new Phrase(new Chunk(adr3)));
PdfTable.AddCell(addrchk1);
string cty = txtcty.Text;
PdfPCell cty1 = new PdfPCell(new Phrase(new Chunk(cty)));
PdfTable.AddCell(cty1);
string stat = txtstat.Text;
PdfPCell stat1 = new PdfPCell(new Phrase(new Chunk(stat)));
PdfTable.AddCell(stat1);
string code = txtcode.Text;
PdfPCell code1 = new PdfPCell(new Phrase(new Chunk(code)));
PdfTable.AddCell(code1);
string cntry = txtcntry.Text;
PdfPCell cntry1 = new PdfPCell(new Phrase(new Chunk(cntry)));
PdfTable.AddCell(cntry1);
string mob = txtmbl.Text;
PdfPCell mob1 = new PdfPCell(new Phrase(new Chunk(mob)));
PdfTable.AddCell(mob1);
pdfDoc.Add(PdfTable);
pdfDoc.Close();
Response.ContentType = "application/pdf";
System.Web.HttpContext.Current.Response.Write(pdfDoc);
Response.Flush();
Response.End();
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
Contact Information
Kavi sujaRank #6,237 · 272 reputationPosted May 14, 2013, 4:09 AM EDT
My Previous code is working fine.
Thank you all.
selvan selva3 reputationPosted Mar 27, 2014, 6:17 AM EDT