List of usage examples for com.itextpdf.text.pdf PdfPTable setWidths
public void setWidths(final int relativeWidths[]) throws DocumentException
From source file:hsa.awp.admingui.report.printer.PdfPrinter.java
License:Open Source License
@Override public void print(ExportList list) { if (outputStream == null) { throw new IllegalArgumentException("OutputStream undefined, please use setOutputStream()"); }//from ww w .j a va 2 s.c om if (!(list instanceof PdfPrintable)) { throw new IllegalArgumentException("PdfPrinter can only print PdfPrintables"); } PdfPrintable pdfPrintable = (PdfPrintable) list; Document document = setUpDocument(pdfPrintable); try { document.open(); int numberOfColumns = pdfPrintable.getPdfProperties().getCellProperties().size(); int numberOfRows = list.getRows().size(); PdfPTable table = new PdfPTable(numberOfColumns); float[] widths = new float[numberOfColumns]; for (int i = 0; i < widths.length; i++) { widths[i] = pdfPrintable.getPdfProperties().getCellProperties().get(i).getWidth(); } table.setWidths(widths); /* header */ for (PdfCellProperties cellProperties : pdfPrintable.getPdfProperties().getCellProperties()) { PdfPCell cell = new PdfPCell( new Phrase(cellProperties.getHeadline(), FontFactory.getFont(FontFactory.HELVETICA_BOLD))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); } /* content */ int rowIndex = 0; for (Row row : list.getRows()) { int columnIndex = 0; for (String content : row.getContent()) { if (content != null) { PdfPCell cell = new PdfPCell( new Phrase(content, FontFactory.getFont(FontFactory.HELVETICA))); cell.setHorizontalAlignment(pdfPrintable.getPdfProperties().getCellProperties() .get(columnIndex).getAlignment().getPdfAlign()); table.addCell(cell); } else { table.addCell(""); } columnIndex++; } rowIndex++; } // /* footer */ // if (footerFound) { // for (PdfTableColumn tableColumn : cols) { // table.addCell(tableColumn.getFooter()); // } // } document.add(table); document.add(new Phrase(" ")); document.close(); } catch (DocumentException e) { e.printStackTrace(); } }
From source file:htmlparser.pdf.PDFFile.java
public void createScoreTable(Color oddrow_color, Color title_bg_color, Color title_font_color, int highlight) { if (this.opened) { int columnNumber = 0; for (String s : this.parser.getTeams().get(0).getData()) { columnNumber++;/*from www.j a va 2s . c o m*/ } PdfPTable table = new PdfPTable(columnNumber + 1); Font f = new Font(this.fonttype, 13); int row = 1; Font headline = new Font(f); headline.setStyle("bold"); headline.setSize(16); headline.setColor(new BaseColor(title_bg_color.getRGB())); PdfPCell headcell = new PdfPCell(new Paragraph(this.parser.getCompetitionName(), headline)); headcell.setColspan(columnNumber + 1); headcell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(headcell); Font title = new Font(f); title.setStyle("bold"); title.setColor(new BaseColor(title_font_color.getRGB())); for (String s : this.shColNms) { PdfPCell cell = new PdfPCell(new Paragraph(s, title)); cell.setBackgroundColor(new BaseColor(title_bg_color.getRGB())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); } row++; int order = 1; Font tfont = f; Font bold = new Font(f); bold.setStyle("bold"); for (Team t : this.parser.getTeams()) { if (highlight >= 0) { if (order == highlight + 1) { tfont = bold; } else { tfont = f; } } PdfPCell ordercell = new PdfPCell(new Paragraph(Integer.toString(order), tfont)); ordercell.setHorizontalAlignment(Element.ALIGN_CENTER); if (row % 2 == 0) { ordercell.setBackgroundColor(new BaseColor(oddrow_color.getRGB())); } table.addCell(ordercell); for (String s : t.getData()) { PdfPCell cell = new PdfPCell(new Paragraph(s, tfont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); if (row % 2 == 0) { cell.setBackgroundColor(new BaseColor(oddrow_color.getRGB())); } table.addCell(cell); } order++; row++; } try { float[] widths = { 12f, 40f, 13f, 5f, 5f, 5f, 10f, 10f }; table.setWidths(widths); this.document.add(table); } catch (DocumentException ex) { System.out.println("Content exception"); } } }
From source file:htmlparser.pdf.PDFFile.java
public void createMatchTable(Color oddrow_color, Color title_bg_color, Color title_font_color) { if (this.opened) { this.document.newPage(); int columnNumber = 0; for (String s : this.parser.getMatches().get(0).getData()) { columnNumber++;// w w w . j a va 2s .co m } PdfPTable table = new PdfPTable(columnNumber); Font f = new Font(this.fonttype, 13); int row = 1; Font headline = new Font(f); headline.setStyle("bold"); headline.setSize(16); headline.setColor(new BaseColor(title_bg_color.getRGB())); PdfPCell headcell = new PdfPCell(new Paragraph(this.parser.getTeamName(), headline)); headcell.setColspan(columnNumber); headcell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(headcell); Font title = new Font(f); title.setStyle("bold"); title.setColor(new BaseColor(title_font_color.getRGB())); for (String s : this.mhColNms) { PdfPCell cell = new PdfPCell(new Paragraph(s, title)); cell.setBackgroundColor(new BaseColor(title_bg_color.getRGB())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); } row++; for (Match t : this.parser.getMatches()) { for (String s : t.getData()) { PdfPCell cell = new PdfPCell(new Paragraph(s, f)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); if (row % 2 == 0) { cell.setBackgroundColor(new BaseColor(oddrow_color.getRGB())); } table.addCell(cell); } row++; } try { float[] widths = { 26f, 26f, 20f, 8f, 20f }; table.setWidths(widths); this.document.add(table); } catch (DocumentException ex) { } } }
From source file:ictproject.ReportGenerator.java
private PdfPTable getPaniKoSroth(String name) throws Exception { PdfPTable table = new PdfPTable(5); // 3 columns. table.getDefaultCell().setBackgroundColor(BaseColor.GRAY); table.setWidths(new int[] { 1, 1, 2, 1, 1 }); table.addCell(getNepaliPhrase("l;=g+="));//"..")); table.addCell(getNepaliPhrase("j8f g+="));//" .")); table.addCell(// w w w.j a v a2 s.co m getNepaliPhrase("kfgL >f]t ;'Sb} uPsf] cj:yf-clt w]/}%,w]/}$,l7s}#,sd@,5}g!_"));// ? ?? ? ?( ,,,,)")); table.addCell(getNepaliPhrase("kf]v/Lsf] ;+Vof"));// ?")); table.addCell(getNepaliPhrase("s}lkmot"));//")); table.setHeaderRows(2); table.getDefaultCell().setBackgroundColor(null); try { Statement stmt = conn.createStatement(); String sql; String selected = name; sql = "SELECT * from bidamanpanikosrot where name='" + name + "'"; ResultSet rs = stmt.executeQuery(sql); //STEP 5: Extract data from result set while (rs.next()) { table.addCell(numberConverterToUnicode(rs.getString("serialNo"))); table.addCell(numberConverterToUnicode(rs.getString("wardNo"))); table.addCell(numberConverterToUnicode(rs.getString("paniKoSrotCount"))); table.addCell(numberConverterToUnicode(rs.getString("pokharicount"))); table.addCell(getNepaliPhrase(converter(rs.getString("remarks")))); } table.addCell(getNepaliPhrase("hDdf")); table.addCell(""); table.addCell(""); table.addCell(getSum(name, "pokharicount", "bidamanpanikosrot")); table.addCell(""); } catch (SQLException se) { //Handle errors for JDBC se.printStackTrace(); } return table; }
From source file:ictproject.ReportGenerator.java
private PdfPTable janajatiAnusar(String name) throws Exception { PdfPTable table = new PdfPTable(8); table.setWidths(new int[] { 1, 1, 2, 2, 2, 2, 2, 2 }); PdfPCell cell;/*from w ww . ja va 2 s .co m*/ cell = new PdfPCell(getNepaliPhrase("l;=g+="));//s.no cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(getNepaliPhrase("j8f g+="));//ward no cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(getNepaliPhrase("hfthftL cg';f/sf] 3/w'/Lsf] ljj/0f ;+Vof"));// ? ? ?")); cell.setColspan(5); table.addCell(cell); cell = new PdfPCell(getNepaliPhrase("s}lkmot"));//")); cell.setRowspan(2); table.addCell(cell); table.addCell(getNepaliPhrase("blnt"));//")); table.addCell(getNepaliPhrase("cflbjf;LhghftL"));///")); table.addCell(getNepaliPhrase("d'lZnd"));//muslim table.addCell(getNepaliPhrase("cGo"));//?")); table.addCell(getNepaliPhrase("hDdf"));//?")); try { Statement stmt = conn.createStatement(); String sql; sql = "SELECT * from janajatianusarkogharduri where name='" + name + "'"; ResultSet rs = stmt.executeQuery(sql); //STEP 5: Extract data from result set while (rs.next()) { table.addCell(numberConverterToUnicode(rs.getString("sno"))); table.addCell(numberConverterToUnicode(rs.getString("wardNo"))); table.addCell(numberConverterToUnicode(rs.getString("dalit"))); table.addCell(numberConverterToUnicode(rs.getString("adiwsi"))); table.addCell(numberConverterToUnicode(rs.getString("muslim"))); table.addCell(numberConverterToUnicode(rs.getString("anya"))); table.addCell(numberConverterToUnicode(rs.getString("jamma"))); table.addCell(getNepaliPhrase(converter(rs.getString("remarks")))); } } catch (SQLException se) { //Handle errors for JDBC se.printStackTrace(); } table.addCell(getNepaliPhrase("hDdf"));//jamma table.addCell(""); table.addCell(getSum(name, "dalit", "janajatianusarkogharduri")); table.addCell(getSum(name, "adiwsi", "janajatianusarkogharduri")); table.addCell(getSum(name, "muslim", "janajatianusarkogharduri")); table.addCell(getSum(name, "anya", "janajatianusarkogharduri")); table.addCell(getSum(name, "jamma", "janajatianusarkogharduri")); table.addCell(""); return table; }
From source file:ictproject.ReportGenerator.java
private PdfPTable sauchalayKoAwasta(String name) throws Exception { PdfPTable table = new PdfPTable(13); table.setWidths(new int[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }); PdfPCell cell;//from w ww. ja v a 2 s .co m cell = new PdfPCell(getNepaliPhrase("hDdf"));//;..")); cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(getNepaliPhrase("hDdf"));// .")); cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(getNepaliPhrase("zf}rfnosf ljj/0f"));// ")); cell.setColspan(3); table.addCell(cell); cell = new PdfPCell(getNepaliPhrase("v'Nnf lb;fd\"St 3f]if0f"));//?? ? ")); cell.setColspan(2); table.addCell(cell); cell = new PdfPCell(getNepaliPhrase("lk;fj cnu ug]{ u/]sf 3/w'/L ;+Vof"));// ? ? ?")); cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(getNepaliPhrase("lk;fj dn k|of]u ug]{ 3/w'/L ;+Vof"));// ? ? ? ?")); cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(getNepaliPhrase("afof] Uof; rkL{ k|of]u ug]{ 3/w'/L ;+Vof"));// ? ? ? ? ? ?")); cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(getNepaliPhrase("w'Fjf/lxt r'Nxf] ePsf] 3/ ;+Vof"));//?? ?? ? ?")); cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(getNepaliPhrase("w'Fjf/lxt j8f 3f]if0f ePsf]gePsf]"));//?? ?/?")); cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(getNepaliPhrase("s}lkmot")); cell.setRowspan(2); table.addCell(cell); table.addCell(getNepaliPhrase("c:yfoL rkL{ ;+Vof"));//? ? ?")); table.addCell(getNepaliPhrase(":yfoL rkL{ ;+Vof"));//? ? ?")); table.addCell(getNepaliPhrase("rkL{ gePsf] ;+Vof"));//? ? ?")); table.addCell(getNepaliPhrase("ePsf]gePsf"));//?/?")); table.addCell(getNepaliPhrase("ePsf] eP ldlt"));//bhayeko bhaye miti try { Statement stmt = conn.createStatement(); String sql; sql = "SELECT * from sauchalaykoawasta where name='" + name + "'"; ResultSet rs = stmt.executeQuery(sql); //STEP 5: Extract data from result set while (rs.next()) { table.addCell(numberConverterToUnicode(rs.getString("sno"))); table.addCell(numberConverterToUnicode(rs.getString("wardNo"))); table.addCell(numberConverterToUnicode(rs.getString("temporaryToilet"))); table.addCell(numberConverterToUnicode(rs.getString("permanentToilet"))); table.addCell(numberConverterToUnicode(rs.getString("noToilet"))); table.addCell(getNepaliPhrase(converter(rs.getString("bhakonaBhako")))); table.addCell(getNepaliPhrase( converter(rs.getString("bhakonaDate").replace("-", "")).replace("247", ""))); table.addCell(numberConverterToUnicode(rs.getString("urineSeperation"))); table.addCell(numberConverterToUnicode(rs.getString("urineManure"))); table.addCell(numberConverterToUnicode(rs.getString("bioGasUse"))); table.addCell(numberConverterToUnicode(rs.getString("noSmokeGas"))); table.addCell(numberConverterToUnicode(rs.getString("noSmokeWard"))); table.addCell(getNepaliPhrase(converter(rs.getString("remarks")))); } } catch (SQLException se) { //Handle errors for JDBC se.printStackTrace(); } table.addCell(getNepaliPhrase("hDdf")); table.addCell(""); table.addCell(getSum(name, "temporaryToilet", "sauchalaykoawasta")); table.addCell(getSum(name, "permanentToilet", "sauchalaykoawasta")); table.addCell(getSum(name, "noToilet", "sauchalaykoawasta")); table.addCell(""); table.addCell(""); table.addCell(getSum(name, "urineSeperation", "sauchalaykoawasta")); table.addCell(getSum(name, "urineManure", "sauchalaykoawasta")); table.addCell(getSum(name, "bioGasUse", "sauchalaykoawasta")); table.addCell(getSum(name, "noSmokeGas", "sauchalaykoawasta")); table.addCell(getSum(name, "noSmokeWard", "sauchalaykoawasta")); table.addCell(""); return table; }
From source file:info.toegepaste.www.service.ProjectServiceImpl.java
public void createPDFje(List<Score> scores) { try {/*from w ww . java 2 s .c o m*/ Document document = new Document(); // Tijdelijk bestand aanmaken (PDF) File temp = File.createTempFile("resultaat", ".pdf"); //PDF openen en bewerken PdfWriter.getInstance(document, new FileOutputStream(temp.getAbsolutePath())); document.open(); // MetaData toevoegen document.addTitle("Resulaten"); document.addAuthor("Score Tracker"); document.addCreator("Score Tracker"); // Titel toevoegen Paragraph preface = new Paragraph(); preface.add(new Paragraph("Resultaten van de gekozen scores")); addEmptyLine(preface, 2); document.add(preface); // Tabel toevoegen met 5 kolommen PdfPTable table = new PdfPTable(5); PdfPCell c1 = new PdfPCell(new Phrase("Klas")); c1.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(c1); c1 = new PdfPCell(new Phrase("Student")); c1.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(c1); c1 = new PdfPCell(new Phrase("Vak")); c1.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(c1); c1 = new PdfPCell(new Phrase("Test")); c1.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(c1); c1 = new PdfPCell(new Phrase("Resultaat")); c1.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(c1); table.setHeaderRows(1); //tabel opvullen met scores uit "List<Score> scores" for (Score score : scores) { table.addCell(score.getStudent().getKlas().getGroep()); table.addCell(score.getStudent().getNaam()); table.addCell(score.getTest().getVak().getNaam()); table.addCell(score.getTest().getNaam()); table.addCell(score.getPunt() + " / " + score.getTest().getMaxScore()); } // breedte van de kolommen float[] columnWidths = new float[] { 10f, 25f, 20f, 20f, 15f }; table.setWidths(columnWidths); document.add(table); document.close(); // PDF downloaden exportPdf(temp); } catch (Exception e) { e.printStackTrace(); } }
From source file:info.toegepaste.www.service.ProjectServiceImpl.java
public void createPDF(List<Score> scores) { try {// w w w . j a va 2s.c om Document document = new Document(); // Tijdelijk bestand aanmaken (PDF) File temp = File.createTempFile("resultaat", ".pdf"); //PDF openen en bewerken PdfWriter.getInstance(document, new FileOutputStream(temp.getAbsolutePath())); document.open(); // MetaData toevoegen document.addTitle("Resulaten"); document.addAuthor("Score Tracker"); document.addCreator("Score Tracker"); // Titel toevoegen Paragraph preface = new Paragraph(); preface.add(new Paragraph("Resultaten van de gekozen scores")); addEmptyLine(preface, 2); document.add(preface); // Tabel toevoegen PdfPTable table = new PdfPTable(4); PdfPCell c1 = new PdfPCell(new Phrase("Student")); c1.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(c1); c1 = new PdfPCell(new Phrase("Vak")); c1.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(c1); c1 = new PdfPCell(new Phrase("Test")); c1.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(c1); c1 = new PdfPCell(new Phrase("Resultaat")); c1.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(c1); table.setHeaderRows(1); //tabel opvullen met scores uit "List<Score> scores" for (Score score : scores) { table.addCell(score.getStudent().getNaam()); table.addCell(score.getTest().getVak().getNaam()); table.addCell(score.getTest().getNaam()); table.addCell(score.getPunt() + " / " + score.getTest().getMaxScore()); } // breedte van de kolommen float[] columnWidths = new float[] { 10f, 25f, 20f, 20f, 15f }; table.setWidths(columnWidths); document.add(table); document.close(); // PDF downloaden exportPdf(temp); } catch (Exception e) { e.printStackTrace(); } }
From source file:Integral.PDF.java
/** * Crea una objeto de tipo tabla// w ww. j a va 2s .c o m * @param columnas numero de columnas * @param tamanio Tamao de las columnas * @param porcentaje proporcion de la tabla deacuerdo a la hoja. * @param alineacion alineacion de la tabla respecto a la hoja * @return */ public PdfPTable crearTabla(int columnas, float tamanio[], int porcentaje, int alineacion) { try { PdfPTable table = new PdfPTable(columnas); table.setWidths(tamanio); table.setWidthPercentage(porcentaje); table.setHorizontalAlignment(alineacion); return table; } catch (DocumentException e) { System.out.println(e); return null; } }
From source file:it.vige.magazzino.pdf.Format1DocumentReceipt.java
License:Apache License
@Model public void build(Receipt receipt) throws Exception { ResourceBundle bundle = ResourceBundle.getBundle("messages"); Document document = new Document(); ByteArrayOutputStream bytesOS = new ByteArrayOutputStream(); PdfWriter writer = PdfWriter.getInstance(document, bytesOS); document.open();//from w w w . j av a 2s .c o m Font normalFont = new Font(); Font headerFont = FontFactory.getFont(FontFactory.TIMES, 9); PdfContentByte canvas = writer.getDirectContentUnder(); List<Data> imagesJar = receipt.getJar().getFiles(); if (imagesJar != null && imagesJar.size() > 0) { Image image1 = Image.getInstance(imagesJar.get(0).getData()); image1.setAbsolutePosition(166, 738); image1.scalePercent(60); document.add(image1); if (imagesJar.size() > 1) { Image image2 = Image.getInstance(imagesJar.get(1).getData()); image2.setAbsolutePosition(326, 748); image2.scalePercent(40); document.add(image2); } } Phrase phrase1 = new Phrase(receipt.getJar().getRagSoc1(), normalFont); Phrase phrase2 = new Phrase( receipt.getJar().getAddress().getAddress() + " " + receipt.getJar().getAddress().getCivicNumber(), normalFont); Phrase phrase3 = new Phrase("Loc. " + receipt.getJar().getAddress().getTown() + " - " + receipt.getJar().getAddress().getCap() + " " + receipt.getJar().getAddress().getCity() + " (" + receipt.getJar().getAddress().getProvince() + ")", normalFont); Phrase phrase4 = new Phrase("Tel. " + receipt.getJar().getAddress().getPhone() + " r.a.Fax " + receipt.getJar().getAddress().getFax(), normalFont); Phrase phrase5 = new Phrase( receipt.getJar().getAddress().getSite() + " E-mail: " + receipt.getJar().getAddress().getEmail(), normalFont); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase1, 36, 784, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase2, 36, 774, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase3, 36, 764, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase4, 36, 754, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase5, 36, 744, 0); Phrase phrase6 = new Phrase(bundle.getString("magazzino_iva") + " " + receipt.getJar().getIva(), normalFont); Phrase phrase7 = new Phrase(bundle.getString("magazzino_capsoc") + " " + receipt.getJar().getCapSoc() + " - " + bundle.getString("magazzino_reapi") + " n. " + receipt.getJar().getReaPI(), normalFont); Phrase phrase8 = new Phrase("Reg. Impr. PI n. " + receipt.getJar().getIva(), normalFont); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase6, 36, 724, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase7, 36, 714, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase8, 36, 704, 0); Phrase phrase9 = new Phrase("prova 2: prova 2", normalFont); Phrase phrase10 = new Phrase("prova 3: prova 3", normalFont); Phrase phrase11 = new Phrase("prova 4: prova 4", normalFont); Phrase phrase12 = new Phrase("prova 2: prova 2", normalFont); Phrase phrase13 = new Phrase("prova 3: prova 3", normalFont); Phrase phrase14 = new Phrase("prova 4: prova 4", normalFont); Phrase phrase15 = new Phrase("prova 4: prova 4", normalFont); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase9, 36, 664, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase10, 36, 654, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase11, 36, 644, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase12, 36, 634, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase13, 36, 624, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase14, 36, 614, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase15, 36, 604, 0); List<Data> imagesCustomer = receipt.getCustomer().getFiles(); if (imagesCustomer != null && imagesCustomer.size() > 0) { Image image3 = Image.getInstance(imagesCustomer.get(0).getData()); image3.setAbsolutePosition(212, 664); image3.scalePercent(40); document.add(image3); } Phrase phrase16 = new Phrase(receipt.getCustomer().getName(), normalFont); Phrase phrase17 = new Phrase(receipt.getCustomer().getAddress().getAddress() + ", " + receipt.getCustomer().getAddress().getCivicNumber(), normalFont); Phrase phrase18 = new Phrase( receipt.getCustomer().getAddress().getCap() + " " + receipt.getCustomer().getAddress().getCity() + " " + receipt.getCustomer().getAddress().getProvince(), normalFont); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase16, 206, 644, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase17, 206, 624, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase18, 206, 604, 0); Phrase phrase19 = new Phrase("prova", normalFont); Phrase phrase20 = new Phrase("prova", normalFont); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase19, 316, 694, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase20, 356, 694, 0); Phrase phrase21 = new Phrase( bundle.getString("customer_code").toUpperCase() + " " + bundle.getString("customer").toUpperCase(), headerFont); Phrase phrase22 = new Phrase(bundle.getString("pdf_partita_iva").toUpperCase(), headerFont); Phrase phrase23 = new Phrase(bundle.getString("pdf_agent").toUpperCase(), headerFont); Phrase phrase24 = new Phrase(bundle.getString("pdf_number_receipt").toUpperCase(), headerFont); Phrase phrase25 = new Phrase( bundle.getString("receipt_date").toUpperCase() + " " + bundle.getString("receipt").toUpperCase(), headerFont); Phrase phrase26 = new Phrase(bundle.getString("pdf_number_page").toUpperCase(), headerFont); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase21, 24, 540, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase22, 100, 540, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase23, 176, 540, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase24, 390, 540, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase25, 466, 540, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase26, 542, 540, 0); Phrase phrase27 = new Phrase("aaqaqaq", normalFont); Phrase phrase28 = new Phrase("cddcddcd", normalFont); Phrase phrase29 = new Phrase("cnjcndkd", normalFont); Phrase phrase30 = new Phrase(receipt.getCodeReceipt() + "", normalFont); Phrase phrase31 = new Phrase(receipt.getDate(), normalFont); Phrase phrase32 = new Phrase("tgsb", normalFont); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase27, 36, 530, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase28, 106, 530, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase29, 176, 530, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase30, 396, 530, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase31, 470, 530, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase32, 546, 530, 0); Phrase phrase33 = new Phrase("aaqaqaq", headerFont); Phrase phrase34 = new Phrase("cddcddcd", headerFont); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase33, 24, 513, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase34, 264, 513, 0); Phrase phrase35 = new Phrase("cnjcndkd", normalFont); Phrase phrase36 = new Phrase("dddedreqq", normalFont); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase35, 36, 503, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase36, 276, 503, 0); Phrase phrase37 = new Phrase(bundle.getString("article_code").toUpperCase(), headerFont); Phrase phrase38 = new Phrase(bundle.getString("article_description").toUpperCase(), headerFont); Phrase phrase39 = new Phrase(bundle.getString("article_um").toUpperCase(), headerFont); Phrase phrase40 = new Phrase(bundle.getString("pdf_number_articles").toUpperCase(), headerFont); Phrase phrase41 = new Phrase(bundle.getString("article_prize").toUpperCase(), headerFont); Phrase phrase42 = new Phrase(bundle.getString("pdf_reduction").toUpperCase(), headerFont); Phrase phrase43 = new Phrase(bundle.getString("pdf_amount").toUpperCase(), headerFont); Phrase phrase44 = new Phrase(bundle.getString("pdf_iva").toUpperCase(), headerFont); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, phrase37, 47, 480, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, phrase38, 126, 480, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, phrase39, 286, 480, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, phrase40, 324, 480, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, phrase41, 373, 480, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, phrase42, 440, 480, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, phrase43, 488, 480, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, phrase44, 552, 480, 0); Phrase phrase45 = null; Phrase phrase46 = null; Phrase phrase47 = null; Phrase phrase48 = null; Phrase phrase49 = null; Phrase phrase50 = null; Phrase phrase51 = null; Phrase phrase52 = null; int i = 0; for (i = 0; i < 70; i = i + 15) { phrase45 = new Phrase("dgbsbb", normalFont); phrase46 = new Phrase("323232", normalFont); phrase47 = new Phrase("bbg", normalFont); phrase48 = new Phrase("wefwe", normalFont); phrase49 = new Phrase("ewrew", normalFont); phrase50 = new Phrase("ewr5", normalFont); phrase51 = new Phrase("dsadasd", normalFont); phrase52 = new Phrase("ds", normalFont); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase45, 59, 460 - i, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase46, 126, 460 - i, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase47, 280, 460 - i, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase48, 306, 460 - i, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase49, 368, 460 - i, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase50, 436, 460 - i, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase51, 480, 460 - i, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase52, 556, 460 - i, 0); } int j = 298; if (i - 298 < 0) i = 298; else { j = i; i = 460 - i; } Phrase phrase81 = new Phrase(receipt.getCause(), normalFont); Phrase phrase82 = new Phrase(receipt.getDescription(), normalFont); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase81, 59, i, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase82, 326, i, 0); Phrase phrase53 = new Phrase(bundle.getString("pdf_total_goods").toUpperCase(), headerFont); Phrase phrase54 = new Phrase(bundle.getString("pdf_reduction").toUpperCase(), headerFont); Phrase phrase55 = new Phrase(bundle.getString("pdf_total_net").toUpperCase(), headerFont); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase53, 26, i - 30, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase54, 104, i - 30, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase55, 182, i - 30, 0); Phrase phrase56 = new Phrase("opoppp", normalFont); Phrase phrase57 = new Phrase("2ws", normalFont); Phrase phrase58 = new Phrase("78900", normalFont); ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, phrase56, 96, i - 50, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, phrase57, 176, i - 50, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, phrase58, 252, i - 50, 0); Phrase phrase59 = new Phrase(bundle.getString("pdf_expiries").toUpperCase(), headerFont); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase59, 36, i - 70, 0); Phrase phrase60 = new Phrase("78900", normalFont); Phrase phrase61 = new Phrase("opoppp", normalFont); Phrase phrase62 = new Phrase("2ws", normalFont); ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, phrase60, 166, i - 90, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, phrase61, 166, i - 110, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, phrase62, 166, i - 130, 0); Phrase phrase63 = new Phrase("78900", normalFont); Phrase phrase64 = new Phrase("opoppp", normalFont); Phrase phrase65 = new Phrase("2ws", normalFont); ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, phrase63, 256, i - 90, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, phrase64, 256, i - 110, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, phrase65, 256, i - 130, 0); Phrase phrase66 = new Phrase(bundle.getString("pdf_transport").toUpperCase(), headerFont); Phrase phrase67 = new Phrase(bundle.getString("pdf_caching").toUpperCase(), headerFont); Phrase phrase68 = new Phrase(bundle.getString("pdf_various_costs").toUpperCase(), headerFont); Phrase phrase69 = new Phrase(bundle.getString("pdf_stamps").toUpperCase(), headerFont); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase66, 260, i - 30, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase67, 340, i - 30, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase68, 418, i - 30, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase69, 496, i - 30, 0); Phrase phrase70 = new Phrase("2ws", normalFont); Phrase phrase71 = new Phrase("78900", normalFont); Phrase phrase72 = new Phrase("opoppp", normalFont); Phrase phrase73 = new Phrase("2ws", normalFont); ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, phrase70, 300, i - 50, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, phrase71, 390, i - 50, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, phrase72, 468, i - 50, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, phrase73, 546, i - 50, 0); Phrase phrase74 = new Phrase(bundle.getString("article_imponible").toUpperCase(), headerFont); Phrase phrase75 = new Phrase(bundle.getString("pdf_tax").toUpperCase(), headerFont); Phrase phrase76 = new Phrase(bundle.getString("pdf_total_receipt").toUpperCase(), headerFont); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase74, 260, i - 70, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase75, 352, i - 70, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase76, 484, i - 70, 0); Phrase phrase77 = new Phrase("2ws", normalFont); Phrase phrase78 = new Phrase("78900", normalFont); Phrase phrase79 = new Phrase("opoppp", normalFont); Phrase phrase80 = new Phrase("2ws", normalFont); ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, phrase77, 310, i - 90, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase78, 352, i - 90, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, phrase79, 450, i - 90, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, phrase80, 536, i - 110, 0); PdfPTable table = new PdfPTable(1); table.getDefaultCell().setPadding(50); table.setWidthPercentage(105); PdfPCell cell = new PdfPCell(); cell.setPadding(127); table.addCell(cell); document.add(table); table = new PdfPTable(6); table.getDefaultCell().setPadding(5); table.setWidthPercentage(105); table.setWidths(new float[] { 7, 7, 20, 7, 7, 3 }); cell = new PdfPCell(); cell.setPadding(14); table.addCell(cell); table.addCell(cell); table.addCell(cell); table.addCell(cell); table.addCell(cell); table.addCell(cell); document.add(table); table = new PdfPTable(2); table.getDefaultCell().setPadding(5); table.setWidthPercentage(105); table.setWidths(new float[] { 15.5f, 20 }); cell = new PdfPCell(); cell.setPadding(14); table.addCell(cell); table.addCell(cell); document.add(table); table = new PdfPTable(1); table.getDefaultCell().setPadding(50); table.setWidthPercentage(105); cell = new PdfPCell(); cell.setPadding(3); table.addCell(cell); document.add(table); table = new PdfPTable(7); table.getDefaultCell().setPadding(100); table.setWidths(new float[] { 23.5f, 2, 5, 6, 4, 7, 3 }); table.setWidthPercentage(105); cell = new PdfPCell(); cell.setPadding(j * 8 - 2279); table.addCell(cell); table.addCell(cell); table.addCell(cell); table.addCell(cell); table.addCell(cell); table.addCell(cell); table.addCell(cell); document.add(table); table = new PdfPTable(7); table.getDefaultCell().setPadding(5); table.setWidthPercentage(105); cell = new PdfPCell(); cell.setPadding(17); table.addCell(cell); table.addCell(cell); table.addCell(cell); table.addCell(cell); table.addCell(cell); table.addCell(cell); table.addCell(cell); document.add(table); table = new PdfPTable(4); table.getDefaultCell().setPadding(5); table.setWidths(new float[] { 10.5f, 4, 6, 4 }); table.setWidthPercentage(105); cell = new PdfPCell(); cell.setPadding(48); table.addCell(cell); table.addCell(cell); table.addCell(cell); table.addCell(cell); document.add(table); document.close(); HttpServletResponse response = (HttpServletResponse) extCtx.getResponse(); response.setContentType("application/pdf"); response.addHeader("Content-disposition", "attachment; filename=\"" + bundle.getString("receipt") + "-" + receipt.getDate() + ".pdf\""); ServletOutputStream os = response.getOutputStream(); os.write(bytesOS.toByteArray()); os.flush(); os.close(); facesContext.responseComplete(); }