Click here to Skip to main content
15,885,309 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Actually i am getting data from tables and i am passing that table values to pdf file every thing is working 5n. but the text in that pdf is not in proper alignment.if needed i will paste my code...
Posted

Send you code block. I am not sure how you pass values, its better to create a formatted HTML doc & see how its look like then pass that document to PDF
 
Share this answer
 
Comments
ntitish 28-Aug-13 5:33am    
but here problem is i passing that html tags form aspx.cs page.....like below code...

string str= <stylerun indent=15 style="font-size:120%" bold=true >1.) Diagnosis (ICD )</stylerun>
Severity POA <br><stylerun indent=15 bold=true style="font-style:italic;">    COT</stylerun><br><list spacebefore=0 spaceafter=0 indentmarker=22 indentitem=25 bold=false style="font-style:italic;">      Plan1 <br></list>
<stylerun indent=15 bold=true>      CPOT </stylerun><br><list spacebefore=0 spaceafter=0 indentmarker=22 indentitem=25 bold=false>     CourceOfTreatment <br></list><br>


i should get out put like below when i convert that string to pdf


1.) Diagnosis (ICD ) Severity POA
COT
Plan1
CPOT
CourceOfTreatment
Hii..
See this one.
C#
Re sponse.ContentType = "application/pdf";
            Response.AddHeader("content-disposition", "attachment;filename=Panel.pdf");
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            StringWriter sw = new StringWriter();
            HtmlTextWriter hw = new HtmlTextWriter(sw);
            pnlPerson.RenderControl(hw);
            StringReader sr = new StringReader(sw.ToString());
            //Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 100f, 0f);
            Document pdfDoc = new Document(PageSize.A3, 100f, 10f, 10f, 10f);
            HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
            PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
            pdfDoc.Open();
//adding Header
            string Header = @"Header Text";
            Paragraph para = new Paragraph(Header);
            para.Alignment = Element.ALIGN_CENTER;
            pdfDoc.Add(para);
//cell11
            PdfPCell cell11 = new PdfPCell();
            cell11.AddElement(new Paragraph("Lable Name:"));
            table1.AddCell(cell11);
            PdfPCell cell12 = new PdfPCell();
            cell12.AddElement(new Paragraph(lbladhar.Text));
            table1.AddCell(cell12);
like convert ur pdf to table format.
thank u.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900