List of usage examples for com.lowagie.text Chunk Chunk
public Chunk(DrawInterface separator, float tabPosition)
From source file:airportpainter.util.AirportPainter.java
License:Open Source License
private void createSheetsLights(Airport airport, Document document) { // FREQs Nearest Navaid notifyAction("createSheetsLights"); PdfPTable table = new PdfPTable(1); {// ww w.j a v a 2s . c om PdfPCell cell = new PdfPCell(); cell.setVerticalAlignment(Element.ALIGN_TOP); cell.setMinimumHeight(20); Paragraph p = new Paragraph(); p.setLeading((p.leading() / 2) + 4); com.lowagie.text.Font font = new com.lowagie.text.Font(com.lowagie.text.Font.TIMES_ROMAN, 10, com.lowagie.text.Font.NORMAL); oneLightDone = false; try { p.add(new Chunk(" ", font)); p.add(new Chunk(Image.getInstance(getClass().getResource(Main.imgFolder + "light.png")), 0, 0)); p.add(new Chunk(" ", font)); } catch (BadElementException ex) { Logger.getLogger(AirportPainter.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(AirportPainter.class.getName()).log(Level.SEVERE, null, ex); } boolean addABN = airport.hasBeacon(); if (addABN) { p.add(addOneLight("ABN", font)); } boolean addALS = false; boolean addPAPI = false; for (final Runway runway : airport.getRunways()) { if ((runway.hasALSF_I(false) || runway.hasALSF_I(true)) || (runway.hasALSF_II(false) || runway.hasALSF_II(true))) { addALS = true; } if ((runway.hasPapi(false) || runway.hasPapi(true))) { addPAPI = true; } } if (addALS) { p.add(addOneLight("ALS", font)); } if (addPAPI) { p.add(addOneLight("PAPI ", font)); String separ = ""; for (final Runway runway : airport.getRunways()) { if (runway.hasPapi(false)) { p.add(new Chunk(separ + runway.getNumber() + " (3.5)" + degrees + " ", font)); separ = ", "; } if (runway.hasPapi(true)) { p.add(new Chunk(separ + runway.getOppositeNumber() + " (3.5)" + degrees + " ", font)); separ = ", "; } } } cell.addElement(p); //cell.setBorder(com.lowagie.text.Rectangle.NO_BORDER); cell.setBorderWidth(borderWidth); cell.setVerticalAlignment(Element.ALIGN_CENTER); table.addCell(cell); } table.setWidthPercentage(100); try { document.add(table); } catch (DocumentException ex) { Logger.getLogger(AirportPainter.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:airportpainter.util.AirportPainter.java
License:Open Source License
private void createSheetsNotes(Airport airport, Document document) { // FREQs Nearest Navaid notifyAction("createSheetsNotes"); PdfPTable table = new PdfPTable(1); {//from w w w. j av a 2 s. co m PdfPCell cell = new PdfPCell(); cell.setVerticalAlignment(Element.ALIGN_CENTER); { Paragraph p = new Paragraph(); com.lowagie.text.Font fontWarning = new com.lowagie.text.Font(com.lowagie.text.Font.TIMES_ROMAN, com.lowagie.text.Font.DEFAULTSIZE, com.lowagie.text.Font.BOLD); p.add(new Chunk("Warning !", fontWarning)); cell.addElement(p); } { Paragraph p = new Paragraph(); com.lowagie.text.Font fontText = new com.lowagie.text.Font(com.lowagie.text.Font.TIMES_ROMAN, com.lowagie.text.Font.DEFAULTSIZE, com.lowagie.text.Font.NORMAL); p.add(new Chunk( "Do not use this chart in real life, this is a chart suitable to be used only for FlightGear !!!", fontText)); cell.addElement(p); } cell.setBorderWidth(borderWidth); cell.setVerticalAlignment(Element.ALIGN_CENTER); table.addCell(cell); } table.setWidthPercentage(100); try { document.add(table); } catch (DocumentException ex) { Logger.getLogger(AirportPainter.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:airportpainter.util.AirportPainter.java
License:Open Source License
private void createSheets2Freqs(Airport airport, Document document) { // FREQs Nearest Navaid notifyAction("createSheets2Freqs"); PdfPTable table = new PdfPTable(2); {/* ww w . j a va 2s . c o m*/ PdfPCell cell = new PdfPCell(); { Paragraph p = new Paragraph("Within Airspace:", new com.lowagie.text.Font( com.lowagie.text.Font.TIMES_ROMAN, 8, com.lowagie.text.Font.NORMAL)); cell.addElement(p); } cell.setBorderWidth(borderWidth); cell.setBorderWidthBottom(borderWidthThin); //cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); } { PdfPCell cell = new PdfPCell(); com.lowagie.text.Font fontBold = new com.lowagie.text.Font(com.lowagie.text.Font.TIMES_ROMAN, com.lowagie.text.Font.DEFAULTSIZE, com.lowagie.text.Font.BOLD); com.lowagie.text.Font font = new com.lowagie.text.Font(com.lowagie.text.Font.TIMES_ROMAN, com.lowagie.text.Font.DEFAULTSIZE, com.lowagie.text.Font.NORMAL); { Paragraph p = new Paragraph(airport.getId(), fontBold); cell.addElement(p); } { Paragraph p = new Paragraph(); p.add(new Chunk("Elev ", font)); int feets = (int) (airport.getElevation()); p.add(new Chunk(new Integer(feets).toString() + "'", fontBold)); int meters = (int) (feets / FEET_PER_METER); p.add(new Chunk("/" + new Integer(meters).toString() + "m", font)); cell.addElement(p); } { Paragraph p = new Paragraph(); p.add(new Chunk(airport.getLatitudeString1(airport.getLat(), "N", "S", 2, false) + "\r\n" + airport.getLatitudeString1(airport.getLong(), "W", "E", 3, true), font)); cell.addElement(p); } cell.setBorder(com.lowagie.text.Rectangle.NO_BORDER); cell.setVerticalAlignment(Element.ALIGN_BOTTOM); table.addCell(cell); } table.setWidthPercentage(100); try { document.add(table); } catch (DocumentException ex) { Logger.getLogger(AirportPainter.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:airportpainter.util.AirportPainter.java
License:Open Source License
private void createSheets2ILS(Airport airport, Document document) { // FREQs Nearest Navaid notifyAction("createSheets2ILS"); PdfPTable table = new PdfPTable(2); {/*from w ww.j av a2 s . c o m*/ PdfPCell cell = new PdfPCell(); { Paragraph p = new Paragraph("(TWR)", new com.lowagie.text.Font(com.lowagie.text.Font.TIMES_ROMAN, 8, com.lowagie.text.Font.NORMAL)); p.setLeading((p.leading() / 2) + 2); cell.addElement(p); } List<ATCFreq> tempFreqsTwr = _airport.getATCFreqs("54"); List<ATCFreq> tempFreqsGnd = _airport.getATCFreqs("53"); if (tempFreqsTwr.size() > 0 || tempFreqsGnd.size() > 0) { if (tempFreqsTwr.size() > 0) { Paragraph p = new Paragraph(); p.setLeading((p.leading() / 2) + 6); Chunk c = new Chunk(airport.getName().toUpperCase() + " APPROACH ", new com.lowagie.text.Font( com.lowagie.text.Font.TIMES_ROMAN, 8, com.lowagie.text.Font.NORMAL)); p.add(c); for (final ATCFreq tower : tempFreqsTwr) { Chunk c2 = new Chunk((tower.getFreq() + " ").substring(0, 9) + " ", new com.lowagie.text.Font(com.lowagie.text.Font.TIMES_ROMAN, 8, com.lowagie.text.Font.BOLD)); p.add(c2); } cell.addElement(p); } if (tempFreqsGnd.size() > 0) { Paragraph p = new Paragraph(); p.setLeading((p.leading() / 2) + 6); Chunk c = new Chunk("GROUND ", new com.lowagie.text.Font(com.lowagie.text.Font.TIMES_ROMAN, 8, com.lowagie.text.Font.NORMAL)); p.add(c); for (final ATCFreq tower : tempFreqsGnd) { Chunk c2 = new Chunk((tower.getFreq() + " ").substring(0, 9) + " ", new com.lowagie.text.Font(com.lowagie.text.Font.TIMES_ROMAN, 8, com.lowagie.text.Font.BOLD)); p.add(c2); } cell.addElement(p); } } cell.setBorderWidth(borderWidth); cell.setBorderWidthTop(borderWidthThin); cell.setBorderWidthRight(borderWidthThin); //cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); } { com.lowagie.text.Font font = new com.lowagie.text.Font(com.lowagie.text.Font.TIMES_ROMAN, com.lowagie.text.Font.DEFAULTSIZE, com.lowagie.text.Font.NORMAL); PdfPCell cell = new PdfPCell(); Paragraph p = new Paragraph(); p.setLeading((p.leading()) + 6); Chunk c = new Chunk("ATIS ", new com.lowagie.text.Font(com.lowagie.text.Font.TIMES_ROMAN, 8, com.lowagie.text.Font.NORMAL)); p.add(c); for (final Atis atis : _airport.getAtises()) { Chunk c2 = new Chunk((atis.getFreq() + " ").substring(0, 9) + " ", new com.lowagie.text.Font( com.lowagie.text.Font.TIMES_ROMAN, 8, com.lowagie.text.Font.BOLD)); p.add(c2); } cell.addElement(p); /// ILS table { height1 = 0; PdfPTable tableILS = new PdfPTable(4); tableILS.setWidthPercentage(100); // titles com.lowagie.text.Font fontTitle = new com.lowagie.text.Font(com.lowagie.text.Font.TIMES_ROMAN, 8, com.lowagie.text.Font.NORMAL); { PdfPCell cellTitle = new PdfPCell(); cellTitle.setVerticalAlignment(Element.ALIGN_CENTER); cellTitle.setBorderWidth(borderWidthThin); Paragraph pt = new Paragraph("RWY", fontTitle); pt.setLeading((pt.leading() / 2) + 2); pt.setAlignment(Element.ALIGN_CENTER); cellTitle.addElement(pt); tableILS.addCell(cellTitle); } { PdfPCell cellTitle = new PdfPCell(); cellTitle.setVerticalAlignment(Element.ALIGN_CENTER); cellTitle.setBorderWidth(borderWidthThin); Paragraph pt = new Paragraph("ILS", fontTitle); pt.setLeading((pt.leading() / 2) + 2); pt.setAlignment(Element.ALIGN_CENTER); cellTitle.addElement(pt); tableILS.addCell(cellTitle); } { PdfPCell cellTitle = new PdfPCell(); cellTitle.setVerticalAlignment(Element.ALIGN_CENTER); cellTitle.setBorderWidth(borderWidthThin); Paragraph pt = new Paragraph("RWY", fontTitle); pt.setLeading((pt.leading() / 2) + 2); pt.setAlignment(Element.ALIGN_CENTER); cellTitle.addElement(pt); tableILS.addCell(cellTitle); } { PdfPCell cellTitle = new PdfPCell(); cellTitle.setVerticalAlignment(Element.ALIGN_CENTER); cellTitle.setBorderWidth(borderWidthThin); Paragraph pt = new Paragraph("ILS", fontTitle); pt.setLeading((pt.leading() / 2) + 2); pt.setAlignment(Element.ALIGN_CENTER); cellTitle.addElement(pt); tableILS.addCell(cellTitle); } int pos = 0; int rs = airport.getRunways().size(); for (final Runway runway : airport.getRunways()) { if (runway.getIlsFreq() != 0) { height1 = height1 + 10; { PdfPCell cellFreq = new PdfPCell(); cellFreq.setVerticalAlignment(Element.ALIGN_CENTER); cellFreq.setBorderWidth(borderWidthThin); if (pos > 0) { cellFreq.setBorderWidthTop(0); } if (pos < rs - 1) { cellFreq.setBorderWidthBottom(0); } Paragraph pt = new Paragraph(runway.getNumber(), fontTitle); pt.setLeading((pt.leading() / 2) + 2); pt.setAlignment(Element.ALIGN_CENTER); cellFreq.addElement(pt); tableILS.addCell(cellFreq); } { PdfPCell cellFreq = new PdfPCell(); cellFreq.setVerticalAlignment(Element.ALIGN_CENTER); cellFreq.setBorderWidth(borderWidthThin); if (pos > 0) { cellFreq.setBorderWidthTop(0); } if (pos < rs - 1) { cellFreq.setBorderWidthBottom(0); } Paragraph pt = new Paragraph( runway.getIlsFreq() + " " + "... " + new Integer((int) runway.getHeading()).toString() + degrees, fontTitle); pt.setLeading((pt.leading() / 2) + 2); pt.setAlignment(Element.ALIGN_CENTER); cellFreq.addElement(pt); tableILS.addCell(cellFreq); } } /*else { { PdfPCell cellFreq = new PdfPCell(); cellFreq.setVerticalAlignment(Element.ALIGN_CENTER); cellFreq.setBorderWidth(borderWidthThin); if (pos>0) { cellFreq.setBorderWidthTop(0); } if (pos<rs-1) { cellFreq.setBorderWidthBottom(0); } Paragraph pt=new Paragraph( "",fontTitle); pt.setLeading((pt.leading()/2)+2); pt.setAlignment(Element.ALIGN_CENTER); cellFreq.addElement(pt); tableILS.addCell(cellFreq); } { PdfPCell cellFreq = new PdfPCell(); cellFreq.setVerticalAlignment(Element.ALIGN_CENTER); cellFreq.setBorderWidth(borderWidthThin); if (pos>0) { cellFreq.setBorderWidthTop(0); } if (pos<rs-1) { cellFreq.setBorderWidthBottom(0); } Paragraph pt=new Paragraph( "",fontTitle); pt.setLeading((pt.leading()/2)+2); pt.setAlignment(Element.ALIGN_CENTER); cellFreq.addElement(pt); tableILS.addCell(cellFreq); } }*/ if (runway.getIlsOppositeFreq() != 0) { { PdfPCell cellFreq = new PdfPCell(); cellFreq.setVerticalAlignment(Element.ALIGN_CENTER); cellFreq.setBorderWidth(borderWidthThin); if (pos > 0) { cellFreq.setBorderWidthTop(0); } if (pos < rs - 1) { cellFreq.setBorderWidthBottom(0); } Paragraph pt = new Paragraph(runway.getOppositeNumber(), fontTitle); pt.setLeading((pt.leading() / 2) + 2); pt.setAlignment(Element.ALIGN_CENTER); cellFreq.addElement(pt); tableILS.addCell(cellFreq); } { PdfPCell cellFreq = new PdfPCell(); cellFreq.setVerticalAlignment(Element.ALIGN_CENTER); cellFreq.setBorderWidth(borderWidthThin); if (pos > 0) { cellFreq.setBorderWidthTop(0); } if (pos < rs - 1) { cellFreq.setBorderWidthBottom(0); } Paragraph pt = new Paragraph(runway.getIlsOppositeFreq() + " " + "... " + new Integer((int) (runway.getHeading() + 180) % 180).toString() + degrees, fontTitle); pt.setLeading((pt.leading() / 2) + 2); pt.setAlignment(Element.ALIGN_CENTER); cellFreq.addElement(pt); tableILS.addCell(cellFreq); } } else { { PdfPCell cellFreq = new PdfPCell(); cellFreq.setVerticalAlignment(Element.ALIGN_CENTER); cellFreq.setBorderWidth(borderWidthThin); if (pos > 0) { cellFreq.setBorderWidthTop(0); } if (pos < rs - 1) { cellFreq.setBorderWidthBottom(0); } Paragraph pt = new Paragraph("", fontTitle); pt.setLeading((pt.leading() / 2) + 2); pt.setAlignment(Element.ALIGN_CENTER); cellFreq.addElement(pt); tableILS.addCell(cellFreq); } { PdfPCell cellFreq = new PdfPCell(); cellFreq.setVerticalAlignment(Element.ALIGN_CENTER); cellFreq.setBorderWidth(borderWidthThin); if (pos > 0) { cellFreq.setBorderWidthTop(0); } if (pos < rs - 1) { cellFreq.setBorderWidthBottom(0); } Paragraph pt = new Paragraph("", fontTitle); pt.setLeading((pt.leading() / 2) + 2); pt.setAlignment(Element.ALIGN_CENTER); cellFreq.addElement(pt); tableILS.addCell(cellFreq); } } pos++; } float[] widths2 = { 1f, 3f, 1f, 3f }; try { tableILS.setWidths(widths2); } catch (DocumentException ex) { Logger.getLogger(AirportPainter.class.getName()).log(Level.SEVERE, null, ex); } cell.addElement(tableILS); } cell.setBorderWidth(borderWidth); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); } table.setWidthPercentage(100); try { document.add(table); } catch (DocumentException ex) { Logger.getLogger(AirportPainter.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:ambit.data.qmrf.Qmrf_Xml_Pdf.java
License:Open Source License
protected int getText(org.w3c.dom.Node node, Phrase phrase, Font currentFont, ScriptMode scriptMode, boolean trim, int paragraphs) { if (node.getNodeType() == node.ELEMENT_NODE) { if ("head".equals(node.getNodeName())) return paragraphs; if ("html".equals(node.getNodeName())) trim = true;// w w w. j av a 2s . c o m else if ("body".equals(node.getNodeName())) trim = true; else if ("p".equals(node.getNodeName())) trim = true; else trim = false; //if ("p".equals(node.getNodeName())) trim=true; // System.out.println(node.getNodeName() + ' ' + trim); //System.out.println(paragraphs); Font f = currentFont; int fweight = currentFont.style(); float fsize = currentFont.size(); Color clr = currentFont.color(); boolean modify = false; if ("b".equals(node.getNodeName())) { if ((currentFont.style() == Font.ITALIC) || (currentFont.style() == Font.BOLDITALIC)) fweight = Font.BOLDITALIC; else fweight = Font.BOLD; modify = true; } if ("i".equals(node.getNodeName())) { if ((currentFont.style() == Font.BOLD) || (currentFont.style() == Font.BOLDITALIC)) fweight = Font.BOLDITALIC; else fweight = Font.ITALIC; modify = true; } if ("sub".equals(node.getNodeName())) { scriptMode = ScriptMode.subscript; } if ("sup".equals(node.getNodeName())) { scriptMode = ScriptMode.superscript; } if ("font".equals(node.getNodeName())) { String r = ((org.w3c.dom.Element) node).getAttribute("color"); if (r != null) try { clr = Hex2Color(r.substring(1)); modify = true; } catch (Exception x) { clr = currentFont.color(); } String z = ((org.w3c.dom.Element) node).getAttribute("size"); if (z != null) { try { fsize = Integer.parseInt(z); modify = true; } catch (Exception x) { fsize = currentFont.size(); } } } if (modify) { f = FontFactory.getFont(currentFont.getFamilyname(), fsize, fweight, clr); } if ("p".equals(node.getNodeName())) { if (paragraphs > 0) phrase.add(new Chunk('\n', f)); paragraphs++; } //f = FontFactory.getFont(currentFont.getFamilyname(),curr) NodeList nodes = node.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) paragraphs += getText(nodes.item(i), phrase, f, scriptMode, trim, paragraphs); } else if (node.getNodeType() == node.TEXT_NODE) { String value = node.getNodeValue(); if (trim) value = replaceNewLine(value); if ("".equals(value)) return paragraphs; //System.out.println(value); Chunk chunk = new Chunk(value, currentFont); HyphenationAuto autoEN = new HyphenationAuto("en", "GB", 2, 2); chunk.setHyphenation(autoEN); switch (scriptMode) { case superscript: chunk.setTextRise(currentFont.size() * 0.3f); break; case subscript: chunk.setTextRise(-currentFont.size() * 0.3f); break; default: break; } phrase.add(chunk); } return paragraphs; }
From source file:appli_etudiants.ExportPDF.java
public static void main(Etudiants etudiant) throws SQLException, FileNotFoundException, BadElementException, IOException { try {/*w w w .j ava 2s.c om*/ Document document = new Document(PageSize.A4); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("c:/tesPDF.pdf")); document.open(); PdfContentByte canvas = writer.getDirectContentUnder(); Image image = Image.getInstance("c:/fond_cv.jpg"); image.setAbsolutePosition(0, 80); canvas.saveState(); PdfGState state = new PdfGState(); state.setFillOpacity(0.6f); canvas.setGState(state); canvas.addImage(image); canvas.restoreState(); LineSeparator lineSepa = new LineSeparator(); lineSepa.setLineColor(new Color(21, 96, 189)); Paragraph para1 = new Paragraph(); Paragraph para2 = new Paragraph(etudiant.getAdresse_rue()); Paragraph para3 = new Paragraph(etudiant.getAdresse_cp() + " " + etudiant.getAdresse_ville()); Paragraph para4 = new Paragraph(etudiant.getCourriel(), FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, new Color(21, 96, 189))); Paragraph para5 = new Paragraph(etudiant.getTel_personnel()); Paragraph para6 = new Paragraph(etudiant.getTel_professionnel()); Paragraph para7 = new Paragraph(etudiant.getSite_web()); para1.add(new Chunk(etudiant.getPrenom(), FontFactory.getFont(FontFactory.HELVETICA, 20, Font.BOLD, new Color(21, 96, 189)))); para1.add( new Chunk(" " + etudiant.getNom(), FontFactory.getFont(FontFactory.HELVETICA, 20, Font.BOLD))); Image image1 = Image.getInstance(DaoS4.getPhoto()); image1.scalePercent(50); image1.setAlignment(Image.RIGHT | Image.TEXTWRAP); image1.scaleAbsolute(94, 94); document.add(image1); document.add(para1); document.add(para2); document.add(para3); document.add(para4); document.add(para5); document.add(para6); para7.setSpacingAfter(25f); document.add(para7); Paragraph para8 = new Paragraph(DaoS4.getLibelleTitre()); para8.setSpacingBefore(25f); para8.setSpacingAfter(20f); document.add(para8); Paragraph para9 = new Paragraph(new Chunk("EXPERIENCE PROFESSIONELLE", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, new Color(21, 96, 189)))); para9.setSpacingBefore(15f); para9.setSpacingAfter(15f); document.add(para9); document.add(lineSepa); Paragraph para10 = new Paragraph(DaoS4.getLibelleExpPro()); para10.setSpacingAfter(15f); document.add(para10); Paragraph para11 = new Paragraph(new Chunk("FORMATION", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, new Color(21, 96, 189)))); para11.setSpacingBefore(15f); para11.setSpacingAfter(15f); document.add(para11); document.add(lineSepa); Paragraph para12 = new Paragraph(DaoS4.getLibelleFormation()); para12.setSpacingAfter(15f); document.add(para12); Paragraph para13 = new Paragraph(new Chunk("INFORMATIQUE", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, new Color(21, 96, 189)))); para13.setSpacingBefore(15f); para13.setSpacingAfter(15f); document.add(para13); document.add(lineSepa); Paragraph para14 = new Paragraph(DaoS4.getLibelleInformatique()); para14.setSpacingAfter(15f); document.add(para14); Paragraph para15 = new Paragraph(new Chunk("LANGUE", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, new Color(21, 96, 189)))); para15.setSpacingBefore(15f); para15.setSpacingAfter(15f); document.add(para15); document.add(lineSepa); Paragraph para16 = new Paragraph(DaoS4.getLibelleLangue()); para16.setSpacingAfter(15f); document.add(para16); Paragraph para17 = new Paragraph(new Chunk("CENTRES D'INTERET", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, new Color(21, 96, 189)))); para17.setSpacingBefore(15f); para17.setSpacingAfter(15f); document.add(para17); document.add(lineSepa); Paragraph para18 = new Paragraph(DaoS4.getLibelleInteret()); para18.setSpacingAfter(15f); document.add(para18); document.close(); } catch (DocumentException ex) { Logger.getLogger(ExportPDF.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:at.reppeitsolutions.formbuilder.components.pdf.formbuilder.PdfFormBuilderHeading.java
License:Open Source License
@Override public Element render() { Font font = new Font(); switch (getProperties().getSize()) { case 1:/*from ww w .j a va 2s. c o m*/ font.setSize(30); break; case 2: font.setSize(25); break; case 3: font.setSize(20); break; } Chunk chunk = new Chunk(getProperties().getValues(), font); return new ITextParagraph(chunk); }
From source file:at.reppeitsolutions.formbuilder.components.pdf.formbuilder.PdfFormBuilderSpace.java
License:Open Source License
@Override public Element render() { Font font = new Font(); switch (getProperties().getSize()) { case 10:/*from www . j a v a2 s .co m*/ font.setSize(1); break; case 30: font.setSize(6); break; case 50: font.setSize(10); break; } return new ITextParagraph(new Chunk(" ", font)); }
From source file:br.org.acessobrasil.silvinha.util.GeraRelatorioPDF.java
License:Open Source License
public static boolean geraRelatorio(File file) { TradGeraRelatorioPDF.carregaTexto(TokenLang.LANG); Document document = new Document(PageSize.A4); try {/*from w w w .java2s.c om*/ PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(file)); writer.setPageEvent(new HeaderAndFooter()); document.open(); int linha = 0, j, tot_pg = ResumoDoRelatorio.getTotPage(); //calcula o total de htmls float tot_link = 0.0f; for (j = 1; j <= tot_pg; j++) { String conteudo = ResumoDoRelatorio.getPage(j); String arr[] = conteudo.split("\n"); tot_link += arr.length; } PainelStatusBar.showProgTarReq(); //loop por todas as pginas da paginacao for (j = 1; j <= tot_pg; j++) { String conteudo = ResumoDoRelatorio.getPage(j); String arr[] = conteudo.split("\n"); int tot = arr.length; int i; //loop por todos os links for (i = 0; i < tot; i++) { progresso = (linha++ / tot_link) * 100.0f; PainelStatusBar.setValueProgress((int) progresso); String arr2[] = arr[i].split("\t"); if (arr2.length == 8) { String strUrl = arr2[7];// URL /* int ap1 = Integer.parseInt(arr2[4]);// Aviso1 int ep1 = Integer.parseInt(arr2[1]);// Erro1 int ap2 = Integer.parseInt(arr2[5]);// Aviso2 int ep2 = Integer.parseInt(arr2[2]);// Erro2 int ap3 = Integer.parseInt(arr2[6]);// Aviso3 int ep3 = Integer.parseInt(arr2[3]);// Erro3 */ String myHash = arr2[0]; RelatorioDaUrl relatorio = new RelatorioDaUrl(); relatorio.recarregaArquivoRelatorioEmXml2(myHash); document.add(new Phrase("\n")); Font font = FontFactory.getFont(FontFactory.HELVETICA, Font.DEFAULTSIZE, Font.BOLD); Chunk url = new Chunk(strUrl, font); Paragraph p1 = new Paragraph(TradGeraRelatorioPDF.RELATORIO_URL); p1.add(url); p1.setAlignment(Paragraph.ALIGN_LEFT); document.add(p1); document.add(new Phrase("\n\n")); if (relatorio.getErrosPrioridade1() <= 0 && relatorio.getErrosPrioridade2() <= 0 && relatorio.getErrosPrioridade3() <= 0) { Paragraph p2 = new Paragraph(TradGeraRelatorioPDF.PAGINAS_SEM_ERROS); p2.setAlignment(Paragraph.ALIGN_CENTER); document.add(p2); } else { if (relatorio.getErrosPrioridade1() > 0) { Paragraph p = new Paragraph(TradGeraRelatorioPDF.ERROS_P1, font); p1.setAlignment(Paragraph.ALIGN_LEFT); document.add(p); document.add(new Chunk("\n")); PdfPTable table = geraLista(relatorio.getListaErrosP1()); if (table != null) { document.add(table); } document.add(new Phrase("\n\n")); } if (relatorio.getErrosPrioridade2() > 0) { Paragraph p = new Paragraph(TradGeraRelatorioPDF.ERROS_P2, font); p1.setAlignment(Paragraph.ALIGN_LEFT); document.add(p); document.add(new Chunk("\n")); PdfPTable table = geraLista(relatorio.getListaErrosP2()); if (table != null) { document.add(table); } document.add(new Phrase("\n\n")); } if (relatorio.getErrosPrioridade3() > 0) { Paragraph p = new Paragraph(TradGeraRelatorioPDF.ERROS_P3, font); p1.setAlignment(Paragraph.ALIGN_LEFT); document.add(p); document.add(new Chunk("\n")); PdfPTable table = geraLista(relatorio.getListaErrosP3()); if (table != null) { document.add(table); } document.add(new Phrase("\n\n")); } document.newPage(); } } } } writer.flush(); document.close(); } catch (DocumentException de) { log.error(de.getMessage(), de); PainelStatusBar.hideProgTarReq(); return false; } catch (IOException ioe) { log.error(ioe.getMessage(), ioe); PainelStatusBar.hideProgTarReq(); return false; } PainelStatusBar.hideProgTarReq(); return true; }
From source file:br.org.acessobrasil.silvinha.util.GeraRelatorioPDF.java
License:Open Source License
public static boolean geraRelatorio_bkp(File file, ResumoDoRelatorio resumo) { Document document = new Document(PageSize.A4); try {/* w ww . ja va 2 s . c o m*/ PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(file)); writer.setPageEvent(new HeaderAndFooter()); document.open(); ArrayList<RelatorioDaUrl> relatorios = resumo.getRelatorios(); loop: for (RelatorioDaUrl relatorio : relatorios) { document.add(new Phrase("\n")); Font font = FontFactory.getFont(FontFactory.HELVETICA, Font.DEFAULTSIZE, Font.BOLD); Chunk url = new Chunk(relatorio.getUrl(), font); Paragraph p1 = new Paragraph(TradGeraRelatorioPDF.RELATORIO_URL); p1.add(url); p1.setAlignment(Paragraph.ALIGN_LEFT); document.add(p1); document.add(new Phrase("\n\n")); if (relatorio.getErrosPrioridade1() <= 0 && relatorio.getErrosPrioridade2() <= 0 && relatorio.getErrosPrioridade3() <= 0) { Paragraph p2 = new Paragraph(TradGeraRelatorioPDF.PAGINAS_SEM_ERROS); p2.setAlignment(Paragraph.ALIGN_CENTER); document.add(p2); continue loop; } if (relatorio.getErrosPrioridade1() > 0) { Paragraph p = new Paragraph(TradGeraRelatorioPDF.ERROS_P1_SEM_TAB, font); p1.setAlignment(Paragraph.ALIGN_LEFT); document.add(p); document.add(new Chunk("\n")); PdfPTable table = geraLista(relatorio.getListaErrosP1()); if (table != null) { document.add(table); } document.add(new Phrase("\n\n")); } if (relatorio.getErrosPrioridade2() > 0) { Paragraph p = new Paragraph(TradGeraRelatorioPDF.ERROS_P2_SEM_TAB, font); p1.setAlignment(Paragraph.ALIGN_LEFT); document.add(p); document.add(new Chunk("\n")); PdfPTable table = geraLista(relatorio.getListaErrosP2()); if (table != null) { document.add(table); } document.add(new Phrase("\n\n")); } if (relatorio.getErrosPrioridade3() > 0) { Paragraph p = new Paragraph(TradGeraRelatorioPDF.ERROS_P3_SEM_TAB, font); p1.setAlignment(Paragraph.ALIGN_LEFT); document.add(p); document.add(new Chunk("\n")); PdfPTable table = geraLista(relatorio.getListaErrosP3()); if (table != null) { document.add(table); } document.add(new Phrase("\n\n")); } document.newPage(); } writer.flush(); document.close(); } catch (DocumentException de) { log.error(de.getMessage(), de); return false; } catch (IOException ioe) { log.error(ioe.getMessage(), ioe); return false; } return true; }