List of usage examples for com.itextpdf.text FontFactory getFont
public static Font getFont(final String fontname, final float size)
Font
-object. From source file:de.jost_net.JVerein.gui.action.SpendenbescheinigungPrintAction.java
License:Open Source License
/** * Generierung des Standard-Dokumentes zu verwenden fr Spendenbescheinigungen * ab 01.01.2013//from w w w. j a va 2s .com * * @param spb * Die Spendenbescheinigung aus der Datenbank * @param fileName * Der Dateiname, wohin das Dokument geschrieben werden soll * @throws IOException * @throws DocumentException */ private void generiereSpendenbescheinigungStandardAb2013(Spendenbescheinigung spb, String fileName) throws IOException, DocumentException { final File file = new File(fileName); FileOutputStream fos = new FileOutputStream(file); Map<String, Object> map = spb.getMap(null); map = new AllgemeineMap().getMap(map); boolean isSammelbestaetigung = spb.isSammelbestaetigung(); Reporter rpt = new Reporter(fos, 80, 50, 50, 50); rpt.addHeaderColumn("Aussteller (Bezeichnung und Anschrift der steuerbegnstigten Einrichtung)", Element.ALIGN_CENTER, 100, BaseColor.LIGHT_GRAY); rpt.createHeader(); rpt.addColumn("\n" + getAussteller() + "\n ", Element.ALIGN_LEFT); rpt.closeTable(); if (isSammelbestaetigung) { rpt.add("Sammelbesttigung ber " + map.get(SpendenbescheinigungVar.SPENDEART.getName()), 13); } else { rpt.add("Besttigung ber " + map.get(SpendenbescheinigungVar.SPENDEART.getName()), 13); } rpt.add("im Sinne des 10b des Einkommenssteuergesetzes an eine der in 5 Abs. 1 Nr. 9 des Krperschaftssteuergesetzes " + "bezeichneten Krperschaften, Personenvereinigungen oder Vermgensmassen\n", 10); rpt.addHeaderColumn("Name und Anschrift des Zuwendenden", Element.ALIGN_CENTER, 100, BaseColor.LIGHT_GRAY); rpt.createHeader(); rpt.addColumn((String) map.get(SpendenbescheinigungVar.EMPFAENGER.getName()), Element.ALIGN_LEFT); rpt.closeTable(); switch (spb.getSpendenart()) { case Spendenart.GELDSPENDE: rpt.addHeaderColumn("Betrag der Zuwendung -in Ziffern-", Element.ALIGN_CENTER, 100, BaseColor.LIGHT_GRAY); break; case Spendenart.SACHSPENDE: rpt.addHeaderColumn("Wert der Zuwendung -in Ziffern-", Element.ALIGN_CENTER, 100, BaseColor.LIGHT_GRAY); break; } rpt.addHeaderColumn("-in Buchstaben-", Element.ALIGN_CENTER, 250, BaseColor.LIGHT_GRAY); if (!isSammelbestaetigung) { rpt.addHeaderColumn("Tag der Zuwendung", Element.ALIGN_CENTER, 50, BaseColor.LIGHT_GRAY); } else { rpt.addHeaderColumn("Zeitraum der Sammelbesttigung", Element.ALIGN_CENTER, 75, BaseColor.LIGHT_GRAY); } rpt.createHeader(); rpt.addColumn( "*" + Einstellungen.DECIMALFORMAT.format(map.get(SpendenbescheinigungVar.BETRAG.getName())) + "*", Element.ALIGN_CENTER); rpt.addColumn((String) map.get(SpendenbescheinigungVar.BETRAGINWORTEN.getName()), Element.ALIGN_CENTER); if (!isSammelbestaetigung) { rpt.addColumn((String) map.get(SpendenbescheinigungVar.SPENDEDATUM.getName()), Element.ALIGN_CENTER); } else { rpt.addColumn((String) map.get(SpendenbescheinigungVar.SPENDENZEITRAUM.getName()), Element.ALIGN_CENTER); } rpt.closeTable(); switch (spb.getSpendenart()) { case Spendenart.SACHSPENDE: rpt.addHeaderColumn("Genaue Bezeichnung der Sachzuwendung mit Alter, Zustand, Kaufpreis usw.", Element.ALIGN_CENTER, 100, BaseColor.LIGHT_GRAY); rpt.createHeader(); rpt.addColumn(spb.getBezeichnungSachzuwendung(), Element.ALIGN_LEFT); rpt.closeTable(); switch (spb.getHerkunftSpende()) { case HerkunftSpende.BETRIEBSVERMOEGEN: rpt.add("Die Sachzuwendung stammt nach den Angaben des Zuwendenden aus dem Betriebsvermgen und ist " + "mit dem Entnahmewert (ggf. mit dem niedrigeren gemeinen Wert) bewertet.\n\n", 9); break; case HerkunftSpende.PRIVATVERMOEGEN: rpt.add("Die Sachzuwendung stammt nach den Angaben des Zuwendenden aus dem Privatvermgen.\n\n", 9); break; case HerkunftSpende.KEINEANGABEN: rpt.add("Der Zuwendende hat trotz Aufforderung keine Angaben zur Herkunft der Sachzuwendung gemacht.\n\n", 9); break; } if (spb.getUnterlagenWertermittlung()) { rpt.add("Geeignete Unterlagen, die zur Wertermittlung gedient haben, z. B. Rechnung, Gutachten, liegen vor.\n\n", 9); } } /* * Bei Sammelbesttigungen ist der Verweis auf Verzicht in der Anlage * vermerkt */ String verzicht = ""; char verzichtJa = (char) 113; // box leer char verzichtNein = (char) 53; // X if (spb.getAutocreate()) { if (!isSammelbestaetigung && spb.getSpendenart() == Spendenart.GELDSPENDE) { if (spb.getBuchungen().get(0).getVerzicht().booleanValue()) { verzichtJa = (char) 53; // X verzichtNein = (char) 113; // box leer } } } else { if (spb.getErsatzAufwendungen()) { verzichtJa = (char) 53; // X verzichtNein = (char) 113; // box leer } } if (!isSammelbestaetigung) { Paragraph p = new Paragraph(); p.setFont(Reporter.getFreeSans(9)); p.setAlignment(Element.ALIGN_LEFT); p.add(new Chunk("Es handelt sich um den Verzicht auf Erstattung von Aufwendungen: ")); p.add(new Chunk(" Ja ", Reporter.getFreeSansBold(9))); p.add(new Chunk(verzichtJa, FontFactory.getFont(FontFactory.ZAPFDINGBATS, 10))); p.add(new Chunk(" Nein ", Reporter.getFreeSansBold(9))); p.add(new Chunk(verzichtNein, FontFactory.getFont(FontFactory.ZAPFDINGBATS, 10))); p.add(new Chunk("\n\n")); rpt.add(p); } else { rpt.add(new Paragraph(" ", Reporter.getFreeSans(12))); } if (!Einstellungen.getEinstellung().getVorlaeufig()) { String txt = "Wir sind wegen " + Einstellungen.getEinstellung().getBeguenstigterzweck() + " nach dem letzten uns zugegangenen Freistellungsbescheid bzw. nach der Anlage zum Krperschaftssteuerbescheid des Finanzamtes " + Einstellungen.getEinstellung().getFinanzamt() + ", StNr. " + Einstellungen.getEinstellung().getSteuernummer() + ", vom " + new JVDateFormatTTMMJJJJ().format(Einstellungen.getEinstellung().getBescheiddatum()) + " nach 5 Abs. 1 Nr. 9 des Krperschaftsteuergesetzes von der Krperschaftsteuer und nach 3 Nr. 6 des Gewerbesteuergesetzes von der Gewerbesteuer befreit."; rpt.add(txt, 8); } else { String txt = "Wir sind wegen " + Einstellungen.getEinstellung().getBeguenstigterzweck() + " durch vorlufige Bescheinigung des Finanzamtes " + Einstellungen.getEinstellung().getFinanzamt() + ", StNr. " + Einstellungen.getEinstellung().getSteuernummer() + ", vom " + new JVDateFormatTTMMJJJJ().format(Einstellungen.getEinstellung().getBescheiddatum()) + " ab " + new JVDateFormatTTMMJJJJ().format(Einstellungen.getEinstellung().getVorlaeufigab()) + " als begnstigten Zwecken dienend anerkannt."; rpt.add(txt, 8); } rpt.add("\nEs wird besttigt, dass die Zuwendung nur zur " + Einstellungen.getEinstellung().getBeguenstigterzweck() + " verwendet wird.\n", 8); if (spb.getSpendenart() == Spendenart.GELDSPENDE) { char mitgliedBetraege = (char) 113; // box leer if (!Einstellungen.getEinstellung().getMitgliedsbetraege()) { mitgliedBetraege = (char) 53; // X } Paragraph p = new Paragraph(); p.setFont(Reporter.getFreeSans(9)); p.setAlignment(Element.ALIGN_LEFT); p.add(new Chunk("\n")); p.add(new Chunk( "Nur fr steuerbegnstigte Einrichtungen, bei denen die Mitgliedsbeitrge steuerlich nicht abziehbar sind:")); rpt.add(p); p = new Paragraph(); p.setFont(Reporter.getFreeSans(9)); p.setAlignment(Element.ALIGN_JUSTIFIED); p.setFirstLineIndent((float) -18.5); p.setIndentationLeft((float) 18.5); p.add(new Chunk(mitgliedBetraege, FontFactory.getFont(FontFactory.ZAPFDINGBATS, 10))); p.add(new Chunk( " Es wird besttigt, dass es sich nicht um einen Mitgliedsbeitrag handelt, dessen Abzug nach 10b Abs. 1 des Einkommensteuergesetzes ausgeschlossen ist.")); rpt.add(p); } if (isSammelbestaetigung) { rpt.add(new Paragraph(" ", Reporter.getFreeSans(12))); rpt.add("Es wird besttigt, dass ber die in der Gesamtsumme enthaltenen Zuwendungen keine weiteren Besttigungen, weder formelle Zuwendungsbesttigungen noch Beitragsquittungen oder hnliches ausgestellt wurden und werden.\n", 8); rpt.add("Ob es sich um den Verzicht auf Erstattung von Aufwendungen handelt, ist der Anlage zur Sammelbesttigung zu entnehmen.", 8); } else { rpt.add(new Paragraph(" ", Reporter.getFreeSans(12))); rpt.add("\n\n", 8); rpt.add("\n", 9); } rpt.add("\n\n" + Einstellungen.getEinstellung().getOrt() + ", " + new JVDateFormatTTMMJJJJ().format(spb.getBescheinigungsdatum()), 9); rpt.add("\n\n\n\n.................................................................................\nUnterschrift des Zuwendungsempfngers", 8); rpt.add("\nHinweis:", 9); rpt.add("Wer vorstzlich oder grob fahrlssig eine unrichtige Zuwendungsbesttigung erstellt oder wer veranlasst, dass " + "Zuwendungen nicht zu den in der Zuwendungsbesttigung angegebenen steuerbegnstigten Zwecken verwendet " + "werden, haftet fr die entgangene Steuer ( 10b Abs. 4 EStG, 9 Abs. 3 KStG, 9 Nr. 5 GewStG).\n\n" + "Diese Besttigung wird nicht als Nachweis fr die steuerliche Bercksichtigung der Zuwendung anerkannt, wenn das " + "Datum des Freistellungsbescheides lnger als 5 Jahre bzw. das Datum der vorlufigen Bescheinigung lnger als 3 Jahre " + "seit Ausstellung der Besttigung zurckliegt (BMF vom 15.12.1994 - BStBl I S. 884).", 8); /* Es sind mehrere Spenden fr diese Spendenbescheinigung vorhanden */ if (isSammelbestaetigung) { List<Buchung> buchungen = spb.getBuchungen(); rpt.newPage(); rpt.add(getAussteller(), 13); rpt.add(new Paragraph(" ", Reporter.getFreeSans(12))); rpt.add("Anlage zur Sammelbesttigung vom " + (String) map.get(SpendenbescheinigungVar.BESCHEINIGUNGDATUM.getName()), 11); rpt.add("fr den Zeitraum vom " + (String) map.get(SpendenbescheinigungVar.SPENDENZEITRAUM.getName()), 11); rpt.add(new Paragraph(" ", Reporter.getFreeSans(12))); /* Kopfzeile */ rpt.addHeaderColumn("Datum der\nZuwendung", Element.ALIGN_LEFT, 150, BaseColor.LIGHT_GRAY); rpt.addHeaderColumn("Art der\nZuwendung", Element.ALIGN_LEFT, 400, BaseColor.LIGHT_GRAY); rpt.addHeaderColumn("Verzicht auf die\nErstattung von Aufwendungen", Element.ALIGN_LEFT, 300, BaseColor.LIGHT_GRAY); rpt.addHeaderColumn("Betrag", Element.ALIGN_RIGHT, 150, BaseColor.LIGHT_GRAY); rpt.createHeader(); boolean printBuchungsart = Einstellungen.getEinstellung().getSpendenbescheinigungPrintBuchungsart(); /* Buchungszeilen */ for (Buchung buchung : buchungen) { rpt.addColumn(buchung.getDatum(), Element.ALIGN_RIGHT); String verwendung = ""; if (printBuchungsart) { verwendung = buchung.getBuchungsart().getBezeichnung(); } else { verwendung = buchung.getZweck(); } rpt.addColumn(verwendung, Element.ALIGN_LEFT); if (buchung.getVerzicht().booleanValue()) { verzicht = "ja"; } else { verzicht = "nein"; } rpt.addColumn(verzicht, Element.ALIGN_CENTER); rpt.addColumn(Double.valueOf(buchung.getBetrag())); } /* Summenzeile */ // String sumString = // Einstellungen.DECIMALFORMAT.format(spb.getBetrag()); rpt.addColumn("Gesamtsumme", Element.ALIGN_LEFT, BaseColor.LIGHT_GRAY); rpt.addColumn("", Element.ALIGN_LEFT, BaseColor.LIGHT_GRAY); rpt.addColumn("", Element.ALIGN_LEFT, BaseColor.LIGHT_GRAY); rpt.addColumn(Double.valueOf(spb.getBetrag())); // rpt.addColumn(sumString, Element.ALIGN_RIGHT, // BaseColor.LIGHT_GRAY); rpt.closeTable(); // // Etwas Abstand // rpt.add(new Paragraph(" ")); // // Nun noch die Legende // rpt.add("Legende:", 8); // rpt.add( // "(a): Es handelt sich nicht um den Verzicht auf Erstattung von // Aufwendungen", // 8); // rpt.add( // "(b): Es handelt sich um den Verzicht auf Erstattung von Aufwendungen", // 8); } rpt.close(); fos.close(); }
From source file:de.jost_net.JVerein.gui.action.SpendenbescheinigungPrintAction.java
License:Open Source License
/** * Generierung des Standard-Dokumentes zu verwenden fr Spendenbescheinigungen * ab 01.01.2014// w ww . j ava 2 s . com * * @param spb * Die Spendenbescheinigung aus der Datenbank * @param fileName * Der Dateiname, wohin das Dokument geschrieben werden soll * @throws IOException * @throws DocumentException */ private void generiereSpendenbescheinigungStandardAb2014(Spendenbescheinigung spb, String fileName) throws IOException, DocumentException { final File file = new File(fileName); FileOutputStream fos = new FileOutputStream(file); Map<String, Object> map = spb.getMap(null); map = new AllgemeineMap().getMap(map); boolean isSammelbestaetigung = spb.isSammelbestaetigung(); Reporter rpt = new Reporter(fos, 80, 50, 50, 50); rpt.addHeaderColumn("Aussteller (Bezeichnung und Anschrift der steuerbegnstigten Einrichtung)", Element.ALIGN_CENTER, 100, BaseColor.LIGHT_GRAY); rpt.createHeader(); rpt.addColumn("\n" + getAussteller() + "\n ", Element.ALIGN_LEFT); rpt.closeTable(); if (isSammelbestaetigung) { rpt.add("Sammelbesttigung ber " + map.get(SpendenbescheinigungVar.SPENDEART.getName()), 13); } else { rpt.add("Besttigung ber " + map.get(SpendenbescheinigungVar.SPENDEART.getName()), 13); } rpt.add("im Sinne des 10b des Einkommenssteuergesetzes an eine der in 5 Abs. 1 Nr. 9 des Krperschaftssteuergesetzes " + "bezeichneten Krperschaften, Personenvereinigungen oder Vermgensmassen\n", 10); rpt.addHeaderColumn("Name und Anschrift des Zuwendenden", Element.ALIGN_CENTER, 100, BaseColor.LIGHT_GRAY); rpt.createHeader(); rpt.addColumn((String) map.get(SpendenbescheinigungVar.EMPFAENGER.getName()), Element.ALIGN_LEFT); rpt.closeTable(); switch (spb.getSpendenart()) { case Spendenart.GELDSPENDE: rpt.addHeaderColumn("Betrag der Zuwendung -in Ziffern-", Element.ALIGN_CENTER, 100, BaseColor.LIGHT_GRAY); break; case Spendenart.SACHSPENDE: rpt.addHeaderColumn("Wert der Zuwendung -in Ziffern-", Element.ALIGN_CENTER, 100, BaseColor.LIGHT_GRAY); break; } rpt.addHeaderColumn("-in Buchstaben-", Element.ALIGN_CENTER, 250, BaseColor.LIGHT_GRAY); if (!isSammelbestaetigung) { rpt.addHeaderColumn("Tag der Zuwendung", Element.ALIGN_CENTER, 50, BaseColor.LIGHT_GRAY); } else { rpt.addHeaderColumn("Zeitraum der Sammelbesttigung", Element.ALIGN_CENTER, 75, BaseColor.LIGHT_GRAY); } rpt.createHeader(); rpt.addColumn( "*" + Einstellungen.DECIMALFORMAT.format(map.get(SpendenbescheinigungVar.BETRAG.getName())) + "*", Element.ALIGN_CENTER); rpt.addColumn((String) map.get(SpendenbescheinigungVar.BETRAGINWORTEN.getName()), Element.ALIGN_CENTER); if (!isSammelbestaetigung) { rpt.addColumn((String) map.get(SpendenbescheinigungVar.SPENDEDATUM.getName()), Element.ALIGN_CENTER); } else { rpt.addColumn((String) map.get(SpendenbescheinigungVar.SPENDENZEITRAUM.getName()), Element.ALIGN_CENTER); } rpt.closeTable(); switch (spb.getSpendenart()) { case Spendenart.SACHSPENDE: rpt.addHeaderColumn("Genaue Bezeichnung der Sachzuwendung mit Alter, Zustand, Kaufpreis usw.", Element.ALIGN_CENTER, 100, BaseColor.LIGHT_GRAY); rpt.createHeader(); rpt.addColumn(spb.getBezeichnungSachzuwendung(), Element.ALIGN_LEFT); rpt.closeTable(); switch (spb.getHerkunftSpende()) { case HerkunftSpende.BETRIEBSVERMOEGEN: rpt.add("Die Sachzuwendung stammt nach den Angaben des Zuwendenden aus dem Betriebsvermgen. " + "Die Zuwendung wurde mit dem Wert der Entnahme (ggf. mit dem niedrigeren gemeinen " + "Wert) und nach der Umsatzsteuer, die auf die Entnahme entfllt, bewertet.\n\n", 9); break; case HerkunftSpende.PRIVATVERMOEGEN: rpt.add("Die Sachzuwendung stammt nach den Angaben des Zuwendenden aus dem Privatvermgen.\n\n", 9); break; case HerkunftSpende.KEINEANGABEN: rpt.add("Der Zuwendende hat trotz Aufforderung keine Angaben zur Herkunft der Sachzuwendung gemacht.\n\n", 9); break; } if (spb.getUnterlagenWertermittlung()) { rpt.add("Geeignete Unterlagen, die zur Wertermittlung gedient haben, z. B. Rechnung, Gutachten, liegen vor.\n\n", 9); } } /* * Bei Sammelbesttigungen ist der Verweis auf Verzicht in der Anlage * vermerkt */ String verzicht = ""; char verzichtJa = (char) 113; // box leer char verzichtNein = (char) 53; // X if (spb.getAutocreate()) { if (!isSammelbestaetigung && spb.getSpendenart() == Spendenart.GELDSPENDE) { if (spb.getBuchungen().get(0).getVerzicht().booleanValue()) { verzichtJa = (char) 53; // X verzichtNein = (char) 113; // box leer } } } else { if (spb.getErsatzAufwendungen()) { verzichtJa = (char) 53; // X verzichtNein = (char) 113; // box leer } } if (!isSammelbestaetigung) { Paragraph p = new Paragraph(); p.setFont(Reporter.getFreeSans(8)); p.setAlignment(Element.ALIGN_LEFT); p.add(new Chunk("Es handelt sich um den Verzicht auf Erstattung von Aufwendungen: ")); p.add(new Chunk(" Ja ", Reporter.getFreeSansBold(9))); p.add(new Chunk(verzichtJa, FontFactory.getFont(FontFactory.ZAPFDINGBATS, 10))); p.add(new Chunk(" Nein ", Reporter.getFreeSansBold(9))); p.add(new Chunk(verzichtNein, FontFactory.getFont(FontFactory.ZAPFDINGBATS, 10))); p.add(new Chunk("\n\n")); rpt.add(p); } else { rpt.add(new Paragraph(" ", Reporter.getFreeSans(12))); } if (Einstellungen.getEinstellung().getVorlaeufig()) { // Verein neu gegrndet, hat noch keinen Bescheid String txt = "Die Einhaltung der satzungsgemen Voraussetzungen nach den 51, 59, 60 und 61 " + "AO wurde vom Finanzamt " + Einstellungen.getEinstellung().getFinanzamt() + ", StNr. " + Einstellungen.getEinstellung().getSteuernummer() + ", mit Bescheid vom " + new JVDateFormatTTMMJJJJ().format(Einstellungen.getEinstellung().getBescheiddatum()) + " nach 60a AO gesondert festgestellt. Wir frdern nach unserer Satzung " + Einstellungen.getEinstellung().getBeguenstigterzweck(); rpt.add(txt, 8); } else { // Verein existiert und hat einen Bescheid bekommen String txt = "Wir sind wegen " + Einstellungen.getEinstellung().getBeguenstigterzweck() + " nach dem Freistellungsbescheid bzw. nach der Anlage zum Krperschaftssteuerbescheid " + "des Finanzamtes " + Einstellungen.getEinstellung().getFinanzamt() + ", StNr. " + Einstellungen.getEinstellung().getSteuernummer() + ", vom " + new JVDateFormatTTMMJJJJ().format(Einstellungen.getEinstellung().getBescheiddatum()) + " fr den letzten Veranlagungszeitraum " + new JVDateFormatJJJJ().format(Einstellungen.getEinstellung().getVeranlagungVon()) + " bis " + new JVDateFormatJJJJ().format(Einstellungen.getEinstellung().getVeranlagungBis()) + " nach 5 Abs. 1 Nr. 9 des Krperschaftsteuergesetzes von der Krperschaftsteuer und nach " + " 3 Nr. 6 des Gewerbesteuergesetzes von der Gewerbesteuer befreit."; rpt.add(txt, 8); } rpt.add("\nEs wird besttigt, dass die Zuwendung nur zur " + Einstellungen.getEinstellung().getBeguenstigterzweck() + " verwendet wird.\n", 8); if (spb.getSpendenart() == Spendenart.GELDSPENDE) { char mitgliedBetraege = (char) 113; // box leer if (!Einstellungen.getEinstellung().getMitgliedsbetraege()) { mitgliedBetraege = (char) 53; // X } Paragraph p = new Paragraph(); p.setFont(Reporter.getFreeSans(8)); p.setAlignment(Element.ALIGN_LEFT); p.add(new Chunk("\n")); p.add(new Chunk( "Nur fr steuerbegnstigte Einrichtungen, bei denen die Mitgliedsbeitrge steuerlich nicht abziehbar sind:")); rpt.add(p); p = new Paragraph(); p.setFont(Reporter.getFreeSans(8)); p.setAlignment(Element.ALIGN_JUSTIFIED); p.setFirstLineIndent((float) -18.5); p.setIndentationLeft((float) 18.5); p.add(new Chunk(mitgliedBetraege, FontFactory.getFont(FontFactory.ZAPFDINGBATS, 10))); p.add(new Chunk( " Es wird besttigt, dass es sich nicht um einen Mitgliedsbeitrag handelt, dessen Abzug nach 10b Abs. 1 des Einkommensteuergesetzes ausgeschlossen ist.")); rpt.add(p); } if (isSammelbestaetigung) { rpt.add(new Paragraph(" ", Reporter.getFreeSans(12))); rpt.add("Es wird besttigt, dass ber die in der Gesamtsumme enthaltenen Zuwendungen keine weiteren Besttigungen, weder formelle Zuwendungsbesttigungen noch Beitragsquittungen oder hnliches ausgestellt wurden und werden.\n", 8); rpt.add("Ob es sich um den Verzicht auf Erstattung von Aufwendungen handelt, ist der Anlage zur Sammelbesttigung zu entnehmen.", 8); } else { rpt.add(new Paragraph(" ", Reporter.getFreeSans(12))); rpt.add("\n\n", 8); rpt.add("\n", 9); } rpt.add("\n\n" + Einstellungen.getEinstellung().getOrt() + ", " + new JVDateFormatTTMMJJJJ().format(spb.getBescheinigungsdatum()), 9); rpt.add("\n\n\n\n.................................................................................\nUnterschrift des Zuwendungsempfngers", 8); rpt.add("\nHinweis:", 8); rpt.add("Wer vorstzlich oder grob fahrlssig eine unrichtige Zuwendungsbesttigung erstellt " + "oder veranlasst, dass Zuwendungen nicht zu den in der Zuwendungsbesttigung " + "angegebenen steuerbegnstigten Zwecken verwendet werden, haftet fr die entgangene " + "Steuer ( 10b Absatz 4 EStG, 9 Absatz 3 KStG, 9 Nummer 5 GewStG).\n" + "\n" + "Diese Besttigung wird nicht als Nachweis fr die steuerliche Bercksichtigung der " + "Zuwendung anerkannt, wenn das Datum des Freistellungsbescheides lnger als 5 Jahre " + "bzw. das Datum der Feststellung der Einhaltung der satzungsmigen Voraussetzungen " + "nach 60a Abs. 1 AO lnger als 3 Jahre seit Ausstellung des Bescheides zurckliegt " + "( 63 Abs. 5 AO).", 7); /* Es sind mehrere Spenden fr diese Spendenbescheinigung vorhanden */ if (isSammelbestaetigung) { List<Buchung> buchungen = spb.getBuchungen(); rpt.newPage(); rpt.add(getAussteller(), 13); rpt.add(new Paragraph(" ", Reporter.getFreeSans(12))); rpt.add("Anlage zur Sammelbesttigung vom " + (String) map.get(SpendenbescheinigungVar.BESCHEINIGUNGDATUM.getName()), 11); rpt.add("fr den Zeitraum vom " + (String) map.get(SpendenbescheinigungVar.SPENDENZEITRAUM.getName()), 11); rpt.add(new Paragraph(" ", Reporter.getFreeSans(12))); /* Kopfzeile */ rpt.addHeaderColumn("Datum der\nZuwendung", Element.ALIGN_LEFT, 150, BaseColor.LIGHT_GRAY); rpt.addHeaderColumn("Art der\nZuwendung", Element.ALIGN_LEFT, 400, BaseColor.LIGHT_GRAY); rpt.addHeaderColumn("Verzicht auf die\nErstattung von Aufwendungen", Element.ALIGN_LEFT, 300, BaseColor.LIGHT_GRAY); rpt.addHeaderColumn("Betrag", Element.ALIGN_RIGHT, 150, BaseColor.LIGHT_GRAY); rpt.createHeader(); boolean printBuchungsart = Einstellungen.getEinstellung().getSpendenbescheinigungPrintBuchungsart(); /* Buchungszeilen */ for (Buchung buchung : buchungen) { rpt.addColumn(buchung.getDatum(), Element.ALIGN_RIGHT); String verwendung = ""; if (printBuchungsart) { verwendung = buchung.getBuchungsart().getBezeichnung(); } else { verwendung = buchung.getZweck(); } rpt.addColumn(verwendung, Element.ALIGN_LEFT); if (buchung.getVerzicht().booleanValue()) { verzicht = "ja"; } else { verzicht = "nein"; } rpt.addColumn(verzicht, Element.ALIGN_CENTER); rpt.addColumn(Double.valueOf(buchung.getBetrag())); } /* Summenzeile */ // String sumString = // Einstellungen.DECIMALFORMAT.format(spb.getBetrag()); rpt.addColumn("Gesamtsumme", Element.ALIGN_LEFT, BaseColor.LIGHT_GRAY); rpt.addColumn("", Element.ALIGN_LEFT, BaseColor.LIGHT_GRAY); rpt.addColumn("", Element.ALIGN_LEFT, BaseColor.LIGHT_GRAY); rpt.addColumn(Double.valueOf(spb.getBetrag())); // rpt.addColumn(sumString, Element.ALIGN_RIGHT, // BaseColor.LIGHT_GRAY); rpt.closeTable(); // // Etwas Abstand // rpt.add(new Paragraph(" ")); // // Nun noch die Legende // rpt.add("Legende:", 8); // rpt.add( // "(a): Es handelt sich nicht um den Verzicht auf Erstattung von // Aufwendungen", // 8); // rpt.add( // "(b): Es handelt sich um den Verzicht auf Erstattung von Aufwendungen", // 8); } rpt.close(); fos.close(); }
From source file:digilib.pdf.PDFTitlePage.java
License:Open Source License
/** * generate iText-PDF-Contents for the title page * /* ww w . java2 s . c o m*/ * @return */ public Element getPageContents() { Paragraph content = new Paragraph(); content.setAlignment(Element.ALIGN_CENTER); // add vertical whitespace for (int i = 0; i < 8; i++) { content.add(Chunk.NEWLINE); } // add logo content.add(getLogo()); content.add(Chunk.NEWLINE); content.add(Chunk.NEWLINE); // add title Anchor title = new Anchor(new Paragraph(getTitle(), FontFactory.getFont(FontFactory.HELVETICA, 16))); String burl = job_info.getImageJobInformation().getAsString("base.url"); title.setReference(burl + "digilib.jsp?fn=" + job_info.getImageJobInformation().getAsString("fn")); content.add(title); content.add(Chunk.NEWLINE); // add author if (getDate() != " ") content.add(new Paragraph(getAuthor() + " (" + getDate() + ")", FontFactory.getFont(FontFactory.HELVETICA, 14))); else content.add(new Paragraph(getAuthor(), FontFactory.getFont(FontFactory.HELVETICA, 14))); content.add(Chunk.NEWLINE); // add page numbers content.add(new Paragraph(getPages(), FontFactory.getFont(FontFactory.HELVETICA, 12))); content.add(Chunk.NEWLINE); content.add(Chunk.NEWLINE); content.add(Chunk.NEWLINE); // add digilib version content.add(new Paragraph(getDigilibVersion(), FontFactory.getFont(FontFactory.HELVETICA, 10))); for (int i = 0; i < 8; i++) { content.add(Chunk.NEWLINE); } Anchor address = new Anchor( new Paragraph(burl + "digilib.jsp?fn=" + job_info.getImageJobInformation().getAsString("fn"), FontFactory.getFont(FontFactory.COURIER, 9))); address.setReference(burl + "digilib.jsp?fn=" + job_info.getImageJobInformation().getAsString("fn")); content.add(address); return content; }
From source file:edu.cornell.mannlib.vitro.webapp.visualization.visutils.PDFDocument.java
License:Open Source License
private void createImage(Document document, PdfWriter writer, Font featureHeaderStyle) throws BadElementException, MalformedURLException, IOException, DocumentException { Image imageSprite = Image.getInstance(new URL( "http://lh3.ggpht.com/_4msVPAgKJv8/SCRYD-pPVKI/AAAAAAAAAYU/zUN963EPoZc/s1024/102_0609.JPG")); imageSprite.setAbsolutePosition(400, 500); imageSprite.scaleAbsolute(171.0f, 250.0f); float imageSpriteY = document.getPageSize().getHeight() * 0.60f; float imageSpriteX = document.getPageSize().getWidth() * 0.65f; imageSprite.setAlignment(Image.UNDERLYING); document.add(imageSprite);/*from w w w . ja v a 2 s. c o m*/ PdfContentByte cb = writer.getDirectContent(); ColumnText ct = new ColumnText(cb); Chunk imageHeader = new Chunk("Images", featureHeaderStyle); ct.addText(imageHeader); ct.setAlignment(Element.ALIGN_LEFT); ct.setSimpleColumn(imageSpriteX, imageSpriteY - imageSprite.getScaledHeight(), imageSpriteX + imageSprite.getScaledWidth(), imageSpriteY + imageSprite.getScaledHeight() + 20); ct.go(); ct = new ColumnText(cb); Chunk imageFooter = new Chunk("Footer to be set for a figure. Similar to 'image cpation'.", FontFactory.getFont(FontFactory.TIMES_ROMAN, 8)); ct.addText(imageFooter); ct.setAlignment(Element.ALIGN_CENTER); ct.setSimpleColumn(imageSpriteX, imageSpriteY - 150, imageSpriteX + imageSprite.getScaledWidth(), imageSpriteY); ct.go(); }
From source file:edu.cornell.mannlib.vitro.webapp.visualization.visutils.PDFDocument.java
License:Open Source License
private PdfPTable createTable(Map<String, Integer> yearToPublicationCount) { Font normalContentStyle = FontFactory.getFont(FontFactory.TIMES_ROMAN, 11); Font summaryContentStyle = FontFactory.getFont(FontFactory.TIMES_ROMAN, 11, Font.BOLDITALIC); BaseColor summaryBackgroundColor = new BaseColor(0xEE, 0xEE, 0xEE); BaseColor headerBackgroundColor = new BaseColor(0xC3, 0xD9, 0xFF); BaseColor bodyBackgroundColor = new BaseColor(Color.white); PdfPTable table = new PdfPTable(2); table.setWidthPercentage(36.0f);//w w w. java 2s . c o m table.setHorizontalAlignment(Element.ALIGN_LEFT); table.getDefaultCell().setBorderWidth(0.0f); table.setHeaderRows(2); PdfPCell cell; cell = new PdfPCell(new Phrase("Publications per year", normalContentStyle)); setTableCaptionStyle(summaryBackgroundColor, cell); table.addCell(cell); cell = new PdfPCell(new Phrase("Year", normalContentStyle)); setTableHeaderStyle(headerBackgroundColor, cell); table.addCell(cell); cell.setPhrase(new Phrase("Publications", normalContentStyle)); table.addCell(cell); setTableBodyStyle(bodyBackgroundColor, cell); int totalPublications = 0; for (Entry<String, Integer> currentEntry : yearToPublicationCount.entrySet()) { cell.setPhrase(new Phrase(currentEntry.getKey(), normalContentStyle)); table.addCell(cell); cell.setPhrase(new Phrase(currentEntry.getValue().toString(), normalContentStyle)); table.addCell(cell); totalPublications += currentEntry.getValue(); } setTableFooterStyle(summaryBackgroundColor, cell); cell.setPhrase(new Phrase("Total", summaryContentStyle)); table.addCell(cell); cell.setPhrase(new Phrase(String.valueOf(totalPublications), summaryContentStyle)); table.addCell(cell); return table; }
From source file:edu.ksu.cs.a4vm.bse.reporter.Reporter.java
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) { JFileChooser chooser = new JFileChooser(); int option = chooser.showSaveDialog(null); if (option == JFileChooser.APPROVE_OPTION) { if (chooser.getSelectedFile() != null) { File3 = chooser.getSelectedFile().getAbsolutePath(); }/*from w w w . j a va 2 s . c om*/ try { br1 = new BufferedReader(new FileReader(f)); BufferedReader b1 = new BufferedReader(new FileReader(f)); } catch (FileNotFoundException ex) { } String line = ""; bull1 = new String[number_of_rows - 1][]; int k = 0; BufferedReader br3 = null; try { br3 = new BufferedReader(new FileReader(f)); } catch (FileNotFoundException ex) { } try { while ((line = br3.readLine()) != null) { // use comma as separator String Bull[] = line.split(","); if (k != 0) { System.out.println(Bull.length); bull1[k - 1] = new String[Bull.length]; for (int j = 0; j < Bull.length; j++) { bull1[k - 1][j] = Bull[j]; } } k++; } } catch (IOException ex) { } Document doc = new Document(); PdfWriter docWriter = null; DecimalFormat df = new DecimalFormat("0.00"); try { //special font sizes Font bfBold12 = new Font(Font.FontFamily.TIMES_ROMAN, 8, Font.BOLD, new BaseColor(0, 0, 0)); Font bf12 = new Font(Font.FontFamily.TIMES_ROMAN, 6); Font bfBold20 = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD); Font bfBold25 = new Font(Font.FontFamily.TIMES_ROMAN, 15, Font.BOLD); //file path docWriter = PdfWriter.getInstance(doc, new FileOutputStream(File3)); //document header attributes doc.addAuthor("Shubh Chopra"); doc.addCreationDate(); doc.addProducer(); doc.addCreator("Shubh Chopra"); doc.addTitle("BES"); doc.setPageSize(PageSize.LETTER.rotate()); //open document doc.open(); //create a paragraph Paragraph paragraph = new Paragraph("BULL EVALUATION\n\n"); paragraph.setFont(bfBold25); paragraph.setAlignment(Element.ALIGN_CENTER); Image img = Image.getInstance("VETMED.png"); img.scaleToFit(300f, 150f); doc.add(paragraph); PdfPTable table1 = new PdfPTable(2); table1.setWidthPercentage(100); PdfPCell cell = new PdfPCell(img); cell.setBorder(PdfPCell.NO_BORDER); table1.addCell(cell); String temp1 = "\tOwner: " + bull1[1][62] + " " + bull1[1][63] + "\n\n\tRanch: " + bull1[1][64] + "\n\n\tAddress: " + bull1[1][55] + "\n\n\tCity: " + bull1[1][57] + "\n\n\tState: " + bull1[1][60] + "\tZip: " + bull1[1][61] + "\n\n\tPhone: " + bull1[1][59] + "\n\n"; table1.addCell(getCell(temp1, PdfPCell.ALIGN_LEFT)); doc.add(table1); if (dlm3.size() == 1) { String str; str = dlm3.get(0).toString(); String[] parts = str.split(":"); String part2 = parts[1]; System.out.println(part2); int row = Integer.parseInt(part2) - 1; String[][] temp = new String[25][6]; temp[0][0] = "Tag"; temp[0][1] = bull1[row][7]; temp[0][2] = "Comments"; temp[0][3] = ""; temp[0][4] = "Total Count"; temp[0][5] = ""; temp[1][0] = "Tatoo"; temp[1][1] = bull1[row][8]; temp[1][2] = "All Normal"; temp[1][3] = "Yes"; temp[2][0] = "RFID"; temp[2][1] = bull1[row][6]; temp[2][2] = "Eyes"; temp[2][3] = bull1[row][10]; temp[3][0] = "Lot#"; temp[3][1] = bull1[row][5]; temp[3][2] = "Feet"; temp[3][3] = bull1[row][12]; temp[4][0] = "Brand"; temp[4][1] = bull1[row][2]; temp[4][2] = "Legs"; temp[4][3] = bull1[row][14]; temp[5][0] = "Date of Birth"; temp[5][1] = bull1[row][4]; temp[5][2] = "Testicals"; temp[5][3] = bull1[row][16]; temp[6][0] = "Age"; temp[6][1] = bull1[row][0]; temp[6][2] = "Accessory Sex Glands"; temp[6][3] = bull1[row][18]; temp[7][0] = "Breed"; temp[7][1] = bull1[row][3]; temp[7][2] = "Inguinal"; temp[7][3] = bull1[row][20]; temp[8][0] = "Other"; temp[8][1] = bull1[row][9]; temp[8][2] = "Scrotal"; temp[8][3] = bull1[row][22]; temp[9][0] = "Clinic Info"; temp[9][1] = "xx"; temp[9][2] = "Epidydimides"; temp[9][3] = bull1[row][24]; temp[10][4] = "Measurements"; temp[10][5] = "xx"; temp[10][0] = "Clinic Name"; temp[10][1] = bull1[row][73]; temp[10][2] = "Penis"; temp[10][3] = bull1[row][26]; temp[11][4] = "Scrotal Cirumference"; temp[11][5] = bull1[row][54]; temp[11][0] = "Veterinarian Name"; temp[11][1] = bull1[row][74] + " " + bull1[row][74]; temp[11][2] = "Prepuce"; temp[11][3] = bull1[row][28]; temp[12][4] = "Body Condition"; temp[12][5] = bull1[row][47]; temp[12][0] = "Address"; temp[12][1] = bull1[row][66] + " " + bull1[row][67]; temp[12][2] = "Scrotum"; temp[12][3] = bull1[row][30]; temp[13][4] = "Pelvic X Measure"; temp[13][5] = bull1[row][52]; temp[13][0] = "City"; temp[13][1] = bull1[row][68]; temp[13][2] = "Sex Drive"; temp[13][3] = "xx"; temp[14][4] = "Pelvic Y Measure"; temp[14][5] = bull1[row][53]; temp[14][0] = "State"; temp[14][1] = bull1[row][71]; temp[14][2] = "Breeding seasons used"; temp[14][3] = bull1[row][40]; temp[15][4] = "Hip Hight"; temp[15][5] = bull1[row][50]; temp[15][0] = "Zip Code"; temp[15][1] = bull1[row][72]; temp[15][2] = "Performance last season"; temp[15][3] = bull1[row][38]; temp[16][4] = "Frame Score"; temp[16][5] = bull1[row][49]; temp[16][0] = "Email"; temp[16][1] = bull1[row][69]; temp[16][2] = "Single or Multi sire"; temp[16][3] = bull1[row][41]; temp[17][4] = "Other"; temp[17][5] = bull1[row][48]; temp[17][0] = "Phone"; temp[17][1] = bull1[row][70]; temp[17][2] = "Other"; temp[17][3] = bull1[row][39]; temp[18][4] = "Motility"; temp[18][5] = "xx"; temp[18][0] = "Classification"; temp[18][1] = bull1[row][35]; temp[18][2] = "Comments"; temp[18][3] = bull1[row][37]; temp[19][4] = "Individual Motility"; temp[19][5] = bull1[row][45]; temp[19][0] = "Comments"; temp[19][1] = bull1[row][36]; temp[19][2] = ""; temp[19][3] = ""; temp[20][4] = "Motility %"; temp[20][5] = bull1[row][46]; temp[20][0] = ""; temp[20][1] = ""; temp[20][2] = ""; temp[20][3] = ""; temp[21][4] = "Gross Motility"; temp[21][5] = bull1[row][44]; temp[21][0] = ""; temp[21][1] = ""; temp[21][2] = ""; temp[21][3] = ""; for (int i = 9; i <= 29; i += 2) { if (bull1[row][i].equals("FALSE")) { temp[1][4] = "No"; break; } } int i; int total = 0; for (i = 77; i < header.length && i < bull1[row].length; i++) { temp[i - 76][4] = header[i].split("_")[1]; temp[i - 76][5] = bull1[row][i]; total += Integer.parseInt(bull1[row][i]); } temp[0][5] = Integer.toString(total); for (int j = i; j <= 85; j++) { temp[j - 76][4] = ""; temp[j - 76][5] = ""; } PdfPTable table = new PdfPTable(6); PdfPCell cell11, cell12, cell13; cell11 = new PdfPCell( new Phrase("Bull Info", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12))); cell11.setColspan(2); cell11.setHorizontalAlignment(Element.ALIGN_CENTER); cell11.setVerticalAlignment(Element.ALIGN_CENTER); table.addCell(cell11); cell12 = new PdfPCell( new Phrase("Physical Exam", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12))); cell12.setColspan(2); cell12.setHorizontalAlignment(Element.ALIGN_CENTER); cell12.setVerticalAlignment(Element.ALIGN_CENTER); table.addCell(cell12); cell13 = new PdfPCell( new Phrase("Morphology", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12))); cell13.setColspan(2); cell13.setHorizontalAlignment(Element.ALIGN_CENTER); cell13.setVerticalAlignment(Element.ALIGN_CENTER); table.addCell(cell13); for (int l = 0; l <= 21; l++) { for (int j = 0; j < 6; j++) { // System.out.println(l+" "+j); if (!temp[l][j].equals("xx") && temp[l][j] != null) { cell = new PdfPCell( new Phrase(temp[l][j], FontFactory.getFont(FontFactory.TIMES_ROMAN, 10))); cell.setBorder(PdfPCell.NO_BORDER); if ((l == 9 && j == 0) || (l == 13 && j == 2) || (l == 10 && j == 4) || (l == 18 && j == 4)) { cell = new PdfPCell(new Phrase(temp[l][j], FontFactory.getFont(FontFactory.TIMES_ROMAN, 12))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); } table.addCell(cell); } } } table.setWidthPercentage(90f); Reporter re; re = new Reporter(); doc.add(table); if (jCheckBox2.isSelected() || jCheckBox1.isSelected()) doc.newPage(); } else { //specify column widths int temp = dlm2.size(); float[] columnWidths = new float[temp]; for (int x = 0; x < columnWidths.length; x++) { columnWidths[x] = 2f; } //create PDF table with the given widths PdfPTable table = new PdfPTable(columnWidths); // set table width a percentage of the page width table.setWidthPercentage(90f); Reporter re; re = new Reporter(); re.insertCell(table, "Bull Info", Element.ALIGN_CENTER, 1, bfBold12); for (int i = 0; i < dlm2.size(); i++) { String[] parts = dlm2.get(i).toString().split(": "); String part2 = parts[1]; re.insertCell(table, newhead[Integer.parseInt(part2)], Element.ALIGN_CENTER, 1, bfBold12); } table.setHeaderRows(1); //insert an empty row //create section heading by cell merging //just some random data to fill for (int x = 0; x < dlm3.size(); x++) { String str = dlm3.get(x).toString(); //System.out.println(str); String[] parts = str.split(":"); String part2 = parts[1]; // System.out.println(part2); int row = Integer.parseInt(part2) - 1; re.insertCell(table, Bulls[row], Element.ALIGN_CENTER, 1, bf12); for (int i = 0; i < dlm2.getSize(); i++) { for (int j = 0; j < header.length && j < bull1[row].length; j++) { String str1 = dlm2.get(i).toString(); String[] p1 = str1.split(": "); String p2 = p1[0]; if (p2.equals(header[j])) { re.insertCell(table, bull1[row][j], Element.ALIGN_CENTER, 1, bf12); } } } // re.insertCell(table, bull1[x][7] , Element.ALIGN_CENTER, 1, bf12); } doc.add(table); } if (jCheckBox2.isSelected()) { DefaultCategoryDataset dataSet = new DefaultCategoryDataset(); for (int i = 0; i < dlm3.size(); i++) { String str = dlm3.get(i).toString(); System.out.println(str); String[] parts = str.split(":"); String part1 = parts[0]; String part2 = parts[1]; System.out.println(part2); int row = Integer.parseInt(part2) - 1; float total = (float) 0.0; for (int j = 77; j < header.length && j < bull1[row].length; j++) { if (bull1[row][j].equals("")) { continue; } else { total += Integer.parseInt(bull1[row][j]); } } System.out.println(total); for (int j = 77; j < header.length && j < bull1[row].length; j++) { if (!bull1[row][j].equals("")) { String[] Parts = header[j].split("_"); String Part2 = Parts[1]; dataSet.setValue((Integer.parseInt(bull1[row][j]) * 100) / total, Part2, part1); } else { dataSet.setValue(0, "Percent", header[j]); } } } JFreeChart chart = ChartFactory.createBarChart("Multi Bull Morphology Chart ", "Morphology", "Percent", dataSet, PlotOrientation.VERTICAL, true, true, false); if (dlm3.size() > 12) { doc.newPage(); } PdfContentByte contentByte = docWriter.getDirectContent(); PdfTemplate template = contentByte.createTemplate(325, 250); PdfGraphics2D graphics2d = new PdfGraphics2D(template, 325, 250); Rectangle2D rectangle2d = new Rectangle2D.Double(0, 0, 325, 250); chart.draw(graphics2d, rectangle2d); graphics2d.dispose(); contentByte.addTemplate(template, 0, 0); } if (jCheckBox1.isSelected()) { for (int i = 0; i < dlm3.size(); i++) { DefaultCategoryDataset dataSet = new DefaultCategoryDataset(); String str = dlm3.get(i).toString(); System.out.println(str); String[] parts = str.split(":"); String part1 = parts[0]; String part2 = parts[1]; System.out.println(part2); int row = Integer.parseInt(part2) - 1; float total = (float) 0.0; for (int j = 77; j < header.length && j < bull1[row].length; j++) { if (bull1[row][j].equals("")) { continue; } else { total += Integer.parseInt(bull1[row][j]); } } System.out.println(total); for (int j = 77; j < header.length && j < bull1[row].length; j++) { if (!bull1[row][j].equals("")) { String[] Parts = header[j].split("_"); String Part2 = Parts[1]; dataSet.setValue((Integer.parseInt(bull1[row][j]) * 100) / total, "Percent", Part2); } else { dataSet.setValue(0, "Percent", header[j]); } } JFreeChart chart = ChartFactory.createBarChart("Single Bull Morphology Chart " + part1, "Morphology", "Percent", dataSet, PlotOrientation.VERTICAL, false, true, false); if ((dlm3.size() > 12 && i == 0) || jCheckBox2.isSelected()) { doc.newPage(); } PdfContentByte contentByte = docWriter.getDirectContent(); PdfTemplate template = contentByte.createTemplate(325, 250); PdfGraphics2D graphics2d = new PdfGraphics2D(template, 325, 250); Rectangle2D rectangle2d = new Rectangle2D.Double(0, 0, 325, 250); chart.draw(graphics2d, rectangle2d); graphics2d.dispose(); contentByte.addTemplate(template, 0, 0); doc.newPage(); } } } catch (DocumentException dex) { dex.printStackTrace(); } catch (FileNotFoundException ex) { Logger.getLogger(ReporterArchive.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(ReporterArchive.class.getName()).log(Level.SEVERE, null, ex); } finally { if (doc != null) { //close the document doc.close(); } if (docWriter != null) { //close the writer docWriter.close(); } } } // TODO add your handling code here: }
From source file:edu.ksu.cs.a4vm.bse.reporter.Reporter.java
private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: // build a controller SwingController controller = new SwingController(); // Build a SwingViewFactory configured with the controller SwingViewBuilder factory = new SwingViewBuilder(controller); // Use the factory to build a JPanel that is pre-configured //with a complete, active Viewer UI. JPanel viewerComponentPanel = factory.buildViewerPanel(); // add copy keyboard command ComponentKeyBinding.install(controller, viewerComponentPanel); // add interactive mouse link annotation support via callback controller.getDocumentViewController().setAnnotationCallback( new org.icepdf.ri.common.MyAnnotationCallback(controller.getDocumentViewController())); // Create a JFrame to display the panel in JFrame window = new JFrame("Using the Viewer Component"); window.getContentPane().add(viewerComponentPanel); window.pack();//from w w w. j a v a2 s. c om window.setVisible(true); String Path; JFileChooser chooser = new JFileChooser(); FileSystemView view = chooser.getFileSystemView(); Path = view.getDefaultDirectory() + "/reporter.pdf"; try { br1 = new BufferedReader(new FileReader(f)); BufferedReader b1 = new BufferedReader(new FileReader(f)); } catch (FileNotFoundException ex) { } String line = ""; bull1 = new String[number_of_rows - 1][]; int k = 0; BufferedReader br3 = null; try { br3 = new BufferedReader(new FileReader(f)); } catch (FileNotFoundException ex) { } try { while ((line = br3.readLine()) != null) { // use comma as separator String Bull[] = line.split(","); if (k != 0) { System.out.println(Bull.length); bull1[k - 1] = new String[Bull.length]; for (int j = 0; j < Bull.length; j++) { bull1[k - 1][j] = Bull[j]; } } k++; } } catch (IOException ex) { } Document doc = new Document(); PdfWriter docWriter = null; DecimalFormat df = new DecimalFormat("0.00"); try { //special font sizes Font bfBold12 = new Font(Font.FontFamily.TIMES_ROMAN, 8, Font.BOLD, new BaseColor(0, 0, 0)); Font bf12 = new Font(Font.FontFamily.TIMES_ROMAN, 6); Font bfBold20 = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD); //file path docWriter = PdfWriter.getInstance(doc, new FileOutputStream(Path)); //document header attributes doc.addAuthor("Shubh Chopra"); doc.addCreationDate(); doc.addProducer(); doc.addCreator("Shubh Chopra"); doc.addTitle("BES"); doc.setPageSize(PageSize.LETTER.rotate()); //open document doc.open(); //create a paragraph Paragraph paragraph = new Paragraph("BULL EVALUATION\n\n"); paragraph.setFont(bfBold20); paragraph.setAlignment(Element.ALIGN_CENTER); Image img = Image.getInstance("VETMED.png"); img.scaleToFit(300f, 150f); doc.add(paragraph); PdfPTable table1 = new PdfPTable(2); table1.setWidthPercentage(100); PdfPCell cell = new PdfPCell(img); cell.setBorder(PdfPCell.NO_BORDER); table1.addCell(cell); String temp1 = "\tOwner: " + bull1[1][62] + " " + bull1[1][63] + "\n\n\tRanch: " + bull1[1][64] + "\n\n\tAddress: " + bull1[1][55] + "\n\n\tCity: " + bull1[1][57] + "\n\n\tState: " + bull1[1][60] + "\tZip: " + bull1[1][61] + "\n\n\tPhone: " + bull1[1][59] + "\n\n"; table1.addCell(getCell(temp1, PdfPCell.ALIGN_LEFT)); doc.add(table1); if (dlm3.size() == 1) { String str; str = dlm3.get(0).toString(); String[] parts = str.split(":"); String part2 = parts[1]; System.out.println(part2); int row = Integer.parseInt(part2) - 1; String[][] temp = new String[25][6]; temp[0][0] = "Tag"; temp[0][1] = bull1[row][7]; temp[0][2] = "Comments"; temp[0][3] = ""; temp[0][4] = "Total Count"; temp[0][5] = ""; temp[1][0] = "Tatoo"; temp[1][1] = bull1[row][8]; temp[1][2] = "All Normal"; temp[1][3] = "Yes"; temp[2][0] = "RFID"; temp[2][1] = bull1[row][6]; temp[2][2] = "Eyes"; temp[2][3] = bull1[row][10]; temp[3][0] = "Lot#"; temp[3][1] = bull1[row][5]; temp[3][2] = "Feet"; temp[3][3] = bull1[row][12]; temp[4][0] = "Brand"; temp[4][1] = bull1[row][2]; temp[4][2] = "Legs"; temp[4][3] = bull1[row][14]; temp[5][0] = "Date of Birth"; temp[5][1] = bull1[row][4]; temp[5][2] = "Testicals"; temp[5][3] = bull1[row][16]; temp[6][0] = "Age"; temp[6][1] = bull1[row][0]; temp[6][2] = "Accessory Sex Glands"; temp[6][3] = bull1[row][18]; temp[7][0] = "Breed"; temp[7][1] = bull1[row][3]; temp[7][2] = "Inguinal"; temp[7][3] = bull1[row][20]; temp[8][0] = "Other"; temp[8][1] = bull1[row][9]; temp[8][2] = "Scrotal"; temp[8][3] = bull1[row][22]; temp[9][0] = "Clinic Info"; temp[9][1] = "xx"; temp[9][2] = "Epidydimides"; temp[9][3] = bull1[row][24]; temp[10][4] = "Measurements"; temp[10][5] = "xx"; temp[10][0] = "Clinic Name"; temp[10][1] = bull1[row][73]; temp[10][2] = "Penis"; temp[10][3] = bull1[row][26]; temp[11][4] = "Scrotal Cirumference"; temp[11][5] = bull1[row][54]; temp[11][0] = "Veterinarian Name"; temp[11][1] = bull1[row][74] + " " + bull1[row][74]; temp[11][2] = "Prepuce"; temp[11][3] = bull1[row][28]; temp[12][4] = "Body Condition"; temp[12][5] = bull1[row][47]; temp[12][0] = "Address"; temp[12][1] = bull1[row][66] + " " + bull1[row][67]; temp[12][2] = "Scrotum"; temp[12][3] = bull1[row][30]; temp[13][4] = "Pelvic X Measure"; temp[13][5] = bull1[row][52]; temp[13][0] = "City"; temp[13][1] = bull1[row][68]; temp[13][2] = "Sex Drive"; temp[13][3] = "xx"; temp[14][4] = "Pelvic Y Measure"; temp[14][5] = bull1[row][53]; temp[14][0] = "State"; temp[14][1] = bull1[row][71]; temp[14][2] = "Breeding seasons used"; temp[14][3] = bull1[row][40]; temp[15][4] = "Hip Hight"; temp[15][5] = bull1[row][50]; temp[15][0] = "Zip Code"; temp[15][1] = bull1[row][72]; temp[15][2] = "Performance last season"; temp[15][3] = bull1[row][38]; temp[16][4] = "Frame Score"; temp[16][5] = bull1[row][49]; temp[16][0] = "Email"; temp[16][1] = bull1[row][69]; temp[16][2] = "Single or Multi sire"; temp[16][3] = bull1[row][41]; temp[17][4] = "Other"; temp[17][5] = bull1[row][48]; temp[17][0] = "Phone"; temp[17][1] = bull1[row][70]; temp[17][2] = "Other"; temp[17][3] = bull1[row][39]; temp[18][4] = "Motility"; temp[18][5] = "xx"; temp[18][0] = "Classification"; temp[18][1] = bull1[row][35]; temp[18][2] = "Comments"; temp[18][3] = bull1[row][37]; temp[19][4] = "Individual Motility"; temp[19][5] = bull1[row][45]; temp[19][0] = "Comments"; temp[19][1] = bull1[row][36]; temp[19][2] = ""; temp[19][3] = ""; temp[20][4] = "Motility %"; temp[20][5] = bull1[row][46]; temp[20][0] = ""; temp[20][1] = ""; temp[20][2] = ""; temp[20][3] = ""; temp[21][4] = "Gross Motility"; temp[21][5] = bull1[row][44]; temp[21][0] = ""; temp[21][1] = ""; temp[21][2] = ""; temp[21][3] = ""; for (int i = 9; i <= 29; i += 2) { if (bull1[row][i].equals("FALSE")) { temp[1][4] = "No"; break; } } int i; int total = 0; for (i = 77; i < header.length && i < bull1[row].length; i++) { temp[i - 76][4] = header[i].split("_")[1]; temp[i - 76][5] = bull1[row][i]; total += Integer.parseInt(bull1[row][i]); } temp[0][5] = Integer.toString(total); for (int j = i; j <= 85; j++) { temp[j - 76][4] = ""; temp[j - 76][5] = ""; } PdfPTable table = new PdfPTable(6); PdfPCell cell11, cell12, cell13; cell11 = new PdfPCell(new Phrase("Bull Info", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12))); cell11.setColspan(2); cell11.setHorizontalAlignment(Element.ALIGN_CENTER); cell11.setVerticalAlignment(Element.ALIGN_CENTER); table.addCell(cell11); cell12 = new PdfPCell( new Phrase("Physical Exam", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12))); cell12.setColspan(2); cell12.setHorizontalAlignment(Element.ALIGN_CENTER); cell12.setVerticalAlignment(Element.ALIGN_CENTER); table.addCell(cell12); cell13 = new PdfPCell(new Phrase("Morphology", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12))); cell13.setColspan(2); cell13.setHorizontalAlignment(Element.ALIGN_CENTER); cell13.setVerticalAlignment(Element.ALIGN_CENTER); table.addCell(cell13); for (int l = 0; l <= 21; l++) { for (int j = 0; j < 6; j++) { // System.out.println(l+" "+j); if (!temp[l][j].equals("xx") && temp[l][j] != null) { cell = new PdfPCell( new Phrase(temp[l][j], FontFactory.getFont(FontFactory.TIMES_ROMAN, 10))); cell.setBorder(PdfPCell.NO_BORDER); if ((l == 9 && j == 0) || (l == 13 && j == 2) || (l == 10 && j == 4) || (l == 18 && j == 4)) { cell = new PdfPCell( new Phrase(temp[l][j], FontFactory.getFont(FontFactory.TIMES_ROMAN, 12))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); } table.addCell(cell); } } } table.setWidthPercentage(90f); Reporter re; re = new Reporter(); doc.add(table); if (jCheckBox2.isSelected() || jCheckBox1.isSelected()) doc.newPage(); } else { //specify column widths int temp = dlm2.size(); float[] columnWidths = new float[temp + 1]; for (int x = 0; x < columnWidths.length; x++) { columnWidths[x] = 2f; } //create PDF table with the given widths PdfPTable table = new PdfPTable(columnWidths); // set table width a percentage of the page width table.setWidthPercentage(90f); Reporter re; re = new Reporter(); re.insertCell(table, "Bull Info", Element.ALIGN_CENTER, 1, bfBold12); for (int i = 0; i < dlm2.size(); i++) { String[] parts = dlm2.get(i).toString().split(": "); String part2 = parts[1]; re.insertCell(table, newhead[Integer.parseInt(part2)], Element.ALIGN_CENTER, 1, bfBold12); } table.setHeaderRows(1); //insert an empty row //create section heading by cell merging //just some random data to fill for (int x = 0; x < dlm3.size(); x++) { String str = dlm3.get(x).toString(); //System.out.println(str); String[] parts = str.split(":"); String part2 = parts[1]; // System.out.println(part2); int row = Integer.parseInt(part2) - 1; re.insertCell(table, Bulls[row], Element.ALIGN_CENTER, 1, bf12); for (int i = 0; i < dlm2.getSize(); i++) { for (int j = 0; j < header.length && j < bull1[row].length; j++) { String str1 = dlm2.get(i).toString(); String[] p1 = str1.split(": "); String p2 = p1[0]; if (p2.equals(header[j])) { re.insertCell(table, bull1[row][j], Element.ALIGN_CENTER, 1, bf12); } } } // re.insertCell(table, bull1[x][7] , Element.ALIGN_CENTER, 1, bf12); } doc.add(table); } if (jCheckBox2.isSelected()) { DefaultCategoryDataset dataSet = new DefaultCategoryDataset(); for (int i = 0; i < dlm3.size(); i++) { String str = dlm3.get(i).toString(); System.out.println(str); String[] parts = str.split(":"); String part1 = parts[0]; String part2 = parts[1]; System.out.println(part2); int row = Integer.parseInt(part2) - 1; float total = (float) 0.0; for (int j = 77; j < header.length && j < bull1[row].length; j++) { if (bull1[row][j].equals("")) { continue; } else { total += Integer.parseInt(bull1[row][j]); } } System.out.println(total); for (int j = 77; j < header.length && j < bull1[row].length; j++) { if (!bull1[row][j].equals("")) { String[] Parts = header[j].split("_"); String Part2 = Parts[1]; dataSet.setValue((Integer.parseInt(bull1[row][j]) * 100) / total, Part2, part1); } else { dataSet.setValue(0, "Percent", header[j]); } } } JFreeChart chart = ChartFactory.createBarChart("Multi Bull Morphology Chart ", "Morphology", "Percent", dataSet, PlotOrientation.VERTICAL, true, true, false); if (dlm3.size() > 12) { doc.newPage(); } PdfContentByte contentByte = docWriter.getDirectContent(); PdfTemplate template = contentByte.createTemplate(325, 250); PdfGraphics2D graphics2d = new PdfGraphics2D(template, 325, 250); Rectangle2D rectangle2d = new Rectangle2D.Double(0, 0, 325, 250); chart.draw(graphics2d, rectangle2d); graphics2d.dispose(); contentByte.addTemplate(template, 0, 0); } if (jCheckBox1.isSelected()) { for (int i = 0; i < dlm3.size(); i++) { DefaultCategoryDataset dataSet = new DefaultCategoryDataset(); String str = dlm3.get(i).toString(); System.out.println(str); String[] parts = str.split(":"); String part1 = parts[0]; String part2 = parts[1]; System.out.println(part2); int row = Integer.parseInt(part2) - 1; float total = (float) 0.0; for (int j = 77; j < header.length && j < bull1[row].length; j++) { if (bull1[row][j].equals("")) { continue; } else { total += Integer.parseInt(bull1[row][j]); } } System.out.println(total); for (int j = 77; j < header.length && j < bull1[row].length; j++) { if (!bull1[row][j].equals("")) { String[] Parts = header[j].split("_"); String Part2 = Parts[1]; dataSet.setValue((Integer.parseInt(bull1[row][j]) * 100) / total, "Percent", Part2); } else { dataSet.setValue(0, "Percent", header[j]); } } JFreeChart chart = ChartFactory.createBarChart("Single Bull Morphology Chart " + part1, "Morphology", "Percent", dataSet, PlotOrientation.VERTICAL, false, true, false); if ((dlm3.size() > 12 && i == 0) || jCheckBox2.isSelected()) { doc.newPage(); } PdfContentByte contentByte = docWriter.getDirectContent(); PdfTemplate template = contentByte.createTemplate(325, 250); PdfGraphics2D graphics2d = new PdfGraphics2D(template, 325, 250); Rectangle2D rectangle2d = new Rectangle2D.Double(0, 0, 325, 250); chart.draw(graphics2d, rectangle2d); graphics2d.dispose(); contentByte.addTemplate(template, 0, 0); doc.newPage(); } } } catch (DocumentException dex) { dex.printStackTrace(); JOptionPane.showMessageDialog(null, dex); } catch (FileNotFoundException ex) { Logger.getLogger(ReporterArchive.class.getName()).log(Level.SEVERE, null, ex); JOptionPane.showMessageDialog(null, ex); } catch (IOException ex) { Logger.getLogger(ReporterArchive.class.getName()).log(Level.SEVERE, null, ex); JOptionPane.showMessageDialog(null, "ex"); } finally { if (doc != null) { //close the document doc.close(); } if (docWriter != null) { //close the writer docWriter.close(); } } controller.openDocument(Path); }
From source file:edu.ksu.cs.a4vm.bse.reporter.Reporter.java
private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: // build a controller SwingController controller = new SwingController(); // Build a SwingViewFactory configured with the controller SwingViewBuilder factory = new SwingViewBuilder(controller); // Use the factory to build a JPanel that is pre-configured //with a complete, active Viewer UI. JPanel viewerComponentPanel = factory.buildViewerPanel(); // add copy keyboard command ComponentKeyBinding.install(controller, viewerComponentPanel); // add interactive mouse link annotation support via callback controller.getDocumentViewController().setAnnotationCallback( new org.icepdf.ri.common.MyAnnotationCallback(controller.getDocumentViewController())); // Create a JFrame to display the panel in JFrame window = new JFrame("Using the Viewer Component"); window.getContentPane().add(viewerComponentPanel); window.pack();//from www. j a va 2 s. c o m window.setVisible(true); String Path; JFileChooser fr = new JFileChooser(); FileSystemView fw = fr.getFileSystemView(); // System.out.println(fw.getDefaultDirectory()); Path = fw.getDefaultDirectory() + "/reporter.pdf"; try { br1 = new BufferedReader(new FileReader(f)); BufferedReader b1 = new BufferedReader(new FileReader(f)); } catch (FileNotFoundException ex) { } String line = ""; bull1 = new String[number_of_rows - 1][]; int k = 0; BufferedReader br3 = null; try { br3 = new BufferedReader(new FileReader(f)); } catch (FileNotFoundException ex) { } try { while ((line = br3.readLine()) != null) { // use comma as separator String Bull[] = line.split(","); if (k != 0) { System.out.println(Bull.length); bull1[k - 1] = new String[Bull.length]; for (int j = 0; j < Bull.length; j++) { bull1[k - 1][j] = Bull[j]; } } k++; } } catch (IOException ex) { } Document doc = new Document(); PdfWriter docWriter = null; DecimalFormat df = new DecimalFormat("0.00"); try { //special font sizes Font bfBold12 = new Font(Font.FontFamily.TIMES_ROMAN, 8, Font.BOLD, new BaseColor(0, 0, 0)); Font bf12 = new Font(Font.FontFamily.TIMES_ROMAN, 6); Font bfBold20 = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD); //file path docWriter = PdfWriter.getInstance(doc, new FileOutputStream(Path)); //document header attributes doc.addAuthor("Shubh Chopra"); doc.addCreationDate(); doc.addProducer(); doc.addCreator("Shubh Chopra"); doc.addTitle("BES"); doc.setPageSize(PageSize.LETTER.rotate()); //open document doc.open(); //create a paragraph Paragraph paragraph = new Paragraph("BULL EVALUATION\n\n"); paragraph.setFont(bfBold20); paragraph.setAlignment(Element.ALIGN_CENTER); Image img = Image.getInstance("VETMED.png"); img.scaleToFit(300f, 150f); doc.add(paragraph); PdfPTable table1 = new PdfPTable(2); table1.setWidthPercentage(100); PdfPCell cell = new PdfPCell(img); cell.setBorder(PdfPCell.NO_BORDER); table1.addCell(cell); String temp1 = "\tOwner: " + bull1[1][62] + " " + bull1[1][63] + "\n\n\tRanch: " + bull1[1][64] + "\n\n\tAddress: " + bull1[1][55] + "\n\n\tCity: " + bull1[1][57] + "\n\n\tState: " + bull1[1][60] + "\tZip: " + bull1[1][61] + "\n\n\tPhone: " + bull1[1][59] + "\n\n"; table1.addCell(getCell(temp1, PdfPCell.ALIGN_LEFT)); doc.add(table1); if (dlm3.size() == 1) { String str; str = dlm3.get(0).toString(); String[] parts = str.split(":"); String part2 = parts[1]; System.out.println(part2); int row = Integer.parseInt(part2) - 1; String[][] temp = new String[25][6]; temp[0][0] = "Tag"; temp[0][1] = bull1[row][7]; temp[0][2] = "Comments"; temp[0][3] = ""; temp[0][4] = "Total Count"; temp[0][5] = ""; temp[1][0] = "Tatoo"; temp[1][1] = bull1[row][8]; temp[1][2] = "All Normal"; temp[1][3] = "Yes"; temp[2][0] = "RFID"; temp[2][1] = bull1[row][6]; temp[2][2] = "Eyes"; temp[2][3] = bull1[row][10]; temp[3][0] = "Lot#"; temp[3][1] = bull1[row][5]; temp[3][2] = "Feet"; temp[3][3] = bull1[row][12]; temp[4][0] = "Brand"; temp[4][1] = bull1[row][2]; temp[4][2] = "Legs"; temp[4][3] = bull1[row][14]; temp[5][0] = "Date of Birth"; temp[5][1] = bull1[row][4]; temp[5][2] = "Testicals"; temp[5][3] = bull1[row][16]; temp[6][0] = "Age"; temp[6][1] = bull1[row][0]; temp[6][2] = "Accessory Sex Glands"; temp[6][3] = bull1[row][18]; temp[7][0] = "Breed"; temp[7][1] = bull1[row][3]; temp[7][2] = "Inguinal"; temp[7][3] = bull1[row][20]; temp[8][0] = "Other"; temp[8][1] = bull1[row][9]; temp[8][2] = "Scrotal"; temp[8][3] = bull1[row][22]; temp[9][0] = "Clinic Info"; temp[9][1] = "xx"; temp[9][2] = "Epidydimides"; temp[9][3] = bull1[row][24]; temp[10][4] = "Measurements"; temp[10][5] = "xx"; temp[10][0] = "Clinic Name"; temp[10][1] = bull1[row][73]; temp[10][2] = "Penis"; temp[10][3] = bull1[row][26]; temp[11][4] = "Scrotal Cirumference"; temp[11][5] = bull1[row][54]; temp[11][0] = "Veterinarian Name"; temp[11][1] = bull1[row][74] + " " + bull1[row][75]; temp[11][2] = "Prepuce"; temp[11][3] = bull1[row][28]; temp[12][4] = "Body Condition"; temp[12][5] = bull1[row][47]; temp[12][0] = "Address"; temp[12][1] = bull1[row][66] + " " + bull1[row][67]; temp[12][2] = "Scrotum"; temp[12][3] = bull1[row][30]; temp[13][4] = "Pelvic X Measure"; temp[13][5] = bull1[row][52]; temp[13][0] = "City"; temp[13][1] = bull1[row][68]; temp[13][2] = "Sex Drive"; temp[13][3] = "xx"; temp[14][4] = "Pelvic Y Measure"; temp[14][5] = bull1[row][53]; temp[14][0] = "State"; temp[14][1] = bull1[row][71]; temp[14][2] = "Breeding seasons used"; temp[14][3] = bull1[row][40]; temp[15][4] = "Hip Hight"; temp[15][5] = bull1[row][50]; temp[15][0] = "Zip Code"; temp[15][1] = bull1[row][72]; temp[15][2] = "Performance last season"; temp[15][3] = bull1[row][38]; temp[16][4] = "Frame Score"; temp[16][5] = bull1[row][49]; temp[16][0] = "Email"; temp[16][1] = bull1[row][69]; temp[16][2] = "Single or Multi sire"; temp[16][3] = bull1[row][41]; temp[17][4] = "Other"; temp[17][5] = bull1[row][48]; temp[17][0] = "Phone"; temp[17][1] = bull1[row][70]; temp[17][2] = "Other"; temp[17][3] = bull1[row][39]; temp[18][4] = "Motility"; temp[18][5] = "xx"; temp[18][0] = "Classification"; temp[18][1] = bull1[row][35]; temp[18][2] = "Comments"; temp[18][3] = bull1[row][37]; temp[19][4] = "Individual Motility"; temp[19][5] = bull1[row][45]; temp[19][0] = "Comments"; temp[19][1] = bull1[row][36]; temp[19][2] = ""; temp[19][3] = ""; temp[20][4] = "Motility %"; temp[20][5] = bull1[row][46]; temp[20][0] = ""; temp[20][1] = ""; temp[20][2] = ""; temp[20][3] = ""; temp[21][4] = "Gross Motility"; temp[21][5] = bull1[row][44]; temp[21][0] = ""; temp[21][1] = ""; temp[21][2] = ""; temp[21][3] = ""; for (int i = 9; i <= 29; i += 2) { if (bull1[row][i].equals("FALSE")) { temp[1][4] = "No"; break; } } int i; int total = 0; for (i = 77; i < header.length && i < bull1[row].length; i++) { temp[i - 76][4] = header[i].split("_")[1]; temp[i - 76][5] = bull1[row][i]; total += Integer.parseInt(bull1[row][i]); } temp[0][5] = Integer.toString(total); for (int j = i; j <= 85; j++) { temp[j - 76][4] = ""; temp[j - 76][5] = ""; } PdfPTable table = new PdfPTable(6); PdfPCell cell11, cell12, cell13; cell11 = new PdfPCell(new Phrase("Bull Info", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12))); cell11.setColspan(2); cell11.setHorizontalAlignment(Element.ALIGN_CENTER); cell11.setVerticalAlignment(Element.ALIGN_CENTER); table.addCell(cell11); cell12 = new PdfPCell( new Phrase("Physical Exam", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12))); cell12.setColspan(2); cell12.setHorizontalAlignment(Element.ALIGN_CENTER); cell12.setVerticalAlignment(Element.ALIGN_CENTER); table.addCell(cell12); cell13 = new PdfPCell(new Phrase("Morphology", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12))); cell13.setColspan(2); cell13.setHorizontalAlignment(Element.ALIGN_CENTER); cell13.setVerticalAlignment(Element.ALIGN_CENTER); table.addCell(cell13); for (int l = 0; l <= 21; l++) { for (int j = 0; j < 6; j++) { // System.out.println(l+" "+j); if (!temp[l][j].equals("xx") && temp[l][j] != null) { cell = new PdfPCell( new Phrase(temp[l][j], FontFactory.getFont(FontFactory.TIMES_ROMAN, 10))); cell.setBorder(PdfPCell.NO_BORDER); if ((l == 9 && j == 0) || (l == 13 && j == 2) || (l == 10 && j == 4) || (l == 18 && j == 4)) { cell = new PdfPCell( new Phrase(temp[l][j], FontFactory.getFont(FontFactory.TIMES_ROMAN, 12))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); } table.addCell(cell); } } } table.setWidthPercentage(90f); Reporter re; re = new Reporter(); doc.add(table); if (jCheckBox2.isSelected() || jCheckBox1.isSelected()) doc.newPage(); } else { //specify column widths int temp = dlm2.size(); float[] columnWidths = new float[temp]; for (int x = 0; x < columnWidths.length; x++) { columnWidths[x] = 2f; } //create PDF table with the given widths PdfPTable table = new PdfPTable(columnWidths); // set table width a percentage of the page width table.setWidthPercentage(90f); Reporter re; re = new Reporter(); re.insertCell(table, "Bull Info", Element.ALIGN_CENTER, 1, bfBold12); for (int i = 0; i < dlm2.size(); i++) { String[] parts = dlm2.get(i).toString().split(": "); String part2 = parts[1]; re.insertCell(table, newhead[Integer.parseInt(part2)], Element.ALIGN_CENTER, 1, bfBold12); } table.setHeaderRows(1); //insert an empty row //create section heading by cell merging //just some random data to fill for (int x = 0; x < dlm3.size(); x++) { String str = dlm3.get(x).toString(); //System.out.println(str); String[] parts = str.split(":"); String part2 = parts[1]; // System.out.println(part2); int row = Integer.parseInt(part2) - 1; re.insertCell(table, Bulls[row], Element.ALIGN_CENTER, 1, bf12); for (int i = 0; i < dlm2.getSize(); i++) { for (int j = 0; j < header.length && j < bull1[row].length; j++) { String str1 = dlm2.get(i).toString(); String[] p1 = str1.split(": "); String p2 = p1[0]; if (p2.equals(header[j])) { re.insertCell(table, bull1[row][j], Element.ALIGN_CENTER, 1, bf12); } } } // re.insertCell(table, bull1[x][7] , Element.ALIGN_CENTER, 1, bf12); } doc.add(table); } if (jCheckBox2.isSelected()) { DefaultCategoryDataset dataSet = new DefaultCategoryDataset(); for (int i = 0; i < dlm3.size(); i++) { String str = dlm3.get(i).toString(); System.out.println(str); String[] parts = str.split(":"); String part1 = parts[0]; String part2 = parts[1]; System.out.println(part2); int row = Integer.parseInt(part2) - 1; float total = (float) 0.0; for (int j = 77; j < header.length && j < bull1[row].length; j++) { if (bull1[row][j].equals("")) { continue; } else { total += Integer.parseInt(bull1[row][j]); } } System.out.println(total); for (int j = 77; j < header.length && j < bull1[row].length; j++) { if (!bull1[row][j].equals("")) { String[] Parts = header[j].split("_"); String Part2 = Parts[1]; dataSet.setValue((Integer.parseInt(bull1[row][j]) * 100) / total, Part2, part1); } else { dataSet.setValue(0, "Percent", header[j]); } } } JFreeChart chart = ChartFactory.createBarChart("Multi Bull Morphology Chart ", "Morphology", "Percent", dataSet, PlotOrientation.VERTICAL, true, true, false); if (dlm3.size() > 12) { doc.newPage(); } PdfContentByte contentByte = docWriter.getDirectContent(); PdfTemplate template = contentByte.createTemplate(325, 250); PdfGraphics2D graphics2d = new PdfGraphics2D(template, 325, 250); Rectangle2D rectangle2d = new Rectangle2D.Double(0, 0, 325, 250); chart.draw(graphics2d, rectangle2d); graphics2d.dispose(); contentByte.addTemplate(template, 0, 0); } if (jCheckBox1.isSelected()) { for (int i = 0; i < dlm3.size(); i++) { DefaultCategoryDataset dataSet = new DefaultCategoryDataset(); String str = dlm3.get(i).toString(); System.out.println(str); String[] parts = str.split(":"); String part1 = parts[0]; String part2 = parts[1]; System.out.println(part2); int row = Integer.parseInt(part2) - 1; float total = (float) 0.0; for (int j = 77; j < header.length && j < bull1[row].length; j++) { if (bull1[row][j].equals("")) { continue; } else { total += Integer.parseInt(bull1[row][j]); } } System.out.println(total); for (int j = 77; j < header.length && j < bull1[row].length; j++) { if (!bull1[row][j].equals("")) { String[] Parts = header[j].split("_"); String Part2 = Parts[1]; dataSet.setValue((Integer.parseInt(bull1[row][j]) * 100) / total, "Percent", Part2); } else { dataSet.setValue(0, "Percent", header[j]); } } JFreeChart chart = ChartFactory.createBarChart("Single Bull Morphology Chart " + part1, "Morphology", "Percent", dataSet, PlotOrientation.VERTICAL, false, true, false); if ((dlm3.size() > 12 && i == 0) || jCheckBox2.isSelected()) { doc.newPage(); } PdfContentByte contentByte = docWriter.getDirectContent(); PdfTemplate template = contentByte.createTemplate(325, 250); PdfGraphics2D graphics2d = new PdfGraphics2D(template, 325, 250); Rectangle2D rectangle2d = new Rectangle2D.Double(0, 0, 325, 250); chart.draw(graphics2d, rectangle2d); graphics2d.dispose(); contentByte.addTemplate(template, 0, 0); doc.newPage(); } } } catch (DocumentException dex) { dex.printStackTrace(); } catch (FileNotFoundException ex) { Logger.getLogger(ReporterArchive.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(ReporterArchive.class.getName()).log(Level.SEVERE, null, ex); } finally { if (doc != null) { //close the document doc.close(); } if (docWriter != null) { //close the writer docWriter.close(); } } controller.openDocument(Path); }
From source file:hsa.awp.admingui.report.util.HeaderFooter.java
License:Open Source License
/** * this method is called by Pageevent.//from w w w.j a v a 2 s. c o m * * @param writer write of the document * @param document document it self */ public void onEndPage(PdfWriter writer, Document document) { Rectangle rect = writer.getBoxSize("art"); /* title */ ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_LEFT, new Phrase(title, FontFactory.getFont(FontFactory.HELVETICA_BOLD, 16)), rect.getLeft(), rect.getTop() + 20, 0); /* subtitle */ ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_LEFT, new Phrase(subtitle, FontFactory.getFont(FontFactory.HELVETICA, 9)), rect.getLeft(), rect.getTop() + 9, 0); /* date */ DateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy"); java.util.Date date = new java.util.Date(); ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_RIGHT, new Phrase(dateFormat.format(date)), rect.getRight(), rect.getTop() + 15, 0); /* pagenumber */ ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_CENTER, new Phrase(String.format("Seite %d", writer.getPageNumber())), (rect.getLeft() + rect.getRight()) / 2, rect.getBottom() - 25, 0); }
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();// w w w . jav a2 s .c om 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(); }