jrxml字段属性设置:

<textElement>
<font fontName="宋体" pdfFontName="STSong-Light" pdfEncoding="UniGB-UCS2-H" isPdfEmbedded="true"/>
</textElement>

在工程lib中引入itextasian-1.5.2.jar文件,注意该文件的目录结构为com/lowagie/text/pdf/fonts/*,最新的itext-asian.jar包不是该结构无法正常使用,

JAVA示例代码:

    /****数据库连接****/
public static Connection getConnection() {
Connection conn = null;
String driver = "net.sourceforge.jtds.jdbc.Driver";
String url = "jdbc:jtds:sqlserver://127.0.0.1:1433/CODE-WH";
try {
Class.forName(driver);
conn = DriverManager.getConnection(url,"sa", "123");
return conn;
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException ex) {
ex.printStackTrace();
}
return null;
} public static void main(String[] args) throws Exception {
String fileName = "D:/Coffee.jrxml";
long startTime = System.currentTimeMillis();
// 将报表的定义文件*.jrxml编译成*.jasper文件
String jasperFile = JasperCompileManager.compileReportToFile(fileName);
// 向*.jasper文件中填充数据,这一步将生产出*.jrprint文件
String jrprintFile = JasperFillManager.fillReportToFile(jasperFile,
null, getConnection());
System.out.println("jrprintFile=="+jrprintFile);
// 将.jrprint文件转换成HTML格式
JasperExportManager.exportReportToHtmlFile(jrprintFile);
// 将.jrprint文件转换成PDF格式
JasperExportManager.exportReportToPdfFile(jrprintFile);
// 将.jrprint文件转换成XML格式
//JasperExportManager.exportReportToXmlFile(jrprintFile, false);
// 将.jrprint文件转换成XLS格式(即Excel文件),需要用到POI类库. File sourceFile = new File(jrprintFile);
JasperPrint jasperPrint = (JasperPrint) JRLoader.loadObject(sourceFile);
File destFile = new File(sourceFile.getParent(), jasperPrint.getName()
+ ".xls");
JRXlsExporter exporter = new JRXlsExporter();
exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(destFile));
SimpleXlsReportConfiguration configuration = new SimpleXlsReportConfiguration();
configuration.setOnePagePerSheet(false);
exporter.setConfiguration(configuration);
exporter.exportReport(); long endTime = System.currentTimeMillis();
long time = (endTime - startTime) / 1000;
System.out.println("success with " + time + " s");
}

jasperreports-5.6 + jaspersoftstudio-5.6 生成pdf 文件中文无法正常显示问题的更多相关文章

  1. linux下编译bib、tex生成pdf文件

    实验: 在linux环境下,编译(英文)*.bib和*.tex文件,生成pdf文件. 环境: fedora 20(uname -a : Linux localhost.localdomain 3.19 ...

  2. ThinkPHP3.2.3扩展之生成PDF文件(MPDF)

    目前是PHP生成PDF文件最好的插件了,今天介绍下在ThinkPHP3.2.3里如何使用. 先安照路径放好如图. 下面是使用方法 public function pdf(){ //引入类库 Vendo ...

  3. [轉載]史上最强php生成pdf文件,html转pdf文件方法

    之前有个客户需要把一些html页面生成pdf文件,然后我就找一些用php把html页面围成pdf文件的类.方法是可谓是找了很多很多,什么html2pdf,pdflib,FPDF这些都试过了,但是都没有 ...

  4. asp.net生成PDF文件 (1)

    asp.net生成PDF文件 (1) 这个是例子是网上淘来的,哈哈,很有用的! 首先要到网上下载itextsharp.dll,然后添加引用,主程序如下: 1 2 3 4 5 6 7 8 9 10 11 ...

  5. 怎么用PHP在HTML中生成PDF文件

    原文:Generate PDF from html using PHP 译文:使用PHP在html中生成PDF 译者:dwqs 利用PHP编码生成PDF文件是一个非常耗时的工作.在早期,开发者使用PH ...

  6. JAVA生成PDF文件

    生成PDF文件是主要应用的是ITEXT插件 import java.awt.Color; import java.io.File; import java.io.FileOutputStream; i ...

  7. .NET生成PDF文件

    C#未借助第三方组件,自己封装通用类,生成PDF文件. 调用方式: //路径 string path = @"C:\yuannwu22.pdf"; //内容 string strC ...

  8. 史上最强php生成pdf文件,html转pdf文件方法

    body{ font-family: "Microsoft YaHei UI","Microsoft YaHei",SimSun,"Segoe UI& ...

  9. java调用wkhtmltopdf生成pdf文件,美观,省事

    最近项目需要导出企业风险报告,文件格式为pdf,于是搜了一大批文章都是什么Jasper Report,iText ,flying sauser ,都尝试了一遍,感觉不是我想要的效果, 需要自己调整好多 ...

随机推荐

  1. Unity中使物体自动寻路的方法

    在做一个FPS游戏时,需要敌方自动找到玩家方位并向玩家移动,在查找资料(并走了不少坑)后,我试了三个方法,经测试,这三个方法都能实现自动寻路功能. 方法一:使用Mathf.Lerp()方法 代码很简单 ...

  2. How to: Signing Installers You Create with Inno Setup

    Original Link: http://revolution.screenstepslive.com/s/revolution/m/10695/l/95041-signing-installers ...

  3. POJ 2559 Largest Rectangle in a Histogram -- 动态规划

    题目地址:http://poj.org/problem?id=2559 Description A histogram is a polygon composed of a sequence of r ...

  4. 计算序列中第k小的数

    作者:jostree 转载请注明出处 http://www.cnblogs.com/jostree/p/4046399.html 使用分治算法,首先选择随机选择轴值pivot,并使的序列中比pivot ...

  5. Windows Phone 8 开发初体验

    Windows Phone 8 是当前除了Android.IPhone之外,第3大智能手机运行平台.作为微软技术的忠实fans,一直关注和跟进微软技术的最新进展.这里就给大家简单介绍一下,如何进行Wi ...

  6. MVC 弹出提示框

    第一种弹框成功后要刷新界面 [HttpPost] public ActionResult Add(Maticsoft.Model.Project.ProjectMoneyPlan model) { m ...

  7. css3太极图效果+自动旋转

    主要使用border-radius属性实现圆,半圆,定位坐标覆盖部分模块. 半圆: width: 50%; height: 100%; border-radius:100% 0 0 100% /50% ...

  8. iOS极光推送集成步骤

    1.下载SDK,导入Xcode 2.在苹果开发者中心建立AppId与bundleID进行关联,注意勾选推送功能 3.在苹果开发者中心建立推送证书 4.在极光后台建立应用且上传推送证书 5.建立描述文件 ...

  9. C#动态生成图书信息XML文件

    通过C#动态生成图书信息XML文件,下面有个不错的示例,需要的朋友可以参考下 通过C#动态生成图书信息XML文件(Books.xml),文件如下: 复制代码代码如下: <?xml version ...

  10. ubuntu 12 64 桌面版Oracle11g 安装

    1.Creating the Oracle Inventory Group sudo groupadd oinstall sudo groupadd dba sudo groupadd oper su ...