1。iTextAsian.jar包有没有加入。
2。源代码
import java.awt.Color;
import java.io.FileOutputStream;
import java.io.IOException;import com.lowagie.text.*;
import com.lowagie.text.pdf.BaseFont;
import com.lowagie.text.pdf.PdfWriter;public class Chap0909 {
public static void main(String[] args) {
System.out.println("Chapter 9 example 9: CJK Fonts");
// step 1: creation of a document-object
Document document = new Document();
Document.compress = false;
try {
// step 2:
// we create a writer that listens to the document
// and directs a PDF-stream to a file
PdfWriter.getInstance(document, new FileOutputStream("Chap0909.pdf"));
// step 3: we open the document
document.open();
String chinese = "我们是害虫";
// step 4: we add content to the document
BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
Font FontChinese = new Font(bfChinese, 12, Font.NORMAL);
Paragraph chunk = new Paragraph(chinese, FontChinese);
document.add(chunk);
}
catch(DocumentException de) {
System.err.println(de.getMessage());
}
catch(IOException ioe) {
System.err.println(ioe.getMessage());
}
// step 5: we close the document
document.close();
}
}3。编译javac -encoding GBK -classpath d:\iText.jar;d:\iTextAsian.jar Chap0909.java
(假设相应的包重命名为iText.jar和iTextAsian.jar且在D盘下)4。执行java -classpath .;d:\iText.jar;d:\iTextAsian.jar; Chap0909
2。源代码
import java.awt.Color;
import java.io.FileOutputStream;
import java.io.IOException;import com.lowagie.text.*;
import com.lowagie.text.pdf.BaseFont;
import com.lowagie.text.pdf.PdfWriter;public class Chap0909 {
public static void main(String[] args) {
System.out.println("Chapter 9 example 9: CJK Fonts");
// step 1: creation of a document-object
Document document = new Document();
Document.compress = false;
try {
// step 2:
// we create a writer that listens to the document
// and directs a PDF-stream to a file
PdfWriter.getInstance(document, new FileOutputStream("Chap0909.pdf"));
// step 3: we open the document
document.open();
String chinese = "我们是害虫";
// step 4: we add content to the document
BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
Font FontChinese = new Font(bfChinese, 12, Font.NORMAL);
Paragraph chunk = new Paragraph(chinese, FontChinese);
document.add(chunk);
}
catch(DocumentException de) {
System.err.println(de.getMessage());
}
catch(IOException ioe) {
System.err.println(ioe.getMessage());
}
// step 5: we close the document
document.close();
}
}3。编译javac -encoding GBK -classpath d:\iText.jar;d:\iTextAsian.jar Chap0909.java
(假设相应的包重命名为iText.jar和iTextAsian.jar且在D盘下)4。执行java -classpath .;d:\iText.jar;d:\iTextAsian.jar; Chap0909
解决方案 »
- struts2 自定义的action继承了actionsupport后,方法名称为什么可以自定义,而不是execute?
- ssh整合报错,哪位高人给解决下
- 一个java面试题,知道的说一下。
- 请教关于txt附件下载的问题(在线等)
- 如何读取虚拟目录下的文件
- 新建了一个页面,可是为什么浏览不到页面
- 关于Apache的安装,进来看看?
- 连数据库出错,急,在线
- jsp中的javabean可以用java本地方法调用c程序吗?
- 请问tomcat中如何添加一个新的上下文?送分100!
- 请问win2000server与unix做web服务器哪种安全性更高,在线等待。。。。
- 请教做投票系统要考虑到哪些因素,如防止重复投票,IP检测等
我没找到,叩首
http://www.lowagie.com/iText/tutorial/ch09.html#CJK
感激不尽,无以言表。
结贴