将报告导出为PDF时,将更改字体 [英] When export a report to PDF change the font
问题描述
我正在使用 Jaspersoft Studio 5.2 ,并使用 Courier New 字体做了一个报告,当我将它导出为PDF时,它将字体更改为 Arial 。
我只使用 Studio 工具。当我预览的报告是正确的,但是当我出口它发生。
我可以做什么与我的报告导出与快递新字体?
我在报告中使用的textField模型:
$ b
< textField pattern =dd / MM / yyyy HH:mm:ss>
< reportElement uuid =f50b279a-b480-498f-8af7-be7e23c4b80bx =415y =11width =105height =10/>
< textElement>
< font fontName =Courier Newsize =8/>
< / textElement>
< textFieldExpression><![CDATA [new java.util.Date()]]>< / textFieldExpression>
< / textField>
您应该使用 em>机制。 您应该使用窗口 - >首选项对话框创建新的字体: 使用字体系列对话框,您可以将 ttf 档案: 您应该在上下文的帮助下创建一个新的样式菜单: 之后,您可以为此样式设置 font : b 之后,您可以使用这种新的风格: > file: 报表设计在 Studio 中: 结果将是由 Jaspersoft Studion 生成的 文件,并在 Adobe Reader中打开): 注意: 您可以找到更多有关字体扩展名 I'm using Jaspersoft Studio 5.2, and I did a report with Courier New font, and when I exports this to PDF, it's change the font to Arial. I'm using just the Studio tool. When I preview the report is all right, but when I export it's happens. What can I do with my report to export with Courier New font? My textField model that I'm using in report:
You should use the Font Extensions mechanism. You should create a new font with Window -> Preferences dialog: With Font Family dialog you can set ttf file for your font: You should create a new style with help of context menu: After that you can set font for this style: And after that you can use this new style: The jrxml file: The report's design in Studio: And the result will be (pdf file generated by Jaspersoft Studion and opened in Adobe Reader): Note: You can find more info about Font Extensions here 这篇关于将报告导出为PDF时,将更改字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
步骤
在Jaspersoft Studio中创建字体
$ b
创建报表样式
$ b
$ b <?xml version =1.0encoding =UTF-8 ?>
<! - 用Jaspersoft Studio版本创建 - >
< jasperReport xmlns =http://jasperreports.sourceforge.net/jasperreportsxmlns:xsi =http://www.w3.org/2001/XMLSchema-instancexsi:schemaLocation =http: //jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsdname =test_courierlanguage =groovypageWidth =595pageHeight =842columnWidth =555 leftMargin =20rightMargin =20topMargin =20bottomMargin =20uuid =2010b76c-0fe5-4a27-9c86-6846a6f9cc6a>
< property name =com.jaspersoft.studio.data.defaultdataadaptervalue =Sample DB/>
< style name =CustomFontfontName =Courier New/>
< queryString>
<![CDATA [从任务中选择任务]]>
< / queryString>
< field name =TASKclass =java.lang.String/>
< title>
< band height =79splitType =Stretch>
< staticText>
< reportElement uuid =9205f787-f3b4-4b21-b2d9-19f52824e187style =CustomFontx =280y =36width =70height =20/>
< textElement />
< text><![CDATA [Title]]>< / text>
< / staticText>
< / band>
< / title>
< detail>
< band height =20splitType =Stretch>
< textField>
< reportElement uuid =f23e8674-c45d-4dc7-92f3-93e5d0b41c16style =CustomFontx =0y =0width =70height =20/>
< textElement />
< textFieldExpression><![CDATA [$ F {TASK}]]>< / textFieldExpression>
< / textField>
< / band>
< / detail>
< / jasperReport>
< hr>
<textField pattern="dd/MM/yyyy HH:mm:ss">
<reportElement uuid="f50b279a-b480-498f-8af7-be7e23c4b80b" x="415" y="11" width="105" height="10"/>
<textElement>
<font fontName="Courier New" size="8"/>
</textElement>
<textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
</textField>
Steps
Creating font in Jaspersoft Studio
Creating report's style
The sample
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version last-->
<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="test_courier" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="2010b76c-0fe5-4a27-9c86-6846a6f9cc6a">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="Sample DB"/>
<style name="CustomFont" fontName="Courier New"/>
<queryString>
<![CDATA[select task from tasks]]>
</queryString>
<field name="TASK" class="java.lang.String"/>
<title>
<band height="79" splitType="Stretch">
<staticText>
<reportElement uuid="9205f787-f3b4-4b21-b2d9-19f52824e187" style="CustomFont" x="280" y="36" width="70" height="20"/>
<textElement/>
<text><![CDATA[Title]]></text>
</staticText>
</band>
</title>
<detail>
<band height="20" splitType="Stretch">
<textField>
<reportElement uuid="f23e8674-c45d-4dc7-92f3-93e5d0b41c16" style="CustomFont" x="0" y="0" width="70" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{TASK}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>