I am writing a Word document from a string of HTML, see below. The HTML uses font Arial, in the code I am explicitly setting the document builder font to Arial. However the first part of the document is converted as Arial but part way through the font changes to Times New Roman. (The font changes after the table cell containing the image)
The code I am using is as follows:
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Set the paper size and margins
builder.getPageSetup().setPaperSize(PaperSize.A4);
builder.getPageSetup().setLeftMargin(71);
builder.getPageSetup().setRightMargin(71);
builder.moveToDocumentStart();
builder.getFont().setName("Arial");
builder.getFont().setSize(11.0);
builder.insertHtml(htmlText);
The HTML text is as follows:
<html xmlns="<A href=" http: //www.w3.org/1999/xhtml">
http://www.w3.org/1999/xhtml</A>">
<head>
<style type="text/css">
body {
font-family: Arial;
}
h1 {
font-family: Arial;
font-size: 24pt;
font-weight: normal;
color: #003366;
}
p {
font-family: Arial;
font-size: 11pt;
font-weight: normal;
}
p.fineprint {
font-size: 8pt;
text-align: center;
}
span.comment {
border: solid 1px #FFFF00;
background-color: #FFFFCC;
}
</style>
<meta name="generator" content="EditLive! 6.3.3.69" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<table border="0" cellpadding="0" width="100%" cellspacing="0">
<tr>
<td valign="middle" width="42%">
03 May 2008<br />
<br />
<br />
LPM Bohemia - The Tent Company<br />
The Aga Buildings,<br />
Lamberhurst Road,<br />
Kent.<br />
TN12 8DP<br />
<br />
P2P000001
</td>
<td width="58%"><img alt="" src="<A href=" file: ///C:/Select/Applications/Planned2Perfection/Images/p2pLogo.jpg">file:///C:/Select/Applications/Planned2Perfection/Images/p2pLogo.jpg</A>" /></td>
</tr>
</table>
Dear ,
I am pleased to confirm a booking with you as follows:
<table border="0" cellpadding="0" width="704" cellspacing="0">
<tr>
<td width="94"><strong>Date:</strong></td>
<td width="612">Thursday, 17 April 2008</td>
</tr>
<tr>
<td valign="top" width="94"><strong>Venue:</strong></td>
<td width="612">
The Dorchester<br />
Park Lane,<br />
London.<br />
W1A 2HJ
</td>
</tr>
<tr>
<td valign="top" width="94"><strong>Room:</strong></td>
<td width="612"> </td>
</tr>
<tr>
<td width="94"> </td>
<td width="612"> </td>
</tr>
<tr>
<td width="94"> </td>
<td width="612"> </td>
</tr>
<tr>
<td width="94"> </td>
<td width="612"> </td>
</tr>
</table>
 
</body>
</html>