Java的itext无法在Windows下创buildPDF,在Ubuntu上工作正常

我有

public class Pdf { private static float FONTSIZE = 8; public void open(String filename) throws Exception { /* File f = new File(PATH + filename); if(f.exists() == true) { Runtime.getRuntime().exec("gnome-open " + PATH + filename); //Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler C:/pdf/test.pdf"); // WINDOWS } else { init(filename); } */ init(filename +".pdf"); Runtime.getRuntime().exec("gnome-open " + Config.PATH + filename +".pdf"); } public void init(String filename) throws Exception { Document doc = new Document(PageSize.A4); doc.setMargins(10,10,10); PdfWriter writer = PdfWriter.getInstance(doc,new FileOutputStream(Config.PATH + filename)); doc.open(); doc.addTitle("incasation"); PdfPTable header = new PdfPTable(5); float[] widths = {5.6f,6,8,5,5}; header.setWidths(widths); header.setHorizontalAlignment(Element.ALIGN_CENTER); header.setWidthPercentage(100); header.setSpacingAfter(4); header.addCell(cell("Data: 20.04.2011",0)); PdfPCell pkt = cell("Punct de lucru: COM COM COM COM COM COM COM COM COM COM COM COM COM COM COM",0); pkt.setColspan(2); header.addCell(pkt); PdfPCell cmp = cell("Company: SC ANC CNE",0); cmp.setColspan(2); header.addCell(cmp); PdfPCell pdate = cell("Ultima incasare: 06.03.2011",0); header.addCell(pdate); header.addCell(cell("Zona: ADAAA",0)); header.addCell(cell("Operator: SOME ONE SPECIAL",0)); header.addCell(cell("Procent locatie: 45%",0)); header.addCell(cell("Metoda de plata: cash",0)); doc.add(header); Image img = Image.getInstance(Config.PATH +"tabelka.png"); img.scalePercent(25,25); // ON TOP PdfContentByte cb = writer.getDirectContent(); BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA,"Cp1250",false); cb.setFontAndSize(bf,FONTSIZE); cb.beginText(); float x = doc.getPageSize().getHeight() - 4; float start = x; int j = 0; for(int i=0; i< 5; i++) { j++; if(i > 0 && i % 5 == 0) { cb.endText(); doc.newPage(); cb = writer.getDirectContent(); cb.setFontAndSize(bf,FONTSIZE); cb.beginText(); start = x; j = 1; } doc.add(img); cb.showtextAligned(PdfContentByte.ALIGN_LEFT,"0305/HS",75,start- 53,0); cb.showtextAligned(PdfContentByte.ALIGN_LEFT,"VUKA-HS-025",start - 67.5f,0); // ELEC // IN cb.showtextAligned(PdfContentByte.ALIGN_RIGHT,"000001",293,0); cb.showtextAligned(PdfContentByte.ALIGN_RIGHT,"000003",365,"000002",440,0); // OUT cb.showtextAligned(PdfContentByte.ALIGN_RIGHT,start - 82,0); // SUM cb.showtextAligned(PdfContentByte.ALIGN_CENTER,"0.50",465,start - 73.5f,"999.0",565,0); // MECH // IN cb.showtextAligned(PdfContentByte.ALIGN_RIGHT,start - 110,start - 124,start - 115.5f,0); /// COINS AND NOTES cb.showtextAligned(PdfContentByte.ALIGN_RIGHT,"0.5",156,"1",start - 95.5f,"5","10","50",start - 138,"100",start - 152,0); // COMMENTS cb.showtextAligned(PdfContentByte.ALIGN_LEFT,"comments...",205,start - 138.5f,0); start = (x - (img.getHeight() * 0.25f) * j); } //doc.add(content); cb.endText(); // END PdfPTable footer = new PdfPTable(5); footer.setHorizontalAlignment(Element.ALIGN_CENTER); footer.setWidthPercentage(100); footer.addCell(cell("Total sum: 3397.50",0)); footer.addCell(cell("Total pierderi: 0.00",0)); footer.addCell(cell("Total taxa: 0.00",0)); footer.addCell(cell("Baza de calcul: 3397.50",0)); footer.addCell(cell("Locatie: 1528.88",0)); PdfPCell b = cell("Num. de ordine al primului bilet: 0",0); b.setColspan(2); footer.addCell(b); footer.addCell(cell("Num. de tichete: 0",0)); footer.addCell(cell("Corectie tichete: 0",0)); footer.addCell(cell("Total bilete: 0.00",0)); PdfPCell b1 = cell("Num de ordine al ultimului bilet: 0",0); b1.setColspan(3); footer.addCell(b1); PdfPCell t = cell("Bani ce trebuiesc viratii: 18.441",0); t.setColspan(2); footer.addCell(t); PdfPCell s = cell("Suma de bani platita: de clienti",0); s.setColspan(5); footer.addCell(s); PdfPCell o = cell("Obs: ",0); o.setColspan(5); footer.addCell(o); doc.add(footer); PdfContentByte cb1 = writer.getDirectContent(); BaseFont bf1 = BaseFont.createFont(BaseFont.HELVETICA,false); cb1.setFontAndSize(bf1,FONTSIZE); cb1.beginText(); cb1.showtextAligned(PdfContentByte.ALIGN_RIGHT,"Semnatura Reprezentant Firma",130,start - 210,0); cb1.showtextAligned(PdfContentByte.ALIGN_CENTER,"Semnatura & Stampila Reprezentant",500,"Pemct de lucru",start - 220,0); cb1.endText(); // CLOSE doc.close(); } public PdfPCell cell(String txt,int border) { Font font = new Font(Font.FontFamily.HELVETICA,FONTSIZE); Paragraph p = new Paragraph(txt,font); p.setSpacingAfter(0); PdfPCell cell = new PdfPCell(p); cell.setBorder(border); return cell; } }

我已经将我的项目导出到jar,然后将它编译为exe和windows不工作。 类创build文件的PDF与0kb。 什么可能是错的?

如何获取系统上的声卡列表?

在Haskell屏幕截图?

以编程方式通过Winapi编辑Windows审核策略时,权限错误

为什么python27.dll不是python安装文件夹的一部分,而是Windows系统文件

如何在Ruby中检测和转换DOS / Windows行结束行到UNIX行结束

相关文章

HashMap是Java中最常用的集合类框架,也是Java语言中非常典型...
在EffectiveJava中的第 36条中建议 用 EnumSet 替代位字段,...
介绍 注解是JDK1.5版本开始引入的一个特性,用于对代码进行说...
介绍 LinkedList同时实现了List接口和Deque接口,也就是说它...
介绍 TreeSet和TreeMap在Java里有着相同的实现,前者仅仅是对...
HashMap为什么线程不安全 put的不安全 由于多线程对HashMap进...