English 中文(简体)
携带阿拉伯文文本的Tyme page PDF显示空白
原标题:Thymeleaf PDF with Arabic text shows blank

我正在使用Thyme page 版本3.1.2.RELEASE和飞行-saucer-pdf 版本9.3.1<>/code>,以生成来自贾瓦尼亚的申请的PDF。 www.un.org/Depts/DGACM/index_french.htm

<html xmlns:th="http://www.thymeleaf.org" lang="ar" dir="rtl">
  <body>
    <h3 style="text-align: center; color: black">
      <span th:text="${title}"></span>
    </h3>
  </body>
</html>

4. 涂层画面模板的方法:

  private String parseThymeleafTemplate() {
    ClassLoaderTemplateResolver templateResolver = new ClassLoaderTemplateResolver();
    templateResolver.setSuffix(".html");
    templateResolver.setTemplateMode(TemplateMode.HTML);

    TemplateEngine templateEngine = new TemplateEngine();
    templateEngine.setTemplateResolver(templateResolver);

    Context context = new Context();
    context.setVariable("title", "عنوان");

    return templateEngine.process("template", context);
  }

• 采用超文本生成PDF的方法:

  public void onPrintPdfButtonClick() throws DocumentException, IOException {
    String outputFolder = ".../template.pdf";
    OutputStream outputStream = new FileOutputStream(outputFolder);

    ITextRenderer renderer = new ITextRenderer();

    ITextFontResolver resolver = renderer.getFontResolver();
    resolver.addFont("src/main/resources/Al Nile.ttc", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);

    renderer.setDocumentFromString(parseThymeleafTemplate());
    renderer.layout();
    renderer.createPDF(outputStream);

    outputStream.close();
  }

出于某种原因,编造的PDF文档根本就没有内容! 我已将所有文件编为UTF-8。 我也正在增加阿拉伯语,以便解决问题。 至今没有任何工作。 此前曾有过这种情况吗? 我确实有兴趣了解这个问题,因此我们能够共同解决这一问题。

最佳回答

Using font style arial-unicode-ms.ttf worked for Arabic text.

在您的html中添加以下文字:

<style>
            * {
                font-family: "Arial Unicode MS", serif;
            }
</style>
问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...