Example #1
0
        /// <summary>
        /// Creates a new
        /// <see cref="HtmlTagWorker"/>
        /// instance.
        /// </summary>
        /// <param name="element">the element</param>
        /// <param name="context">the context</param>
        public HtmlTagWorker(IElementNode element, ProcessorContext context)
        {
            bool        immediateFlush = context.IsImmediateFlush() && !context.GetCssContext().IsPagesCounterPresent();
            PdfDocument pdfDocument    = context.GetPdfDocument();

            document = new Document(pdfDocument, pdfDocument.GetDefaultPageSize(), immediateFlush);
            document.SetRenderer(new HtmlDocumentRenderer(document, immediateFlush));
            document.SetProperty(Property.COLLAPSING_MARGINS, true);
            document.SetFontProvider(context.GetFontProvider());
            if (context.GetTempFonts() != null)
            {
                document.SetProperty(Property.FONT_SET, context.GetTempFonts());
            }
            String fontFamily = element.GetStyles().Get(CssConstants.FONT_FAMILY);
            // TODO DEVSIX-2534
            IList <String> fontFamilies = FontFamilySplitter.SplitFontFamily(fontFamily);

            document.SetProperty(Property.FONT, fontFamilies.ToArray(new String[fontFamilies.Count]));
            inlineHelper = new WaitingInlineElementsHelper(element.GetStyles().Get(CssConstants.WHITE_SPACE), element.
                                                           GetStyles().Get(CssConstants.TEXT_TRANSFORM));
            String lang = element.GetAttribute(AttributeConstants.LANG);

            if (lang != null)
            {
                pdfDocument.GetCatalog().SetLang(new PdfString(lang, PdfEncodings.UNICODE_BIG));
            }
        }
Example #2
0
 /// <summary>
 /// Creates a new
 /// <see cref="PTagWorker"/>
 /// instance.
 /// </summary>
 /// <param name="element">the element</param>
 /// <param name="context">the context</param>
 public PTagWorker(IElementNode element, ProcessorContext context)
 {
     lastParagraph = new Paragraph();
     inlineHelper  = new WaitingInlineElementsHelper(element.GetStyles().Get(CssConstants.WHITE_SPACE), element.
                                                     GetStyles().Get(CssConstants.TEXT_TRANSFORM));
     display = element.GetStyles() != null?element.GetStyles().Get(CssConstants.DISPLAY) : null;
 }
Example #3
0
 /// <summary>
 /// Creates a new
 /// <see cref="LiTagWorker"/>
 /// instance.
 /// </summary>
 /// <param name="element">the element</param>
 /// <param name="context">the context</param>
 public LiTagWorker(IElementNode element, ProcessorContext context)
 {
     listItem = new ListItem();
     if (element.GetAttribute(AttributeConstants.VALUE) != null)
     {
         int?indexValue = (int?)CssDimensionParsingUtils.ParseInteger(element.GetAttribute(AttributeConstants.VALUE
                                                                                           ));
         if (indexValue != null)
         {
             listItem.SetListSymbolOrdinalValue(indexValue.Value);
         }
     }
     if (!(context.GetState().Top() is UlOlTagWorker))
     {
         listItem.SetProperty(Property.LIST_SYMBOL_POSITION, ListSymbolPosition.INSIDE);
         float em = CssDimensionParsingUtils.ParseAbsoluteLength(element.GetStyles().Get(CssConstants.FONT_SIZE));
         if (TagConstants.LI.Equals(element.Name()))
         {
             ListStyleApplierUtil.SetDiscStyle(listItem, em);
         }
         else
         {
             listItem.SetProperty(Property.LIST_SYMBOL, null);
         }
         list = new List();
         list.Add(listItem);
     }
     inlineHelper = new WaitingInlineElementsHelper(element.GetStyles().Get(CssConstants.WHITE_SPACE), element.
                                                    GetStyles().Get(CssConstants.TEXT_TRANSFORM));
     AccessiblePropHelper.TrySetLangAttribute(listItem, element);
 }
Example #4
0
        /// <summary>
        /// Creates a new
        /// <see cref="DivTagWorker"/>
        /// instance.
        /// </summary>
        /// <param name="element">the element</param>
        /// <param name="context">the context</param>
        public DivTagWorker(IElementNode element, ProcessorContext context)
        {
            div = new Div();
            IDictionary <String, String> styles = element.GetStyles();

            inlineHelper = new WaitingInlineElementsHelper(styles == null ? null : styles.Get(CssConstants.WHITE_SPACE
                                                                                              ), styles == null ? null : styles.Get(CssConstants.TEXT_TRANSFORM));
            display = element.GetStyles() != null?element.GetStyles().Get(CssConstants.DISPLAY) : null;
        }
Example #5
0
        /// <summary>
        /// Creates a new
        /// <see cref="SpanTagWorker"/>
        /// instance.
        /// </summary>
        /// <param name="element">the element</param>
        /// <param name="context">the processor context</param>
        public SpanTagWorker(IElementNode element, ProcessorContext context)
        {
            spanWrapper = new SpanWrapper();
            IDictionary <String, String> styles = element.GetStyles();

            inlineHelper = new WaitingInlineElementsHelper(styles == null ? null : styles.Get(CssConstants.WHITE_SPACE
                                                                                              ), styles == null ? null : styles.Get(CssConstants.TEXT_TRANSFORM));
            display       = styles == null ? null : styles.Get(CssConstants.DISPLAY);
            textTransform = styles == null ? null : styles.Get(CssConstants.TEXT_TRANSFORM);
        }
Example #6
0
        /// <summary>
        /// Creates a new
        /// <see cref="SpanTagWorker"/>
        /// instance.
        /// </summary>
        /// <param name="element">the element</param>
        /// <param name="context">the processor context</param>
        public SpanTagWorker(IElementNode element, ProcessorContext context)
        {
            // TODO ideally, this should be refactored. For now, I don't see a beautiful way of passing this information to other workers.
            // Also, we probably should wait a bit until the display support is more or less stable
            spanWrapper = new SpanWrapper();
            IDictionary <String, String> styles = element.GetStyles();

            inlineHelper = new WaitingInlineElementsHelper(styles == null ? null : styles.Get(CssConstants.WHITE_SPACE
                                                                                              ), styles == null ? null : styles.Get(CssConstants.TEXT_TRANSFORM));
            display = element.GetStyles() != null?element.GetStyles().Get(CssConstants.DISPLAY) : null;
        }
Example #7
0
        /// <summary>
        /// Creates a new
        /// <see cref="TdTagWorker"/>
        /// instance.
        /// </summary>
        /// <param name="element">the element</param>
        /// <param name="context">the context</param>
        public TdTagWorker(IElementNode element, ProcessorContext context)
        {
            int?colspan = CssUtils.ParseInteger(element.GetAttribute(AttributeConstants.COLSPAN));
            int?rowspan = CssUtils.ParseInteger(element.GetAttribute(AttributeConstants.ROWSPAN));

            colspan = colspan != null ? colspan : 1;
            rowspan = rowspan != null ? rowspan : 1;
            cell    = new Cell((int)rowspan, (int)colspan);
            cell.SetPadding(0);
            inlineHelper = new WaitingInlineElementsHelper(element.GetStyles().Get(CssConstants.WHITE_SPACE), element.
                                                           GetStyles().Get(CssConstants.TEXT_TRANSFORM));
            display = element.GetStyles() != null?element.GetStyles().Get(CssConstants.DISPLAY) : null;
        }
Example #8
0
 /// <summary>
 /// Creates a new
 /// <see cref="UlOlTagWorker"/>
 /// instance.
 /// </summary>
 /// <param name="element">the element</param>
 /// <param name="context">the context</param>
 public UlOlTagWorker(IElementNode element, ProcessorContext context)
 {
     list = new List().SetListSymbol("");
     //In the case of an ordered list, see if the start attribute can be found
     if (element.GetAttribute(AttributeConstants.START) != null)
     {
         int?startValue = CssUtils.ParseInteger(element.GetAttribute(AttributeConstants.START));
         if (startValue != null)
         {
             list.SetItemStartIndex((int)startValue);
         }
     }
     inlineHelper = new WaitingInlineElementsHelper(element.GetStyles().Get(CssConstants.WHITE_SPACE), element.
                                                    GetStyles().Get(CssConstants.TEXT_TRANSFORM));
 }
Example #9
0
        /// <summary>
        /// Creates a new
        /// <see cref="HtmlTagWorker"/>
        /// instance.
        /// </summary>
        /// <param name="element">the element</param>
        /// <param name="context">the context</param>
        public HtmlTagWorker(IElementNode element, ProcessorContext context)
        {
            bool        immediateFlush = context.IsImmediateFlush() && !context.GetCssContext().IsPagesCounterPresent();
            PdfDocument pdfDocument    = context.GetPdfDocument();

            document = new Document(pdfDocument, pdfDocument.GetDefaultPageSize(), immediateFlush);
            document.SetRenderer(new HtmlDocumentRenderer(document, immediateFlush));
            DefaultHtmlProcessor.SetConvertedRootElementProperties(element.GetStyles(), context, document);
            inlineHelper = new WaitingInlineElementsHelper(element.GetStyles().Get(CssConstants.WHITE_SPACE), element.
                                                           GetStyles().Get(CssConstants.TEXT_TRANSFORM));
            String lang = element.GetAttribute(AttributeConstants.LANG);

            if (lang != null)
            {
                pdfDocument.GetCatalog().SetLang(new PdfString(lang, PdfEncodings.UNICODE_BIG));
            }
        }
 /// <summary>
 /// Creates a new
 /// <see cref="DisplayTableTagWorker"/>
 /// instance.
 /// </summary>
 /// <param name="element">the element</param>
 /// <param name="context">the context</param>
 public DisplayTableRowTagWorker(IElementNode element, ProcessorContext context)
 {
     inlineHelper = new WaitingInlineElementsHelper(element.GetStyles().Get(CssConstants.WHITE_SPACE), element.
                                                    GetStyles().Get(CssConstants.TEXT_TRANSFORM));
     lang = element.GetAttribute(AttributeConstants.LANG);
 }