In case of Chunk we could specify the text and the font which is to be used. For example we can set bold and font size in case of Chunk. While in case of PdfContentByte I am trying to set the text in bold for
PdfContentByte cb = writer.DirectContent;
cb.ShowTextAligned(PdfContentByte.ALIGN_CENTER,"INVOICE",386,596, 0);
using
cb.SetTextRenderingMode(PdfContentByte.TEXT_RENDER_MODE_FILL_STROKE);
But the text being rendered is too Black, is there any way to render the text as that of Chunk to use a font like
Font contentBoldHead = FontFactory.GetFont("Arial-BoldMT", 14, Font.BOLD);
in the PdfContentByte.
Any suggestions would be really helping.
Just to add to what @calum said, the solution is to just use a bold font. SetTextRenderingMode
creates a faux bold which is why it looks bad to you.
cb.SetFontAndSize(FontFactory.GetFont(FontFactory.HELVETICA_BOLD).BaseFont, 20);
cb.BeginText();
cb.ShowTextAligned(PdfContentByte.ALIGN_CENTER, "INVOICE", 386, 596, 0);
cb.EndText();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With