某些 HTML 个实体(箭头)未在 PDF (iText) 中呈现
Certain HTML entities (arrows) are not rendered in PDF (iText)
我尝试使用 XMLWorker 和 iText 在 HTML 中呈现 ⇒ ⇔ € © →
。 PDF 中仅出现版权和欧元符号。我使用了 dafault 字体和 Arial 但没有成功。
有没有办法渲染这些实体?有没有其他方法可以在文本中呈现箭头?
正如您在 ParseHtml3 示例中看到的那样,它适用于我:
这是我创建 PDF 的代码:
public void createPdf(String file) throws IOException, DocumentException {
// step 1
Document document = new Document();
// step 2
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(file));
// step 3
document.open();
// step 4
String str = "<html><head></head><body style=\"font-size:12.0pt; font-family:Arial\">"+
"<p>Special symbols: ← ↓ ↔ ↑ → € ©</p>" +
"</body></html>";
XMLWorkerHelper worker = XMLWorkerHelper.getInstance();
InputStream is = new ByteArrayInputStream(str.getBytes());
worker.parseXHtml(writer, document, is);
// step 5
document.close();
}
请注意,所有实体均以小写形式书写。
我尝试使用 XMLWorker 和 iText 在 HTML 中呈现 ⇒ ⇔ € © →
。 PDF 中仅出现版权和欧元符号。我使用了 dafault 字体和 Arial 但没有成功。
有没有办法渲染这些实体?有没有其他方法可以在文本中呈现箭头?
正如您在 ParseHtml3 示例中看到的那样,它适用于我:
这是我创建 PDF 的代码:
public void createPdf(String file) throws IOException, DocumentException {
// step 1
Document document = new Document();
// step 2
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(file));
// step 3
document.open();
// step 4
String str = "<html><head></head><body style=\"font-size:12.0pt; font-family:Arial\">"+
"<p>Special symbols: ← ↓ ↔ ↑ → € ©</p>" +
"</body></html>";
XMLWorkerHelper worker = XMLWorkerHelper.getInstance();
InputStream is = new ByteArrayInputStream(str.getBytes());
worker.parseXHtml(writer, document, is);
// step 5
document.close();
}
请注意,所有实体均以小写形式书写。