c# - Special characters throwing error in ITextSharp -


itextsharp used in application viewing data database in pdf format.

 document document = new document(pagesize.a4);  memorystream stream = new memorystream();   pdfwriter writer = pdfwriter.getinstance(document, stream);  document.open();   pdfptable detail = gettable(4, 500f, 0);  foreach (var stage in stagedetails)    {       detail.addcell(getcelldetails(stage.key,string.empty, 4, 0, 0));                                   detail.addcell(getcelldetails(string.empty,stage.value, 4, 0, 0, 0f, 1, 0, 8, 0, 1));    }                      document.add(detail); 

getcelldetails method generating css style

 public static pdfpcell getcelldetails(string topic, string value, int colspan, int horizontalalignment, int main = 1, float length = 0f, int isheight = 0, int isborder = 0, int paddingbottom = 8, int paddingtop = 0, int ishtml = 0)     {         var phrase = new phrase();         var titlefont = fontfactory.getfont("arial", 12, font.bold);         var subtitlefont = fontfactory.getfont("arial", 10, font.bold);         var subansfont = fontfactory.getfont("arial", 8, font.normal);         if (main == 1)         {             phrase.add(new chunk(topic, titlefont));         }         else         {             if (topic != string.empty && value != string.empty)             {                 phrase.add(new chunk(topic, subtitlefont));                 phrase.add(new chunk(value, subansfont));             }             else if (topic != string.empty)             {                 phrase.add(new chunk(topic, subtitlefont));             }             else if (value != string.empty)             {                 phrase.add(new chunk(value, subansfont));             }         }         paragraph paragraph = new paragraph(phrase);         if (main == 2 || main == 3 || main == 4)         {             if (length >= 100f)             {                 lineseparator lineseparator = new lineseparator((main == 4) ? 3.5f : (main == 2) ? 1.5f : 0.2f, length, basecolor.black, element.align_left, -1);                 paragraph.add(lineseparator);             }             else             {                 lineseparator lineseparator = new lineseparator(1f, length, basecolor.black, element.align_left, -1);                 paragraph.add(lineseparator);             }         }         pdfpcell cell = new pdfpcell(paragraph);         if (ishtml == 1)         {             cell = new pdfpcell();             stylesheet css = new stylesheet();             css.loadtagstyle(htmltags.div, htmltags.fontsize, "8");             css.loadstyle("theader", "size", "15ptx");             css.loadstyle("rows", "color", "red");             css.loadstyle("left", "width", "auto");             css.loadstyle("left", "float", "left");              css.loadstyle("right", "width", "auto");             css.loadstyle("right", "float", "right");             css.loadstyle("right", "border", "solid 1px blue");             css.loadstyle("lbl", "font-weight", "700");             css.loadstyle("content", "size", "15ptx");             string[] spilt = { "<hr/>", "<hr />" };             foreach (string ab in spilt)             {                 value = value.replace(ab, "<table border='1' width=auto cellpadding='0' cellspacing='0'><tr><td>&nbsp;</td></tr></table>");             }             var objects = htmlworker.parsetolist(new stringreader(value), css);             (int k = 0; k < objects.count; ++k)             {                 cell.addelement((ielement)objects[k]);             }         }         if (isheight == 1)         {             cell.minimumheight = 25f;         }         cell.borderwidthbottom = (isborder == 4) || (isborder == 6) || (isborder == 5) || (isborder == 1) || (isborder == 8) || (isborder == 9) || (isborder == 7) ? 1 : 0;         cell.borderwidthright = (isborder == 3) || (isborder == 6) || (isborder == 1) || (isborder == 9) ? 1 : 0;         cell.borderwidthleft = (isborder == 2) || (isborder == 4) || (isborder == 1) || (isborder == 8) ? 1 : 0;         cell.borderwidthtop = (isborder == 1) ? 1 : 0;         cell.colspan = colspan;         if (paddingtop == 1)         {             cell.paddingtop = 8;         }         cell.paddingbottom = paddingbottom;         cell.horizontalalignment = horizontalalignment;         return cell;     } 

the problem special characters, shows error table width must greater zero.how can encode , decode using piece of code?what solution issue?


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -