仅使用itextpdf使用字母(拉丁语)的HTML的PDF
我相信,对于那些经验丰富的人来说,我的问题的答案非常容易,我事先感谢您。
也就是说,我设法从TextView BodyText
和Titletext
中导出PDF文件,但是我的问题是只有字母(拉丁)字母可以在该PDF文件中看到,我可以't看到一个阿拉伯语,西里尔,印度人或希伯来语等的例子,任何人都可以帮助我,谢谢!!!!!!!!!
在Gradle I中使用:实现'com.itextpdf.tool:xmlworker:5.5.3'
OutputStream file = new FileOutputStream(new File("MyPath"));
Document document = new Document (PageSize.A4);
PdfWriter.getInstance(document, file);
document.open();
Paragraph title = new Paragraph();
title.add(titleText.getText().toString());
title.setSpacingAfter(12.0f);
title.setAlignment(Element.ALIGN_CENTER);
document.add(title);
document.add(new Paragraph("\n"));
HTMLWorker htmlWorker = new HTMLWorker(document);
htmlWorker.parse(new StringReader(Html.toHtml((Spanned) bodyText.getText())));
document.close();
file.close();
I believe that the answer to my question is very easy for those who have had experience with this, and I thank you in advance.
Namely, I managed to export a PDF file from TextView bodyText
and titleText
, but my problem is that only alphabetic (Latin) letters can be seen in that PDF file, I can't see an example in Arabic, Cyrillic, Indian or Hebrew, etc. Can anyone help me, thanks !!!!!!!!
In Gradle I use: implementation 'com.itextpdf.tool:xmlworker:5.5.3'
OutputStream file = new FileOutputStream(new File("MyPath"));
Document document = new Document (PageSize.A4);
PdfWriter.getInstance(document, file);
document.open();
Paragraph title = new Paragraph();
title.add(titleText.getText().toString());
title.setSpacingAfter(12.0f);
title.setAlignment(Element.ALIGN_CENTER);
document.add(title);
document.add(new Paragraph("\n"));
HTMLWorker htmlWorker = new HTMLWorker(document);
htmlWorker.parse(new StringReader(Html.toHtml((Spanned) bodyText.getText())));
document.close();
file.close();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信问题是您在导出时决定使用的字体。 某些字体不支持非拉丁字符。
因此,您可以使用以下字体:
与itextpdf一起使用它:单击此处
I believe the problem is the font that you decided to use when exporting. Some fonts do not support non-Latin characters.
As a result you can use fonts like:
To use it with itextpdf I refrenced this: Click here