c# - Iwant to add Radio button Image inside a pdf document Dynamically by replacing the content using content.replace("String","string menhod) -


protected void btncreatepdf_click(object sender, eventargs e)     {     // create document object     var document = new document(pagesize.a4, 50, 50, 25, 25);      // create new pdfwrite object, writing output memorystream     var output = new memorystream();     var writer = pdfwriter.getinstance(document, output);      // open document writing     document.open();      // read in contents of receipt.htm html template file     string contents = file.readalltext(server.mappath("~/htmltemplate/receipt.htm"));      // replace placeholders user-specified text     contents = contents.replace("[orderid]", txtorderid.text);     contents = contents.replace("[totalprice]", convert.todecimal(txttotalprice.text).tostring("c"));     contents = contents.replace("[orderdate]", datetime.now.toshortdatestring());      var itemstable = @"<table><tr><th style=""font-weight: bold"">item #</th><th style=""font-weight: bold"">item name</th><th style=""font-weight: bold"">qty</th></tr>";     foreach (system.web.ui.webcontrols.listitem item in cblitemspurchased.items)         if (item.selected)         {             // each checkboxlist item has value of itemname|item#|qty, split on | , pull these values out...             var pieces = item.value.split("|".tochararray());             itemstable += string.format("<tr><td>{0}</td><td>{1}</td><td>{2}</td></tr>",                                         pieces[1], pieces[0], pieces[2]);         }     itemstable += "</table>";      contents = contents.replace("[items]", itemstable);       var parsedhtmlelements = htmlworker.parsetolist(new stringreader(contents), null);     foreach (var htmlelement in parsedhtmlelements)         document.add(htmlelement ielement);        // can add additional elements document. let's add image in upper right corner     var logo = itextsharp.text.image.getinstance(server.mappath("~/images/4guysfromrolla.gif"));     logo.setabsoluteposition(440, 800);     document.add(logo);      document.close();      response.contenttype = "application/pdf";     response.addheader("content-disposition", string.format("attachment;filename=receipt-{0}.pdf", txtorderid.text));     response.binarywrite(output.toarray()); }  

there *.htm file replaces text content string content ,but want add radio button checked or unchecked image there based on data value.

using program base created code.


Comments