XMLWorker does not support RTL by default. so we need to collect the parsed elements first and then wrap them with a RTL table.
상속: IElementHandler
예제 #1
0
        /// <summary>
        /// Using iTextSharp's HTML to PDF capabilities.
        /// </summary>
        public PdfPCell RenderHtml()
        {
            IElementHandler elementsHandler;

            if (RunDirection == PdfRunDirection.RightToLeft)
            {
                elementsHandler = new RtlElementsCollector();
            }
            else
            {
                elementsHandler = new SimpleElementsCollector();
            }

            processHtml(elementsHandler);

            var runDirection = RunDirection == PdfRunDirection.RightToLeft ? PdfWriter.RUN_DIRECTION_RTL : PdfWriter.RUN_DIRECTION_LTR;
            var cell         = new PdfPCell
            {
                RunDirection        = runDirection,
                HorizontalAlignment = Element.ALIGN_LEFT,
                UseAscender         = true,
                UseDescender        = true
            };

            var paragraph = RunDirection == PdfRunDirection.RightToLeft ?
                            ((RtlElementsCollector)elementsHandler).Paragraph :
                            ((SimpleElementsCollector)elementsHandler).Paragraph;

            cell.AddElement(paragraph);
            return(cell);
        }
예제 #2
0
        /// <summary>
        /// Using iTextSharp's HTML to PDF capabilities.
        /// </summary>
        public PdfPCell RenderHtml()
        {
            IElementHandler elementsHandler;
            if (RunDirection == PdfRunDirection.RightToLeft)
            {
                elementsHandler = new RtlElementsCollector();
            }
            else
            {
                elementsHandler = new SimpleElementsCollector();
            }

            processHtml(elementsHandler);

            var runDirection = RunDirection == PdfRunDirection.RightToLeft ? PdfWriter.RUN_DIRECTION_RTL : PdfWriter.RUN_DIRECTION_LTR;
            var cell = new PdfPCell
            {
                RunDirection = runDirection,
                HorizontalAlignment = Element.ALIGN_LEFT,
                UseAscender = true,
                UseDescender = true
            };

            var paragraph = RunDirection == PdfRunDirection.RightToLeft ?
                                                        ((RtlElementsCollector)elementsHandler).Paragraph :
                                                        ((SimpleElementsCollector)elementsHandler).Paragraph;

            cell.AddElement(paragraph);
            return cell;
        }