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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Joginder BangerPosted Mar 27, 2014, 2:42 PM
selvan selvaPosted Mar 27, 2014, 10:17 AM
Kavi sujaPosted May 14, 2013, 8:09 AM
My Previous code is working fine.
Thank you all.
Kavi sujaPosted May 14, 2013, 6:12 AM
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
Sreejesh SPPosted May 14, 2013, 6:01 AM
Please explain your problem,and what u want
thanks
Sreejesh