Harshi
Harshi

Reputation: 163

set attributes of custom tag in iText PdfHTML C#

I created custom tag using PdfHTML.

<condition align="right">Text</condition>

Created custom tag for "condition" to change the value of "Text". It worked. It appeared as "P tag" in the pdf. But it doesn't take attribute align="right". I is always left aligned. How can I set attributes. Created custom css class with below code segment to text alignment.

 if (container != null && cssProps.containsKey(CssConstants.TEXT_ALIGN)) {
            cssProps.put(CssConstants.TEXT_ALIGN, "right");
            BackgroundApplierUtil.applyBackground(cssProps, context, container);
        }

It doesn't work. Please help me to solve this. Thanks in advance

Upvotes: 0

Views: 718

Answers (2)

Harshi
Harshi

Reputation: 163

Finally I found the answer. My mistake is using, "BackgroundApplierUtil.applyBackground(cssProps, context, container)" to apply font.

if (container != null && cssProps.containsKey(CssConstants.TEXT_ALIGN)) {
            cssProps.put(CssConstants.TEXT_ALIGN, "right");
            FontStyleApplierUtil.ApplyFontStyles(cssProps, context,stylecontainer ,container);
        }

Thanks all.

Upvotes: 1

Adam McMahon
Adam McMahon

Reputation: 800

https://developers.itextpdf.com/content/itext-7-converting-html-pdf-pdfhtml/chapter-5-custom-tag-workers-and-css-appliers

This link details everything you need to know about custom tags within iText PDF.

Upvotes: 0

Related Questions