Ejemplo n.º 1
0
    public PdfPCell GetRichCell(string html, int colSpan = 1)
    {
        html = this.HtmlDecodeRichText(html);
        var cell = new PdfPCell {
            // Border = 1,
            HorizontalAlignment = Element.ALIGN_LEFT
        };

        iTextSharp.text.Paragraph p = new iTextSharp.text.Paragraph();
        p.SetLeading(0.1f, 0f);

        //   try {
        List <IElement> htmlArrayList = iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(new StringReader(html), this.GetStyleSheet(true));

        p.InsertRange(0, htmlArrayList);
        //} catch (Exception ex) {
        //    var mh = new MySampleHandler();
        //    using (TextReader sr = new StringReader(html)) {
        //        XMLWorkerHelper.GetInstance().ParseXHtml(mh, sr);
        //    }
        //    p.InsertRange(0, mh.elements);
        //}
        cell.AddElement(p);
        cell.PaddingLeft = 4;
        cell.Colspan     = colSpan;
        return(cell);
    }
Ejemplo n.º 2
0
        /// <summary>
        ///  XMLWorker RTL sample.
        /// </summary>
        /// <param name="args"></param>
        ///
        public static PdfPCell GetRichCell(string html)
        {
            var cell = new PdfPCell {
                Border = 0,
                HorizontalAlignment = Element.ALIGN_LEFT
            };

            iTextSharp.text.Paragraph p = new iTextSharp.text.Paragraph();
            TextReader sr = new StringReader(html);

            // XMLWorkerHelper.GetInstance().ParseXHtml(elementsHandler, sr);
            System.Collections.Generic.List <IElement> htmlArrayList = iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(new StringReader(html), null);
            p.SetLeading(0.1f, 0f);
            p.InsertRange(0, htmlArrayList);
            cell.AddElement(p);
            cell.PaddingLeft = 4;
            return(cell);
        }