我有一个字符串,里面有一个例子——它真的很好用,但是当我添加波兰字母时,它们就消失了。我试过这样的事情:
byte[] byteArray = str.getBytes(Charset.forName("UTF-8"));
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArray);
worker.parseXHtml(pdfWriter, document, byteArrayInputStream, Charset.forName("UTF-8"));
但它不会改变任何东西。如何添加波兰语字母?
编辑:它仍然不起作用。
代码:
document.open();
XMLWorkerHelper worker = XMLWorkerHelper.getInstance();
String str = "<html><head></head><body style=\"font-size:12.0pt; font-family:Times New Roman\">"+
"<a href='http://www.rgagnon.com/howto.html'><b>Real's HowTo</b></a>" +
"<h1>Show your support</h1>" +
"<p>It DOES cost a lot to produce this site - in ISP storage and transfer fees</p>" +
"<p>TEST POLSKICH ZNAKÓW: ĄąćCÓ󣳯żŹźĘę</p>" +
"<hr/>" +
"<p>the huge amounts of time it takes for one person to design and write the actual content.</p>" +
"<p>If you feel that effort has been useful to you, perhaps you will consider giving something back?</p>" +
"<p>Donate using PayPalŽ</p>" +
"<p>Contributions via PayPal are accepted in any amount</p>" +
"<p><br/><table border='1'><tr><td>Java HowTo</td></tr><tr>" +
"<td style='background-color:red;'>Javascript HowTo</td></tr>" +
"<tr><td>Powerbuilder HowTo</td></tr></table></p>" +
"</body></html>";
byte[] byteArray = str.getBytes(Charset.forName("UTF-8"));
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArray);
worker.parseXHtml(pdfWriter, document, byteArrayInputStream, Charset.forName("UTF-8"));
document.close();
也许有人会发现一个错误。