Can not convert a html with <b></b> to bold font in the pdf
<td class="flttblbodyB" colspan="3" style="padding-top:3px;"><font class="flt_date"> 02 Jul</font> - Please verify flight times prior to departure</td>
<td class="flttblhdrB" style="padding-top:3px;"><b>AIRLINE RES CODE</b> : </td>
Amendment :
builder.useFont(new File(System.getenv("SystemRoot")+"/fonts/" + "arialuni.ttf"), "Arial Unicode MS", 400, PdfRendererBuilder.FontStyle.NORMAL, true);
builder.useFont(new File(System.getenv("SystemRoot")+"/fonts/" + "arialuni.ttf"), "Arial Unicode MS", 700, PdfRendererBuilder.FontStyle.NORMAL, true);
builder.useFont(new File(System.getenv("SystemRoot")+"/fonts/" + "cour.ttf"), "Courier New", 400, PdfRendererBuilder.FontStyle.NORMAL, true);
builder.useFont(new File(System.getenv("SystemRoot")+"/fonts/" + "courbd.ttf"), "Courier New", 700, PdfRendererBuilder.FontStyle.NORMAL, true);
originally , my program added above lines , however i cannot get a desired result, but after i remove above lines , the pdf can display the normal style and bold style correctly, but my desired font is not set since i remove the above line. So my problem is, is there any way to set the font that i want and have a correct display of bold style.
Did you try to set a breakpoint in PdfBoxFontResolver.resolveFont() and debugging this?
Hi @tszzzyeung
No, the project does not currently support emulating bold fonts. You need to provide a bold version of the font you want to use. It seems you are providing a bold font but it is the same font file as the normal weight.
oh.... that's the problem. thx a lot @danfickle !
but will you guys having enhancement on that? @danfickle
@tszzzyeung I don't think so. This would be a feature that FontBox (part of PdfBox) needs to implement. It's relativ easy (and ugly) to make a font bold by stretching it and then drawing it as streched vector graphics. But you usually want to have the font used as font, so that the text remains selectable in the PDF and the PDF does not expolde (size wise). To have it bold in PDF you need a bold version of the font. Creating such a version of a font is out of scope for this project.
I think there is support for italic & bold emulation in #143 It just needs manual merging. Would anyone like to provide a pr with just this done?
@danfickle As I needed this feature, I've cherry-picked the commit in the PR #143 done by @backslash47 and done a PR :)
RC-14 has been released, so think we can close this.