I've just started using Flying Saucer to display html reports that will be populated by a solution I am creating.
Essentially, I am trying to get Flying Saucer's XHTMLPanel
to display bold, but so far have been unable. I have tried using <b></b>
tags, as well as using <span class="b"></span>
with .b {font-weight:bold;}
and a couple of other methods but so far no success. Below is the trimmed java code I am currently using and the xhtml below that.
public class HALReportViewMain extends JFrame {
XHTMLPanel panel;
FSScrollPane scroll;
public HALReportViewMain() throws Exception{
panel = new XHTMLPanel();
scroll = new FSScrollPane(panel);
panel.setDocument(new File("C:\\Users\\rudi.kershaw\\Desktop\\Report.html"));
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
add(scroll);
setSize((int)new PageFormat().getImageableWidth(), (int)new PageFormat().getImageableHeight());
setVisible(true);
}
public static void main(String[] args) throws Exception {
HALReportViewMain derp = new HALReportViewMain();
}
}
And the a section from the xhtml Report.html;
<html>
<head>
<style type="text/css">
body {font:10px arial,sans-serif;}
p {margin-left:5px;}
.b {font-weight:800;display:inline;margin:0;}
#address {position:absolute;top:0px;right:5px;text-align:right}
#picture {position:absolute;top:85px;right:20px;height:120px;width:240px;background-color:#E6E6E6}
.sitecontactswrapper {display:inline-block;margin:0px 10px;}
.sitecontacts {margin:0;}
</style>
</head>
<body>
<div class="sitecontactswrapper">
<p class="sitecontacts"><span class="b">Description: </span>Example</p>
<p class="sitecontacts"><span class="b">Full Name/s: </span>Example</p>
<p class="sitecontacts"><span class="b">Office Phone: </span>Example</p>
<p class="sitecontacts"><span class="b">Mobile Phone: </span>Example</p>
<p class="sitecontacts"><span class="b">Email Address: </span>Example</p>
</div>
</body>
</html>
Seems that Flying Saucer has issues with certain font variants. I changed
font:10px arial,sans-serif;
to
font-size:10px;font-family:"Trebuchet MS";
The fact that I have declared font-size separately is inconsequential. I just did it to separate the issues for testing. I checked other fonts and it appears that Arial, Helvetica, sans-serif and a few others wont be made bold in the XHTMLPanel
. Why this is I have no idea. I will report it to them directly, in case it is a bug of some description.