3

I am using iTextSharp to convert html to pdf.But i am unable to put a check box in pdf.Please help.

Document pdoc = new Document(PageSize.A4, 72, 72, 82, 72);
            MemoryStream ms = new MemoryStream();
            PdfWriter writer = PdfWriter.GetInstance(pdoc, ms);
            pdoc.Open();
            iTextSharp.text.html.simpleparser.HTMLWorker hw =
                         new iTextSharp.text.html.simpleparser.HTMLWorker(pdoc);
            hw.Parse(new StringReader("<input type='checkbox' name='myChkBox' id='myChk'/>"));
           // hw.Parse(new StringReader(myDiv.InnerHtml));
            pdoc.Close();
            Response.AddHeader("Content-Type", "application/pdf");
            Response.AddHeader("Content-Disposition", "attachment;filename=Untitled.pdf");
            Response.OutputStream.Write(ms.GetBuffer(), 0, ms.GetBuffer().Length);
            Response.End();
JIKKU
  • 577
  • 4
  • 9
  • 26
  • 1
    (1.) `HTMLWorker` is no deprecated and it doesn't support `` tags, so that's a dead end. (2.) XHTML is now being parsed with iText's XML Worker. XML Worker doesn't support the `` tag either, but you can easily add support for tags not directly supported by iText and XML Worker. For an example, see: http://itextpdf.com/sandbox/xmlworker/D10_ParseCustomTag – Bruno Lowagie May 29 '14 at 10:27
  • I am also looking for this.I there any C# example for it? – Kamran Shahid Jul 04 '14 at 10:01
  • 1
    Below links may help you http://stackoverflow.com/questions/22186989/add-one-checkbox-with-itextsharp http://stackoverflow.com/questions/13245208/how-to-create-pdfformfields-using-itextsharp – Nisha Salim Nov 20 '15 at 11:22

0 Answers0