iText5.3.4 无法读出中文

	import java.io.BufferedReader; 
	import java.io.FileInputStream; 
	import java.io.FileNotFoundException;   
	import java.io.FileOutputStream;   
	import java.io.IOException; 
	import java.io.InputStreamReader; 

	import com.itextpdf.text.Document; 
	import com.itextpdf.text.DocumentException; 
	import com.itextpdf.text.Font; 
	import com.itextpdf.text.FontFactory; 
	import com.itextpdf.text.PageSize; 
	import com.itextpdf.text.Paragraph; 
	import com.itextpdf.text.pdf.CMYKColor; 
	import com.itextpdf.text.pdf.PdfWriter; 

	  
	public class OutputPdf {
	    private static final String URL = "d:/HelloWorld.pdf";   
	    
	    public static void main(String[] args) throws IOException {   
	     
	    Document document = new Document(PageSize.A4, 20, 20, 20, 20); 
	    
	        try {   

	        BufferedReader in = null; 
	        String b ; 
	        in = new BufferedReader(new InputStreamReader( new FileInputStream("D:/SGPREPORT.SGD071D1.20120812.txt"),"UTF-8")); 
	        PdfWriter.getInstance(document, new FileOutputStream(URL)); 
	        document.open(); 
	        
	        while((b = in.readLine()) != null) 
	        { 
	        System.out.println(b); 
	        document.add(new Paragraph(b,FontFactory.getFont(FontFactory.COURIER, 5, Font.BOLD ,new CMYKColor(16, 244, 15, 89)))); 
	            }  
	        document.close(); 
	        in.close(); 
	        } catch (FileNotFoundException e) {   
	            e.printStackTrace();   
	        } catch (DocumentException e) {   
	            e.printStackTrace();   
	        }   
	  
	    }   

}
 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值