Hi all,
I'm using a custom truetype font in a pdf generated by flying saucer xhtmlrenderer.
ITextRenderer renderer = new ITextRenderer();
renderer.getFontResolver().addFont("myfont.ttf", BaseFont.CP1252, BaseFont.EMBEDDED);
renderer.setDocument(XMLResource.load(in).getDocument(), url);
renderer.layout();
renderer.createPDF(out);
and within the html being rendered, i have the following (for example)
<html>
<head>
<style type="text/css">
*{font-family:myfont;} /* <-- this works, trust me */
</style>
</head>
<body>
<p>some plain text<b>some bold text</b> <span style="font-weight:bold;">more bold</span></p>
</body>
</html>
but even with the <b>
and the font-weight:bold
I can't get the text to come out bold.
Now, i know this should work because i have a similar (legacy) project which uses the same font, and plain old itext (ie no xhtmlrenderer) and it does produce pdfs with bold text via:
myFont = BaseFont.createFont("myfont.ttf", BaseFont.CP1252, BaseFont.EMBEDDED);
Font boldFont = new Font(myFont);
boldFont.setStyle(Font.BOLD);
com.lowagie.text.Document document = ...;
document.add(new Paragraph("plain", myFont));
document.add(new Paragraph("bold", boldFont));
can anyone explain why i can't use bold with xhtmlrenderer, and maybe a way to overcome this issue?
thanks, p.