Java iText 动态 生成 PDF 文档 表格 中文问题
import java.awt.Color;
import java.io.FileOutputStream;
import com.lowagie.text.Cell;
import com.lowagie.text.Chapter;
import com.lowagie.text.Document;
import com.lowagie.text.Font;
import com.lowagie.text.Image;
import com.lowagie.text.List;
import com.lowagie.text.ListItem;
import com.lowagie.text.PageSize;
import com.lowagie.text.Paragraph;
import com.lowagie.text.Section;
import com.lowagie.text.Table;
import com.lowagie.text.pdf.BaseFont;
import com.lowagie.text.pdf.PdfWriter;
public class ITextDemo {
public boolean iTextTest() {
try {
/** 实例化文档对象 */
Document document = new Document(PageSize.A4, 50, 50, 50, 50);
/** 创建 PdfWriter 对象 */
PdfWriter.getInstance(document,// 文档对象的引用
new FileOutputStream("d:\\ITextTest.pdf"));//文件的输出路径+文件的实际名称
document.open();// 打开文档 /** pdf文档中中文字体的设置,注意一定要添加iTextAsian.jar包 */
BaseFont bfChinese = BaseFont.createFont("STSong-Light",
&nb
相关文档:
/**
* 创建缩略图片
*
* @param orgpath
* @param filename
* @return
* @description: 描述
*/
//此方法对于ssh项目并且针对 上传功能时,非常有用
public static Boolean createAbbreviateImg(String orgpath, String filename) {
Boolea ......
在Java中,synchronized关键字为防止资源冲突提供了支持,其作用域有二种:
实例范围。
对象实例范围内synchronized使用的两种形式:
实例范围同步方法
publicd class syncTest {
…
synchronized void aMethod() {
//需要同步使用的代码
}
}
synchronized aMethod(){}可以防止多个线程同时 ......
方法的重载
:同一个类里面方法的名字相同,方法的参数项(主要是参数类型,参数个数)
不同
,
返回类型可能不同。
重载方法可以具有不同的返回类型,但返回类型本身不足以区分方法的两个版
本。 ......
java文件过滤器的使用代码如下:
测试代码:package file;
import java.io.File;
public class fileFilter {
public static void main(String[] args) {
File file = new File("d:\\");//设置文件路径
for (File fileList : file.listFiles(new file.MyFileFilter())) {
......