How can I display “$£Ω€απ⅔” in Jasperserver PDF using iReport?

血红的双手。 提交于 2019-11-26 01:45:44

问题


I\'ve hardcoded a Text field with the value

 \":$£Ω€απ⅔:\" 

to test if these characters will show in PDF

But it only prints as

:$£€:

I\'ve tried changing the font to \"Symbol\" but that does not do the trick.

Note: I\'m using iReport 5.5


回答1:


I tried your characters using font-extensions in iReport, These are the steps that I took

  1. Download (or use one on your pc) your desired ttf font (it need to support the characters), I used dejavu-serif.
  2. Install the font in iReport or in Jasper soft studio (click links to understand how)

    • I used iReport 5.6 and did set the PDF-Encoding: Idenity-H (unicode with horizontal writing) and embedded the font in pdf. This was the code of my textField

      <textField>
          <reportElement x="8" y="15" width="100" height="20" uuid="41dc1200-091f-4799-a1d2-4622f88a0e84"/>
          <textElement>
              <font fontName="DejaVu Serif" size="13"/>
          </textElement>
          <textFieldExpression><![CDATA[":$£Ω€απ⅔:"]]></textFieldExpression>
      </textField>
      
  3. Export the font extension (this creates a .jar)

  4. Add the jar to your classpath.
  5. Export to pdf and enjoy the result.

This is an example of how to use any arbitrary font, if you like to use DejaVu Sans or DejaVu Serif you can just include the jasper report fonts library in classpath, hence these font are already included and mapped in library




回答2:


I had posted a similar question and the above technique solved my problem, until one fine day I restarted the JasperServer context. I was now getting "PDF encoding not found" error when I tried to export the report to pdf.

To solve this problem I had to copy the iText-Asian.jar and Font-extension.jar in the lib folder of the jasperserver context. "jasperserver/WEB-INF/lib". Once done restart the context and problem solved.

Hope it helps someone.




回答3:


JRDesignStyle normalStyle = new JRDesignStyle();
        normalStyle.setName("tahoma");
        normalStyle.setDefault(true);
        normalStyle.setFontName("../tahoma_0.ttf");
        normalStyle.setPdfFontName("../tahoma_0.ttf");
        normalStyle.setPdfEncoding("Identity-H");
        normalStyle.setPdfEmbedded(true);
        .
        .
        jasperPrint.addStyle(normalStyle);


来源:https://stackoverflow.com/questions/33940126/how-can-i-display-%c2%a3%e2%84%a6%e2%82%ac%ce%b1%cf%80%e2%85%94-in-jasperserver-pdf-using-ireport

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!