BoldDesk®Customer service software offering ticketing, live chat, and omnichannel support, starting at $49/mo. for 10 agents. Try it for free.
Please could someone help. I have the following code to show HTML on my pdf. I want the text to appear on a coloured background, so I am first drawing a rectangle with the colour box i need and then the html text over the top. However when i write out the HTML to background colour remains white.
RectangleF layoutRectangle = new RectangleF((float)rectXStartPos, intY + (borderSize / 2), intWidth - borderSize, height - borderSize);
PdfBrush backgroundBrush = new PdfSolidBrush(new PdfColor(255, 0, 0));
page.Graphics.DrawRectangle(backgroundBrush, layoutRectangle);
//HTML TEXT
string htmlText = objTableSetting.Text;
PdfFont font = CreatePdfFont(FONT_NAME, fontSize, FontStyle.Regular);
PdfHTMLTextElement richTextElement = new PdfHTMLTextElement(htmlText, font, CreateSolidBrush(fontColour));
richTextElement.TextAlign = TextAlign.Left;
PdfMetafileLayoutFormat format = new PdfMetafileLayoutFormat();
format.Layout = PdfLayoutType.Paginate;
format.Break = PdfLayoutBreakType.FitPage;
richTextElement.Draw(page, layoutRectangle, format);
If i replace
richTextElement.Draw(page, layoutRectangle, format);'
with
page.Graphics.DrawString(objTableSetting.Text, CreatePdfFont(FONT_NAME, fontSize, FontStyle.Regular), CreateSolidBrush(fontColour), new RectangleF(intX + 5, intY, intWidth - 6, height), objStringFormat);'
it works fine and i get my text on a red background, but obviously the html tages are written out.
Can someone help? Many thanks
Does anyone know the answer please?
Hi Caroline,
Currently we are validating on the reported behavior with the provided details on our end and we will share the further validation on March 17th, 2025.
Regards,
Irfana J.
Hi Caroline,
Regards,
Irfana J.