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. KMP(匹配)

    Description 一块花布条,里面有些图案,另有一块直接可用的小饰条,里面也有一些图案.对于给定的花布条和小饰条,计算一下能从花布条中尽可能剪出几块小饰条来呢? Input 输入中含有一些数据, ...

  2. [翻译][MVC 5 + EF 6] 9:异步和存储过程

    原文:Async and Stored Procedures with the Entity Framework in an ASP.NET MVC Application 1.为什么使用异步代码: ...

  3. 在Window IIS中安装运行node.js应用—你疯了吗

    [原文发表地址]Installing and Running node.js applications within IIS on Windows - Are you mad? [原文发表时间]201 ...

  4. css中>,+,~的用法

    1.>的用法 A>B选择A的所有子元素B(只选择一代) 2.+的用法 A+B选择紧随着A的兄弟元素B 3.~的用法 A~B选择位置处于A后面的所有兄弟元素B(不包含兄弟元素的子元素)

  5. m2e插件的新下载地址

    今天在按照<Maven实战>这本书给eclipse配置maven的m2eclipse插件的时候发现,书中写的老的下载地址http://m2eclipse.sonatype.org/site ...

  6. 不能将“const char [7]”转换为“LPCTSTR”

    試試用強制轉換變數型態的方法吧,像這樣(LPCTSTR)"WinSun",若不行再試L"WinSun",再不行試_L"WinSun".

  7. Python学习笔记—itertools模块

    这篇是看wklken的<Python进阶-Itertools模块小结> 学习itertools模块的学习笔记 在看itertools中各函数的源代码时,刚开始还比较轻松,但后面看起来就比较 ...

  8. Vijos p1165 火烧赤壁 离散化+单调栈

    题目链接:https://vijos.org/p/1165 题意:输入n(n <= 20,000)段线段的端点,问所有线段的长度总和为多少? input: -1 1 5 11 2 9 outpu ...

  9. hdu 3572 Task Schedule

    Task Schedule 题意:有N个任务,M台机器.每一个任务给S,P,E分别表示该任务的(最早开始)开始时间,持续时间和(最晚)结束时间:问每一个任务是否能在预定的时间区间内完成: 注:每一个任 ...

  10. mysql查看表结构命令

    mysql查看表结构命令 mysql查看表结构命令,如下: desc 表名;show columns from 表名;describe 表名;show create table 表名; use inf ...