用于PDF报告的iReport和Jasperreport字体 [英] iReport and Jasperreport fonts for a PDF report

查看:335
本文介绍了用于PDF报告的iReport和Jasperreport字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用一些默认字体(等宽字体,无衬线字体)与iReport进行了报告。
这个报告有点复杂,许多静态元素的位置都是根据标签的宽度来计算的。
举个例子:

其中长字符串的测试...是一个字段内容,并且这些框是静态元素。
正如你所看到的,我需要一个精确的字符大小。



iReport预览效果很好,但是当我用JasperReport库进行报告时,字体大小确实是真的与iReport预览不同,此外,等宽字体完全不存在。



如何准确创建PDF报告,如ireport preview? b
$ b

这是JRXML头(完整文件大于2000行):

 < ?xml version =1.0encoding =UTF-8?> 
< jasperReport xmlns =http://jasperreports.sourceforge.net/jasperreportsxmlns:xsi =http://www.w3.org/2001/XMLSchema-instancexsi:schemaLocation =http: jsperreports.sourceforge.net/jasperreports.xjdname =107mpageWidth =595pageHeight =842columnWidth =537leftMargin =29 rightMargin =29topMargin =20bottomMargin =20uuid =821aebb9-c4bd-4720-ae38-ae0f7e515398>
< property name =ireport.zoomvalue =1.4641000000000364/>
< property name =ireport.xvalue =0/>
< property name =ireport.yvalue =48/>
< property name =ireport.background.imagevalue =C:\v2(1).png/>
< detail>
< band height =801splitType =Stretch>
< staticText>
< reportElement x =0y =0width =536height =18uuid =07f24965-4a55-49f1-bbaa-c7550bc6b37f/>
< textElement textAlignment =中心>
< font size =11/>
< / textElement>
< text><![CDATA [TITLE]]>< / text>
< / staticText>
< staticText>
< reportElement x =0y =14width =536height =18uuid =06b42267-0de9-4467-96cb-aa477c3f07c1/>
< textElement textAlignment =中心>
< font size =9isBold =true/>
< / textElement>
< text><![CDATA [SUBTITLE]]>< / text>
< / staticText>


解决方案

6.0你使用了像这样的代码

pre $ < font fontName = Times New RomanpdfFontName =Times-RomanisPdfEmbedded =true/>

因为Jasper 6.0这是弃用而你应该使用字体扩展



这是一个很好的

编辑:我在哪里可以找到字体我的电脑?,在Windows上通常在C:\ Windows \Fonts


I made a report with iReport using some default fonts (monospace, sans-serif). This report is a bit complex and many static elements have their position calculated to fit the label's width. Just for example: Where "test of a long string..." is a field content, and the boxes are static elements. As you can see I need a precise char sizes as.

The iReport preview well works, but when I made a report with JasperReport library fonts size are really different from the iReport preview and, moreover, the monospace font doesn't exist at all.

How to exactly create a PDF report like ireport preview?

This is the JRXML head (full file is >2000 rows):

<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="107m" pageWidth="595" pageHeight="842" columnWidth="537" leftMargin="29" rightMargin="29" topMargin="20" bottomMargin="20" uuid="821aebb9-c4bd-4720-ae38-ae0f7e515398">
    <property name="ireport.zoom" value="1.4641000000000364"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="48"/>
    <property name="ireport.background.image" value="C:\v2(1).png"/>
    <property name="ireport.background.image.properties" value="true,true,0.25,1,-202,-7,184,612,865"/>
    <detail>
        <band height="801" splitType="Stretch">
            <staticText>
                <reportElement x="0" y="0" width="536" height="18" uuid="07f24965-4a55-49f1-bbaa-c7550bc6b37f"/>
                <textElement textAlignment="Center">
                    <font size="11"/>
                </textElement>
                <text><![CDATA[TITLE]]></text>
            </staticText>
            <staticText>
                <reportElement x="0" y="14" width="536" height="18" uuid="06b42267-0de9-4467-96cb-aa477c3f07c1"/>
                <textElement textAlignment="Center">
                    <font size="9" isBold="true"/>
                </textElement>
                <text><![CDATA[SUBTITLE]]></text>
            </staticText>

解决方案

To get the same font in pdf export previous to Jasper 6.0 you used

code like this

<font fontName="Times New Roman" pdfFontName="Times-Roman" isPdfEmbedded="true"/>

since Jasper 6.0 this is deprecated and you should use font-extension

This is a good guide for how to include font extensions in iReport.

EDIT: Where can I find the font on my pc?, on Windows normally in C:\Windows\Fonts

这篇关于用于PDF报告的iReport和Jasperreport字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆