我想使用FlyingSaucer将包含阿拉伯字符的HTML页面转换为PDF文件,但生成的PDF不包含组合字符并向后打印输出。使用FlyingSaucer将包含阿拉伯字符的HTML页面转换为PDF
HTML:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body style="font-size:15px;font-family: Arial Unicode MS;">
<center style="font-size: 18px; font-family: Arial Unicode MS;">
<b>
<i style="font-family: Arial Unicode MS;">
جميع الحقوق<br />
</i>
</b>
</center>
</body>
</html>
Java的摘录:
String inputFile = "c:\\html.html";
String url = new File(inputFile).toURI().toURL().toString();
String outputFile = "c:\\html.pdf";
OutputStream os = new FileOutputStream(outputFile);
ITextRenderer renderer = new ITextRenderer();
renderer.getFontResolver().addFont("c://ARIALUNI.TTF", BaseFont.IDENTITY_H,BaseFont.EMBEDDED);
renderer.setDocument(url);
renderer.layout();
renderer.createPDF(os);
os.close();
实际PDF结果:
预期PDF结果:
我能做些什么,以获得正确的结果?
其实你正试图画布图像转换为PDF格式??? – CoderNeji 2015-07-07 06:53:48
这看起来像一个飞碟错误给我。阿拉伯语unicode字符处于明确定义的范围内,显然已知它们是RTL(从右到左)。显然浏览器正在渲染RTL,但飞碟不是。将错误报告给Google。 – 2015-07-13 23:47:18
你有阿拉伯语格式的解决方案吗? – Hana90 2017-02-06 10:03:31