List of usage examples for com.itextpdf.text Image scaleAbsolute
public void scaleAbsolute(final float newWidth, final float newHeight)
From source file:ihm.panneaux.GenererPdf.java
private void initComponement() throws FileNotFoundException, DocumentException, IOException { String DEST = "devis/devis-" + devis.getNumero() + ".pdf"; OutputStream file = new FileOutputStream(new File(DEST)); com.itextpdf.text.Document document = new com.itextpdf.text.Document(); PdfWriter.getInstance((com.itextpdf.text.Document) document, file); // PAS TOUCHE PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(DEST)); Rectangle rect = new Rectangle(30, 30, 550, 800); writer.setBoxSize("art", rect); HeaderFooterPageEvent event = new HeaderFooterPageEvent(); writer.setPageEvent(event);//from ww w . j av a2s . c om document.open(); PdfContentByte canvas = writer.getDirectContent(); Image logo = Image.getInstance("images/logo.png"); logo.scaleAbsolute(200, 57); // INFO DEVIS Image devisImg = Image.getInstance("images/imgDevis.png"); devisImg.scaleAbsolute(110, 34); devisImg.setAbsolutePosition((PageSize.POSTCARD.getWidth() + 150), (PageSize.POSTCARD.getHeight() - devisImg.getScaledHeight()) * 2); Font fontImgDevis = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD); Phrase numeroInfo = new Phrase("Numro " + devis.getNumero(), fontImgDevis); ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, numeroInfo, devisImg.getScaledWidth() + 413, devisImg.getScaledHeight() + 710, 0); Phrase dateInfo = new Phrase("Le " + devis.getDate(), fontImgDevis); ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, dateInfo, devisImg.getScaledWidth() + 420, devisImg.getScaledHeight() + 695, 0); Image devisImgBordure = Image.getInstance("images/bordureDevis.png"); devisImgBordure.setAbsolutePosition((devisImg.getScaledWidth() + 318), devisImg.getScaledHeight() + 660); devisImgBordure.scaleAbsolute(120, 122); // INFO ENTREPRISE Font fontEntreprise = new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.BOLD); Phrase coGerants = new Phrase("Co-grants : " + devis.getEntreprise().getCoGerant(), fontEntreprise); ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, coGerants, devisImg.getScaledWidth() + 210, devisImg.getScaledHeight() + 660, 0); Phrase siege = new Phrase("Sige : " + devis.getEntreprise().getSiege(), fontEntreprise); ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, siege, devisImg.getScaledWidth() + 149, devisImg.getScaledHeight() + 640, 0); Phrase tel = new Phrase("TEL : " + devis.getEntreprise().getTel(), fontEntreprise); ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, tel, devisImg.getScaledWidth() + 113, devisImg.getScaledHeight() + 625, 0); Image bordureEntreprise = Image.getInstance("images/bordureEntreprise.png"); bordureEntreprise.setAbsolutePosition(devisImg.getScaledWidth() - 80, devisImg.getScaledHeight() + 610); // INFO CLIENT Font fontClient = new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.NORMAL); Phrase nomPrenom = new Phrase(devis.getClient().getNom() + " " + devis.getClient().getPrenom(), fontClient); Phrase commune = new Phrase(devis.getClient().getAdresse(), fontClient); Phrase adresse = new Phrase(devis.getClient().getCodePostale() + " " + devis.getClient().getCommune(), fontClient); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, nomPrenom, PageSize.A4.getWidth() - 280, devisImg.getScaledHeight() + 595, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, commune, PageSize.A4.getWidth() - 280, devisImg.getScaledHeight() + 580, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, adresse, PageSize.A4.getWidth() - 280, devisImg.getScaledHeight() + 565, 0); document.add(logo); document.add(devisImg); document.add(devisImgBordure); document.add(bordureEntreprise); // AJOUT DES DONNEES DU TABLEAUX float[] columnWidths = { 14, 3, 4, 3, 4 }; Font fontCategorie = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD); fontCategorie.setColor(BaseColor.GREEN); PdfPTable table = new PdfPTable(columnWidths); table.getDefaultCell().setBorder(Rectangle.NO_BORDER); table.setTotalWidth(PageSize.A4.getWidth() - 15); table.setSpacingBefore(150); table.setLockedWidth(true); Font Categorie = new Font(FontFamily.HELVETICA, 13, Font.BOLD); Font Chantier = new Font(FontFamily.HELVETICA, 11, Font.UNDERLINE); PdfPCell cellChantier = new PdfPCell(new Phrase("CHANTIER : " + chantier, Chantier)); cellChantier.setColspan(3); cellChantier.setBorder(Rectangle.NO_BORDER); table.addCell(cellChantier); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(new Phrase("Dsignation", Categorie)); PdfPCell unite = new PdfPCell(new Phrase("Unite", Categorie)); PdfPCell quantite = new PdfPCell(new Phrase("Quantite", Categorie)); PdfPCell prixht = new PdfPCell(new Phrase("Prix HT", Categorie)); PdfPCell pvtht = new PdfPCell(new Phrase("Pvt HT", Categorie)); unite.setHorizontalAlignment(Element.ALIGN_CENTER); quantite.setHorizontalAlignment(Element.ALIGN_CENTER); prixht.setHorizontalAlignment(Element.ALIGN_CENTER); pvtht.setHorizontalAlignment(Element.ALIGN_CENTER); unite.setBorder(Rectangle.NO_BORDER); quantite.setBorder(Rectangle.NO_BORDER); prixht.setBorder(Rectangle.NO_BORDER); pvtht.setBorder(Rectangle.NO_BORDER); table.addCell(unite); table.addCell(quantite); table.addCell(prixht); table.addCell(pvtht); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); double htTotalParcour = 0; double ttcTotalParcour = 0; if (this.EquipementDeChantier.isEmpty() == false) { table.addCell(new Phrase("Equipement De Chantier", fontCategorie)); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); for (DevisContenu listeMaterielDevi : EquipementDeChantier) { table.addCell(listeMaterielDevi.getMateriel().getNom()); PdfPCell cellunite = new PdfPCell(new Phrase(listeMaterielDevi.getMateriel().getUnite())); PdfPCell cellQuantite = new PdfPCell(new Phrase(Double.toString(listeMaterielDevi.getQuantite()))); PdfPCell cellprix = new PdfPCell( new Phrase(Double.toString(listeMaterielDevi.getMateriel().getPrix()) + "")); PdfPCell cellpvtHT = new PdfPCell( new Phrase(Double.toString(listeMaterielDevi.getPvtHT()) + "")); cellunite.setHorizontalAlignment(Element.ALIGN_CENTER); cellQuantite.setHorizontalAlignment(Element.ALIGN_CENTER); cellprix.setHorizontalAlignment(Element.ALIGN_CENTER); cellpvtHT.setHorizontalAlignment(Element.ALIGN_CENTER); cellunite.setBorder(Rectangle.NO_BORDER); cellQuantite.setBorder(Rectangle.NO_BORDER); cellprix.setBorder(Rectangle.NO_BORDER); cellpvtHT.setBorder(Rectangle.NO_BORDER); table.addCell(cellunite); table.addCell(cellQuantite); table.addCell(cellprix); table.addCell(cellpvtHT); /* BACKUP table.addCell(listeMaterielDevi.getMateriel().getNom()); table.addCell(listeMaterielDevi.getMateriel().getUnite()); table.addCell(Double.toString(listeMaterielDevi.getQuantite())); table.addCell(Double.toString(listeMaterielDevi.getMateriel().getPrix())+""); table.addCell(Double.toString(listeMaterielDevi.getPvtHT())+""); */ ttcTotalParcour += listeMaterielDevi.getPvtHT(); htTotalParcour += listeMaterielDevi.getPvtHT(); } table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); } if (Couverture.isEmpty() == false) { table.addCell(new Phrase("Couverture", fontCategorie)); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); for (DevisContenu listeMaterielDevi : Couverture) { table.addCell(listeMaterielDevi.getMateriel().getNom()); PdfPCell cellunite = new PdfPCell(new Phrase(listeMaterielDevi.getMateriel().getUnite())); PdfPCell cellQuantite = new PdfPCell(new Phrase(Double.toString(listeMaterielDevi.getQuantite()))); PdfPCell cellprix = new PdfPCell( new Phrase(Double.toString(listeMaterielDevi.getMateriel().getPrix()) + "")); PdfPCell cellpvtHT = new PdfPCell( new Phrase(Double.toString(listeMaterielDevi.getPvtHT()) + "")); cellunite.setHorizontalAlignment(Element.ALIGN_CENTER); cellQuantite.setHorizontalAlignment(Element.ALIGN_CENTER); cellprix.setHorizontalAlignment(Element.ALIGN_CENTER); cellpvtHT.setHorizontalAlignment(Element.ALIGN_CENTER); cellunite.setBorder(Rectangle.NO_BORDER); cellQuantite.setBorder(Rectangle.NO_BORDER); cellprix.setBorder(Rectangle.NO_BORDER); cellpvtHT.setBorder(Rectangle.NO_BORDER); table.addCell(cellunite); table.addCell(cellQuantite); table.addCell(cellprix); table.addCell(cellpvtHT); ttcTotalParcour += listeMaterielDevi.getPvtHT(); htTotalParcour += listeMaterielDevi.getPvtHT(); } table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); } if (CouvertureArdoise.isEmpty() == false) { table.addCell(new Phrase("Couverture Ardoise", fontCategorie)); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); for (DevisContenu listeMaterielDevi : CouvertureArdoise) { table.addCell(listeMaterielDevi.getMateriel().getNom()); PdfPCell cellunite = new PdfPCell(new Phrase(listeMaterielDevi.getMateriel().getUnite())); PdfPCell cellQuantite = new PdfPCell(new Phrase(Double.toString(listeMaterielDevi.getQuantite()))); PdfPCell cellprix = new PdfPCell( new Phrase(Double.toString(listeMaterielDevi.getMateriel().getPrix()) + "")); PdfPCell cellpvtHT = new PdfPCell( new Phrase(Double.toString(listeMaterielDevi.getPvtHT()) + "")); cellunite.setHorizontalAlignment(Element.ALIGN_CENTER); cellQuantite.setHorizontalAlignment(Element.ALIGN_CENTER); cellprix.setHorizontalAlignment(Element.ALIGN_CENTER); cellpvtHT.setHorizontalAlignment(Element.ALIGN_CENTER); cellunite.setBorder(Rectangle.NO_BORDER); cellQuantite.setBorder(Rectangle.NO_BORDER); cellprix.setBorder(Rectangle.NO_BORDER); cellpvtHT.setBorder(Rectangle.NO_BORDER); table.addCell(cellunite); table.addCell(cellQuantite); table.addCell(cellprix); table.addCell(cellpvtHT); ttcTotalParcour += listeMaterielDevi.getPvtHT(); htTotalParcour += listeMaterielDevi.getPvtHT(); } table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); } if (CouvertureTuile.isEmpty() == false) { table.addCell(new Phrase("Couverture Tuile", fontCategorie)); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); for (DevisContenu listeMaterielDevi : CouvertureTuile) { table.addCell(listeMaterielDevi.getMateriel().getNom()); PdfPCell cellunite = new PdfPCell(new Phrase(listeMaterielDevi.getMateriel().getUnite())); PdfPCell cellQuantite = new PdfPCell(new Phrase(Double.toString(listeMaterielDevi.getQuantite()))); PdfPCell cellprix = new PdfPCell( new Phrase(Double.toString(listeMaterielDevi.getMateriel().getPrix()) + "")); PdfPCell cellpvtHT = new PdfPCell( new Phrase(Double.toString(listeMaterielDevi.getPvtHT()) + "")); cellunite.setHorizontalAlignment(Element.ALIGN_CENTER); cellQuantite.setHorizontalAlignment(Element.ALIGN_CENTER); cellprix.setHorizontalAlignment(Element.ALIGN_CENTER); cellpvtHT.setHorizontalAlignment(Element.ALIGN_CENTER); cellunite.setBorder(Rectangle.NO_BORDER); cellQuantite.setBorder(Rectangle.NO_BORDER); cellprix.setBorder(Rectangle.NO_BORDER); cellpvtHT.setBorder(Rectangle.NO_BORDER); table.addCell(cellunite); table.addCell(cellQuantite); table.addCell(cellprix); table.addCell(cellpvtHT); ttcTotalParcour += listeMaterielDevi.getPvtHT(); htTotalParcour += listeMaterielDevi.getPvtHT(); } table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); } if (this.Demoussage.isEmpty() == false) { table.addCell(new Phrase("Demoussage", fontCategorie)); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); for (DevisContenu listeMaterielDevi : Demoussage) { table.addCell(listeMaterielDevi.getMateriel().getNom()); PdfPCell cellunite = new PdfPCell(new Phrase(listeMaterielDevi.getMateriel().getUnite())); PdfPCell cellQuantite = new PdfPCell(new Phrase(Double.toString(listeMaterielDevi.getQuantite()))); PdfPCell cellprix = new PdfPCell( new Phrase(Double.toString(listeMaterielDevi.getMateriel().getPrix()) + "")); PdfPCell cellpvtHT = new PdfPCell( new Phrase(Double.toString(listeMaterielDevi.getPvtHT()) + "")); cellunite.setHorizontalAlignment(Element.ALIGN_CENTER); cellQuantite.setHorizontalAlignment(Element.ALIGN_CENTER); cellprix.setHorizontalAlignment(Element.ALIGN_CENTER); cellpvtHT.setHorizontalAlignment(Element.ALIGN_CENTER); cellunite.setBorder(Rectangle.NO_BORDER); cellQuantite.setBorder(Rectangle.NO_BORDER); cellprix.setBorder(Rectangle.NO_BORDER); cellpvtHT.setBorder(Rectangle.NO_BORDER); table.addCell(cellunite); table.addCell(cellQuantite); table.addCell(cellprix); table.addCell(cellpvtHT); ttcTotalParcour += listeMaterielDevi.getPvtHT(); htTotalParcour += listeMaterielDevi.getPvtHT(); } table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); } if (this.Velux.isEmpty() == false) { table.addCell(new Phrase("Velux", fontCategorie)); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); for (DevisContenu listeMaterielDevi : Velux) { table.addCell(listeMaterielDevi.getMateriel().getNom()); PdfPCell cellunite = new PdfPCell(new Phrase(listeMaterielDevi.getMateriel().getUnite())); PdfPCell cellQuantite = new PdfPCell(new Phrase(Double.toString(listeMaterielDevi.getQuantite()))); PdfPCell cellprix = new PdfPCell( new Phrase(Double.toString(listeMaterielDevi.getMateriel().getPrix()) + "")); PdfPCell cellpvtHT = new PdfPCell( new Phrase(Double.toString(listeMaterielDevi.getPvtHT()) + "")); cellunite.setHorizontalAlignment(Element.ALIGN_CENTER); cellQuantite.setHorizontalAlignment(Element.ALIGN_CENTER); cellprix.setHorizontalAlignment(Element.ALIGN_CENTER); cellpvtHT.setHorizontalAlignment(Element.ALIGN_CENTER); cellunite.setBorder(Rectangle.NO_BORDER); cellQuantite.setBorder(Rectangle.NO_BORDER); cellprix.setBorder(Rectangle.NO_BORDER); cellpvtHT.setBorder(Rectangle.NO_BORDER); table.addCell(cellunite); table.addCell(cellQuantite); table.addCell(cellprix); table.addCell(cellpvtHT); ttcTotalParcour += listeMaterielDevi.getPvtHT(); htTotalParcour += listeMaterielDevi.getPvtHT(); } table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); } if (this.Zinguerie.isEmpty() == false) { table.addCell(new Phrase("Zinguerie", fontCategorie)); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); for (DevisContenu listeMaterielDevi : Zinguerie) { table.addCell(listeMaterielDevi.getMateriel().getNom()); PdfPCell cellunite = new PdfPCell(new Phrase(listeMaterielDevi.getMateriel().getUnite())); PdfPCell cellQuantite = new PdfPCell(new Phrase(Double.toString(listeMaterielDevi.getQuantite()))); PdfPCell cellprix = new PdfPCell( new Phrase(Double.toString(listeMaterielDevi.getMateriel().getPrix()) + "")); PdfPCell cellpvtHT = new PdfPCell( new Phrase(Double.toString(listeMaterielDevi.getPvtHT()) + "")); cellunite.setHorizontalAlignment(Element.ALIGN_CENTER); cellQuantite.setHorizontalAlignment(Element.ALIGN_CENTER); cellprix.setHorizontalAlignment(Element.ALIGN_CENTER); cellpvtHT.setHorizontalAlignment(Element.ALIGN_CENTER); cellunite.setBorder(Rectangle.NO_BORDER); cellQuantite.setBorder(Rectangle.NO_BORDER); cellprix.setBorder(Rectangle.NO_BORDER); cellpvtHT.setBorder(Rectangle.NO_BORDER); table.addCell(cellunite); table.addCell(cellQuantite); table.addCell(cellprix); table.addCell(cellpvtHT); ttcTotalParcour += listeMaterielDevi.getPvtHT(); htTotalParcour += listeMaterielDevi.getPvtHT(); } table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); } if (Plancher.isEmpty() == false) { table.addCell(new Phrase("Plancher", fontCategorie)); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); for (DevisContenu listeMaterielDevi : Plancher) { table.addCell(listeMaterielDevi.getMateriel().getNom()); PdfPCell cellunite = new PdfPCell(new Phrase(listeMaterielDevi.getMateriel().getUnite())); PdfPCell cellQuantite = new PdfPCell(new Phrase(Double.toString(listeMaterielDevi.getQuantite()))); PdfPCell cellprix = new PdfPCell( new Phrase(Double.toString(listeMaterielDevi.getMateriel().getPrix()) + "")); PdfPCell cellpvtHT = new PdfPCell( new Phrase(Double.toString(listeMaterielDevi.getPvtHT()) + "")); cellunite.setHorizontalAlignment(Element.ALIGN_CENTER); cellQuantite.setHorizontalAlignment(Element.ALIGN_CENTER); cellprix.setHorizontalAlignment(Element.ALIGN_CENTER); cellpvtHT.setHorizontalAlignment(Element.ALIGN_CENTER); cellunite.setBorder(Rectangle.NO_BORDER); cellQuantite.setBorder(Rectangle.NO_BORDER); cellprix.setBorder(Rectangle.NO_BORDER); cellpvtHT.setBorder(Rectangle.NO_BORDER); table.addCell(cellunite); table.addCell(cellQuantite); table.addCell(cellprix); table.addCell(cellpvtHT); ttcTotalParcour += listeMaterielDevi.getPvtHT(); htTotalParcour += listeMaterielDevi.getPvtHT(); } table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); } ttcTotalParcour = (ttcTotalParcour * devis.getTva() / 100) + ttcTotalParcour; LineDash solid = new SolidLine(); PdfPCell cell, cell2, cellSOUSTOTAL, cellhttotal, tva, getTva, totalttc, gettotalttc; table.addCell(new Phrase(" ")); table.addCell(new Phrase(" ")); table.addCell(new Phrase(" ")); table.addCell(new Phrase(" ")); cell = new PdfPCell(new Phrase("")); cell.setBorder(PdfPCell.NO_BORDER); cell.setCellEvent(new CustomBorder(null, null, null, solid)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); table.addCell(new Phrase("")); table.addCell(new Phrase("")); cellSOUSTOTAL = new PdfPCell(new Phrase("SOUS-TOTAL")); cellSOUSTOTAL.setHorizontalAlignment(Element.ALIGN_MIDDLE); cellSOUSTOTAL.setBorder(Rectangle.NO_BORDER); table.addCell(cellSOUSTOTAL); table.addCell(new Phrase("")); double prixHT_2Chiffre = Math.round((htTotalParcour) * Math.pow(10, 2)) / Math.pow(10, 2); String httotal = String.valueOf(prixHT_2Chiffre); cellhttotal = new PdfPCell(new Phrase(httotal + "")); cellhttotal.setBorder(Rectangle.NO_BORDER); cellhttotal.setHorizontalAlignment(Element.ALIGN_MIDDLE); table.addCell(cellhttotal); table.addCell(new Phrase("")); table.addCell(new Phrase("")); tva = new PdfPCell(new Phrase("TVA")); tva.setBorder(Rectangle.NO_BORDER); tva.setHorizontalAlignment(Element.ALIGN_MIDDLE); table.addCell(tva); getTva = new PdfPCell(new Phrase(devis.getTva() + "%")); getTva.setBorder(Rectangle.NO_BORDER); getTva.setHorizontalAlignment(Element.ALIGN_MIDDLE); table.addCell(getTva); String tvaprix = String.valueOf(htTotalParcour * devis.getTva() / 100); double prixTVA_2Chiffre = Math.round(Double.parseDouble(tvaprix) * Math.pow(10, 2)) / Math.pow(10, 2); cell2 = new PdfPCell(new Phrase(Double.toString(prixTVA_2Chiffre) + "")); cell2.setBorder(PdfPCell.NO_BORDER); cell2.setCellEvent(new CustomBorder(null, null, null, solid)); cell2.setHorizontalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell2); table.addCell(""); table.addCell(""); totalttc = new PdfPCell(new Phrase("Total TTC")); totalttc.setHorizontalAlignment(Element.ALIGN_MIDDLE); totalttc.setBorder(PdfPCell.NO_BORDER); table.addCell(totalttc); table.addCell(""); double prixTTC_2Chiffre = Math.round(ttcTotalParcour * Math.pow(10, 2)) / Math.pow(10, 2); String ttctotal = String.valueOf(Double.toString(prixTTC_2Chiffre)); gettotalttc = new PdfPCell(new Phrase(ttctotal + "")); gettotalttc.setBorder(PdfPCell.NO_BORDER); gettotalttc.setHorizontalAlignment(Element.ALIGN_MIDDLE); table.addCell(gettotalttc); table.setSpacingAfter(10); document.add(table); Pattern p = Pattern.compile("[.^\\.]+"); String texte = devis.getInformationComplementaire(); Font infoComptBlue = new Font(Font.getFamily("TIMES_ROMAN"), 8, Font.NORMAL); infoComptBlue.setColor(BaseColor.BLUE); Font infoComptRed = new Font(Font.getFamily("TIMES_ROMAN"), 8, Font.NORMAL); infoComptRed.setColor(BaseColor.RED); Font infoComptBlack = new Font(Font.getFamily("TIMES_ROMAN"), 8, Font.NORMAL); infoComptBlack.setColor(BaseColor.BLACK); Paragraph infoComp = new Paragraph(); Image BonPourAccord = null; BonPourAccord = Image.getInstance("images/BonPourAccord.png"); infoComp.setAlignment(Element.ALIGN_LEFT); BonPourAccord.setAlignment(Image.TEXTWRAP | Image.ALIGN_RIGHT); String[] phrase = p.split(texte); for (int i = 0; i < phrase.length; i++) { if (i == 0 || i == 1) { infoComp.add(new Paragraph(phrase[i], infoComptBlue)); } if (i == 2 || i == 3 || i == 4 || i == 5) { infoComp.add(new Paragraph(phrase[i], infoComptRed)); } if (i > 5 && i <= 11) infoComp.add(new Paragraph(phrase[i], infoComptBlack)); if (i > 11) infoComp.add(new Paragraph(phrase[i], infoComptRed)); } /* A OPTIMISER */ float taille_tableau = table.calculateHeights() + table.getRowHeight(table.getLastCompletedRowIndex()); if (taille_tableau > 386) { document.newPage(); } document.add(BonPourAccord); document.add(infoComp); document.close(); EnvoieDevis envoie = new EnvoieDevis(null, true, session, devis); this.CouvertureArdoise.clear(); this.CouvertureTuile.clear(); this.Demoussage.clear(); this.EquipementDeChantier.clear(); this.Velux.clear(); this.Zinguerie.clear(); this.Couverture.clear(); this.Plancher.clear(); }
From source file:Integral.PDF.java
/** * Crea un objeto imagen de tipo Chunk// www . j a v a2s. c o m * @param archivo Ruta de la imagen * @param x Posision en x para la imagen dentro del archivo * @param y Posision en y para la imagen dentro del archivo * @param w_escala escala de la imagen en relacion horizontal * @param h_escala escala de la imagen en relacion a vertical * @param grados grados para girar la imagen * @return Retorna una objeto de tipo Chunk */ public Chunk crearImagen(String archivo, int x, int y, int w_escala, int h_escala, float grados) { try { RandomAccessFile rf1 = new RandomAccessFile(ruta + archivo, "r"); int size1 = (int) rf1.length(); byte imagedata[] = new byte[size1]; rf1.readFully(imagedata); rf1.close(); Image img11 = Image.getInstance(imagedata); img11.scaleAbsolute(w_escala, h_escala); img11.setRotationDegrees(grados); Chunk logo = new Chunk(img11, x, y); return logo; } catch (Exception e) { System.out.println(e); return null; } }
From source file:itext_result.Main.java
private int developScreeningSheet() { new SwingWorker<Object, Object>() { String filename;/*from w w w . j av a 2 s .com*/ @Override protected void done() { // ConsoleMsg("Printing PROFILE SHEET IN PROGRESS.. "); } public PdfPCell createBarcode(PdfWriter writer, String code) throws DocumentException, IOException { BarcodeEAN barcode = new BarcodeEAN(); barcode.setCodeType(Barcode.EAN8); barcode.setCode(code); PdfPCell cell = new PdfPCell( barcode.createImageWithBarcode(writer.getDirectContent(), BaseColor.BLACK, BaseColor.GRAY), true); cell.setPadding(10); return cell; } class ImageContent implements PdfPTableEvent { protected com.itextpdf.text.Image content; public ImageContent(com.itextpdf.text.Image content) { this.content = content; } public void tableLayout(PdfPTable table, float[][] widths, float[] heights, int headerRows, int rowStart, PdfContentByte[] canvases) { try { PdfContentByte canvas = canvases[PdfPTable.TEXTCANVAS]; float x = widths[3][1] + 10; float y = heights[3] - 10 - content.getScaledHeight(); content.setAbsolutePosition(x, y); canvas.addImage(content); } catch (DocumentException e) { throw new ExceptionConverter(e); } } } @Override protected Object doInBackground() throws Exception { // System.err.println(" Roll No Received ....." + rollno); Document doc = new Document(); try { PdfWriter writer = PdfWriter.getInstance(doc, new FileOutputStream("12345" + ".pdf")); doc.open(); doc.addTitle("Recruitment PET Sheett - " + "Created By SOS : "); doc.addSubject("Confidential Report Eyes Only"); doc.addKeywords(""); doc.addAuthor("SOS"); doc.addCreator("SOS"); // A4 = 210mm x 297mm ~ 605points x 855points doc.setPageSize(PageSize.A5); doc.setMargins(15f, 15f, 15f, 15f); ///////////////////////////////////////////////////////////// int pageno = 1; for (int i = 0; i == pageno; i++) { // doc.add(imageRight); } PdfContentByte cb = writer.getDirectContent(); //DONE BarcodeEAN codeEAN = new BarcodeEAN(); codeEAN.setCodeType(Barcode.EAN8); Barcode128 code128 = new Barcode128(); code128.setCode(String.valueOf("123456")); Barcode128 code128_jacket = new Barcode128(); code128_jacket.setCode(String.valueOf("10345")); codeEAN.setCode(String.valueOf("123456")); com.itextpdf.text.Image imageEAN = code128.createImageWithBarcode(cb, null, null); // imageEAN.scalePercent(10f); //464f, 725f // imageEAN.setAbsolutePosition(474f, 662f); int i = 1; while (i <= pageno) { doc.newPage(); // cb.addImage(imageRight); // cb.addImage(imageEAN); i++; } com.itextpdf.text.Image carcode = code128_jacket.createImageWithBarcode(cb, null, null); carcode.scaleAbsolute(100f, 35f); carcode.setAbsolutePosition(500f, 600f); writer.addDirectImageSimple(carcode); // cb.addImage(carcode); com.itextpdf.text.Image carcode2 = code128.createImageWithBarcode(cb, null, null); carcode2.scaleAbsolute(100f, 35f); carcode2.setAbsolutePosition(450f, 760f); writer.addDirectImageSimple(carcode2); // cb.addImage(carcode2); Image image1 = Image.getInstance("jklogo.gif"); PdfPTable table = new PdfPTable(1); table.setWidthPercentage(99); table.addCell(image1); doc.add(table); table = new PdfPTable(4); table.setWidthPercentage(99); float[] columnWidths = { 6, 2 }; PdfPTable CandidateTable = new PdfPTable(columnWidths); Font f = new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL, GrayColor.BLACK); Font fsmall = new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL, GrayColor.BLACK); PdfPCell rollno = new PdfPCell(new Phrase("Roll No# " + String.valueOf("123456"), fsmall)); PdfPCell cname = new PdfPCell(new Phrase("Name #" + String.valueOf("John Doe"), fsmall)); // DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy"); // String today = formatter.format(cInfo.getDob()); PdfPCell dob = new PdfPCell(new Phrase("DOB#" + String.valueOf("12-03-1989"), fsmall)); PdfPCell fname = new PdfPCell(new Phrase("F/H Name #" + String.valueOf("Big John"), fsmall)); PdfPCell type = new PdfPCell(new Phrase("Total Time #" + String.valueOf("350.00"), fsmall)); // String scrtoday = formatter.format(cInfo.getScreeningdate()); // System.out.println("Today : " + today); PdfPCell scrdate = new PdfPCell(new Phrase("Laps #" + String.valueOf("4"), fsmall)); PdfPCell cell = new PdfPCell(new Phrase(" ", fsmall)); rollno.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); cname.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); rollno.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); dob.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); fname.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); type.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); scrdate.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); cell.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); CandidateTable.addCell(rollno); CandidateTable.addCell(cell); CandidateTable.addCell(cname); CandidateTable.addCell(cell); CandidateTable.addCell(dob); CandidateTable.addCell(cell); PdfPTable CandidateOtherTable = new PdfPTable(columnWidths); CandidateOtherTable.addCell(fname); CandidateOtherTable.addCell(cell); CandidateOtherTable.addCell(scrdate); CandidateOtherTable.addCell(cell); CandidateOtherTable.addCell(type); CandidateOtherTable.addCell(cell); PdfPCell race_start_time = new PdfPCell(new Phrase("Start Time :XX-XX-XX ", fsmall)); PdfPCell race_end_time = new PdfPCell(new Phrase("End Time :XX-XX-XX", fsmall)); PdfPCell race_total_time = new PdfPCell(new Phrase("Total Time : 350.00 ", fsmall)); race_start_time.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); race_end_time.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); race_total_time.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); PdfPTable CandidateRaceDetails = new PdfPTable(columnWidths); CandidateRaceDetails.addCell(race_start_time); CandidateRaceDetails.addCell(cell); CandidateRaceDetails.addCell(race_end_time); CandidateRaceDetails.addCell(cell); CandidateRaceDetails.addCell(race_total_time); CandidateRaceDetails.addCell(cell); PdfPTable tablewith3cells = new PdfPTable(3); //1 St Col for Roll No Name and DOB tablewith3cells.addCell(CandidateTable); //2 nd Col for Father Name sCREEning Date Gurkha tablewith3cells.addCell(CandidateOtherTable); //3rd Col for Barcode to be Printed tablewith3cells.addCell(CandidateRaceDetails); // Setting the Width here to 101 tablewith3cells.setWidthPercentage(99); doc.add(tablewith3cells); PdfPTable userArea = new PdfPTable(1); userArea.setWidthPercentage(99); userArea.addCell(" \n \n Congratulations \n \n "); doc.add(userArea); PdfPTable footerCSBC = new PdfPTable(2); footerCSBC.setWidthPercentage(99); PdfPCell height_box = new PdfPCell(new Phrase("Height \n\n\n", f)); height_box.setBorder(com.itextpdf.text.Rectangle.BOX); PdfPCell chest_box = new PdfPCell(new Phrase("Chest \n\n\n", f)); chest_box.setBorder(com.itextpdf.text.Rectangle.BOX); PdfPCell chest_exp_box = new PdfPCell(new Phrase("Chest Exp \n\n\n", f)); chest_exp_box.setBorder(com.itextpdf.text.Rectangle.BOX); PdfPCell pushup_box = new PdfPCell(new Phrase("Pushup \n\n\n", f)); pushup_box.setBorder(com.itextpdf.text.Rectangle.BOX); //CSignatureBox.setBorder(com.itextpdf.text.Rectangle.BOX); // ASignatureBox.setBorder(com.itextpdf.text.Rectangle.BOX); footerCSBC.addCell(height_box); footerCSBC.addCell(chest_box); footerCSBC.addCell(chest_exp_box); footerCSBC.addCell(pushup_box); doc.add(footerCSBC); float[] columnWidths_ForBarcode = { 6, 3 }; PdfPTable terminalinfo = new PdfPTable(columnWidths_ForBarcode); // terminalinfo.setWidthPercentage(99); String computername = InetAddress.getLocalHost().getHostName(); System.out.println(computername); PdfPCell pcname = new PdfPCell(new Phrase("\t Jacket \n\n ", f)); String UserMatchScore = "\t Barcode\n\n"; PdfPCell score = new PdfPCell(new Phrase(UserMatchScore, f)); PdfPCell barcode = new PdfPCell(carcode2); PdfPCell jacketnumber = new PdfPCell(carcode); pcname.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); score.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); barcode.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); jacketnumber.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); terminalinfo.addCell(score); terminalinfo.addCell(pcname); terminalinfo.addCell(barcode); terminalinfo.addCell(jacketnumber); doc.add(terminalinfo); PdfPCell eula_notice = new PdfPCell(new Phrase(" ", f)); eula_notice.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); cell.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPTable eula_notice_table = new PdfPTable(1); eula_notice_table.setWidthPercentage(25); eula_notice_table.addCell(eula_notice); doc.add(eula_notice_table); } catch (Exception e) { System.err.println(e.getMessage()); // ConsoleMsg(e.getMessage()); } finally { doc.close(); doc.close(); doc.close(); } //ConsoleMsg("PDF... GENERATED"); return null; // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }.execute(); return 0; }
From source file:jdbreport.model.io.pdf.itext5.PdfWriter.java
License:Apache License
private com.itextpdf.text.Image awtImageToImage(java.awt.Image awtImage, jdbreport.model.Cell srcCell, float w, float h) throws BadElementException, IOException { com.itextpdf.text.Image image = com.itextpdf.text.Image.getInstance(awtImage, null); boolean scaled = srcCell.isScaleIcon(); double kx = 1.0 / GraphicUtil.getScreenScaleX(); double ky = 1.0 / GraphicUtil.getScreenScaleY(); float imageWidth = (float) (image.getWidth() * kx); float imageHeight = (float) (image.getHeight() * ky); if (!scaled) { if (imageWidth < w) { w = imageWidth;/* w ww. j ava2 s .c om*/ } if (imageHeight < h) { h = imageHeight; } } if (imageWidth >= w || imageHeight >= h) { scaled = true; } if (scaled) { image.scaleAbsolute(w - 2, h - 2); } return image; }
From source file:managedbeans.descargas.PDFConversionDemo.java
public static void main(String[] args) { try {/*from w w w .ja v a2s. c o m*/ //Read file using PdfReader PdfReader pdfReader = new PdfReader("HelloWorld.pdf"); //Modify file using PdfReader PdfStamper pdfStamper = new PdfStamper(pdfReader, new FileOutputStream("HelloWorld-modified.pdf")); Image image = Image.getInstance("temp.png"); image.scaleAbsolute(100, 50); image.setAbsolutePosition(100f, 700f); for (int i = 1; i <= pdfReader.getNumberOfPages(); i++) { PdfContentByte content = pdfStamper.getUnderContent(i); content.addImage(image); } pdfStamper.close(); } catch (IOException | DocumentException e) { logger.warn("failed to ...." + e); } }
From source file:mobac.program.atlascreators.PaperAtlasPdf.java
License:Open Source License
@Override protected void processPage(BufferedImage image, int pageNumber) throws MapCreationException { int imageWidth = image.getWidth(); int imageHeight = image.getHeight(); if (document == null) { double width = UnitSystem.pixelsToPoints(imageWidth, s.dpi); double height = UnitSystem.pixelsToPoints(imageHeight, s.dpi); width += s.marginLeft + s.marginRight; height += s.marginTop + s.marginBottom; Rectangle r = new Rectangle((float) width, (float) height); document = createDocument(r);//from w w w.ja va 2 s .co m } Image iTextImage; try { iTextImage = Image.getInstance(image, Color.WHITE); } catch (BadElementException e) { throw new MapCreationException(map, e); } catch (IOException e) { throw new MapCreationException(map, e); } iTextImage.setCompressionLevel(s.compression); iTextImage.setDpi(s.dpi, s.dpi); float width = (float) UnitSystem.pixelsToPoints(imageWidth, s.dpi); float height = (float) UnitSystem.pixelsToPoints(imageHeight, s.dpi); iTextImage.scaleAbsolute(width, height); try { document.add(iTextImage); } catch (DocumentException e) { throw new MapCreationException(map, e); } document.newPage(); }
From source file:mvjce.PDF.java
public static void create(int sino) {// sino = SI.No // TODO code application logic here try {/* ww w. j a va 2 s .c om*/ //Create Document instance. Document document = new Document(); //Create OutputStream instance. OutputStream outputStream = new FileOutputStream( new File("/home/narein/NetBeansProjects/" + sem + cl + "/" + usn + ".pdf")); //Create PDFWriter instance. PdfWriter.getInstance(document, outputStream); //Open the document. document.open(); //image position Image imageCenter = Image.getInstance("/home/narein/Downloads/mvj.png"); //imageCenter.setAlignment(Image.MIDDLE); imageCenter.setAbsolutePosition(235, 780); imageCenter.scaleAbsolute(146f, 53f); //Permanently affiliated para PdfPTable table = new PdfPTable(2); table.setWidthPercentage(100); table.addCell(getCell( "\n\n\nPermanently affiliated to VTU, Govt. of Karnataka\nApproved by AICTE, New Delhi\nNear ITPB, Bengaluru- 560067\n\n" + hod_name + ", HOD - " + dep, PdfPCell.ALIGN_LEFT)); table.addCell(getCell("\n\n\n\nPh: 080-42991000\nFax: 080-28452443\nWebsite: www.mvjce.edu.in\nEmail: " + hod_email + "\n\n", PdfPCell.ALIGN_RIGHT)); //line across pdf final LineSeparator lineSeparator = new LineSeparator(); Chunk linebreak = new Chunk(lineSeparator); Phrase p = new Phrase("\nPROGRESS REPORT\n", new Font(FontFamily.TIMES_ROMAN, 10, Font.UNDERLINE | Font.BOLD)); Paragraph para = new Paragraph(p); para.setAlignment(Element.ALIGN_CENTER); Chunk glue = new Chunk(new VerticalPositionMark()); Paragraph p1 = new Paragraph("\nRef:", new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD)); p1.add(new Chunk(glue)); //get current date DateTimeFormatter dtf = DateTimeFormatter.ofPattern("dd.MM.yyyy"); LocalDate localDate = LocalDate.now(); //add date to pdf p1.add(new Phrase("Date: " + dtf.format(localDate) + "\n", new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD))); Phrase dear_prnts = new Phrase("Dear Parents,\n", new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD)); Phrase The_acad = new Phrase( " The academic performance of your ward Mr/Ms " + name + " of Semester " + sem + " bearing the USN " + usn + " is as follows,\n\n", new Font(FontFamily.TIMES_ROMAN, 9)); Phrase Rem = new Phrase("Remarks\n", new Font(FontFamily.TIMES_ROMAN, 10, Font.UNDERLINE | Font.BOLD)); Phrase your_ward = new Phrase( "\nYour ward's overall performance is Good / Satisfactory / Poor / Very Poor\n", new Font(FontFamily.TIMES_ROMAN, 9)); Phrase you_are = new Phrase("\nYou are requested to:\n", new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD)); Phrase req = new Phrase(""); Paragraph para2 = new Paragraph( "1) Advice your ward to attend classes regularly\n2) Note that he/she may likely be detainedfrom appearing for examinations\n" + "3) Advice your ward to improve in Test/Exam performance particularly in subject\n4) Meet the Head of the Department\n5) Meet the principal\n", new Font(FontFamily.TIMES_ROMAN, 9)); Chunk glue1 = new Chunk(new VerticalPositionMark()); Paragraph p3 = new Paragraph("\nSIGNATURE:\n\nNAME OF PROCTOR:\n\nCONTACT NUMBER:", new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD)); p3.add(new Chunk(glue1)); p3.add(new Phrase( "SIGNATURE OF HOD\n\n Kindly attend the Parent Teacher Meeting to be held on the date informed to your ward.\n", new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD))); Phrase Note = new Phrase("\nNOTE:", new Font(FontFamily.TIMES_ROMAN, 10, Font.UNDERLINE | Font.BOLD)); Paragraph p4 = new Paragraph(); p4.add(Note); p4.add(new Phrase( " Parents are requested to contact the proctor (By Email/Letter/Phone) and confirm receipt of this feedback. Parents are also" + "welcome to interact with proctors/subject faculty/ HOD for any discussion/clarification.\n", new Font(FontFamily.TIMES_ROMAN, 9))); //Add content to the document. document.add(imageCenter); document.add(table); document.add(linebreak); document.add(para); document.add(p1); document.add(dear_prnts); document.add(The_acad); document.add(createinternalsTable()); if (internal.equals("1")) { document.add(new Phrase("\nPREVIOUS SEMESTER VTU RESULT\n\n", new Font(FontFamily.TIMES_ROMAN, 10, Font.UNDERLINE | Font.BOLD))); document.add(createexternalTable()); } document.add(Rem); document.add(your_ward); document.add(you_are); document.add(para2); document.add(p3); document.add(p4); //document.add(paragraph);document.add(paragraph1); //Close document and outputStream. document.close(); outputStream.close(); System.out.println("Pdf created successfully."); } catch (Exception e) { e.printStackTrace(); } }
From source file:org.fao.geonet.api.records.formatters.ImageReplacedElementFactory.java
License:Open Source License
private ReplacedElement loadImage(LayoutContext layoutContext, BlockBox box, UserAgentCallback userAgentCallback, int cssWidth, int cssHeight, String url, float scaleFactor) { InputStream input = null;/*from ww w . j ava2s .co m*/ try { Log.error(Geonet.GEONETWORK, "URL -> " + url.toString()); input = new URL(url).openStream(); byte[] bytes = IOUtils.toByteArray(input); Image image = Image.getInstance(bytes); image.scaleAbsolute(image.getPlainWidth() * scaleFactor, image.getPlainHeight() * scaleFactor); FSImage fsImage = new ITextFSImage(image); if (cssHeight > -1 && cssWidth > -1) { fsImage.scale(cssWidth, cssHeight); } int maxWidth = (int) (900 * scaleFactor); if (fsImage.getWidth() > maxWidth) { int ratio = fsImage.getWidth() / maxWidth; fsImage.scale(maxWidth, fsImage.getHeight() / ratio); } return new ITextImageElement(fsImage); } catch (Exception e) { Log.error(Geonet.GEONETWORK, "Error writing metadata to PDF", e); try { return superFactory.createReplacedElement(layoutContext, box, userAgentCallback, cssWidth, cssHeight); } catch (Throwable e2) { return new EmptyReplacedElement(cssWidth, cssHeight); } } finally { if (input != null) { IOUtils.closeQuietly(input); } } }
From source file:org.fhaes.jsea.JSEAStatsFunctions.java
License:Open Source License
public void savePDFReport(String filename) { Document document = new Document(); try {// w w w .j av a 2s . co m // if you want to save a pdf file using bigbuffer do it here PdfWriter.getInstance(document, new FileOutputStream(filename)); document.open(); document.add(new Paragraph(para1.get(0))); printTableAct.get(0).setWidthPercentage(90); printTableAct.get(0).setSpacingBefore(20f); printTableAct.get(0).setSpacingAfter(20f); document.add(printTableAct.get(0)); // document.newPage(); document.add(new Paragraph(para2.get(0))); printTableSim.get(0).setWidthPercentage(90); printTableSim.get(0).setSpacingBefore(20f); printTableSim.get(0).setSpacingAfter(20f); document.add(printTableSim.get(0)); // the charts are being saved from an array list to the files for (int i = 0; i < chartList.size(); i++) { try { File f2 = File.createTempFile("chart" + i, ".png"); ChartUtilities.saveChartAsPNG(f2, chartList.get(i).getChart(), 800, 500); Image image = Image.getInstance(f2.getAbsolutePath()); float fWidth = 0.6f * 800; float fHeight = 0.6f * 500; image.scaleAbsolute(fWidth, fHeight); document.add(image); f2.delete(); } catch (IOException ex) { System.err.println(ex.getLocalizedMessage()); } } } catch (Exception e) { } document.close(); }
From source file:PDF.CrearPDF_Ficha.java
public void generarPDF(ServletOutputStream sops, DatosPDF datos, String url) { try {//from w w w .j a va2 s. c o m Document documento = new Document(); // ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter writer = PdfWriter.getInstance(documento, sops); documento.open(); Image itt_logo; try { itt_logo = Image.getInstance(url); Image Logo_itt = Image.getInstance(itt_logo); Logo_itt.setAbsolutePosition(50f, 698f); Logo_itt.scaleAbsolute(90, 100); documento.add(Logo_itt); } catch (BadElementException | IOException ex) { Logger.getLogger(CrearPDF_Ficha.class.getName()).log(Level.SEVERE, null, ex); } PdfContentByte rectangulo_info = writer.getDirectContentUnder(); drawRectangle(rectangulo_info, 430, 648, 90, 100); Paragraph leyendaFoto = new Paragraph("\nFOTO:\n", FontFactory.getFont("arial", 14, Font.BOLD)); leyendaFoto.setIndentationLeft(200f); Paragraph titulo = new Paragraph("INSTITUTO TECNOLGICO DE TOLUCA", FontFactory.getFont("arial", 14)); titulo.setAlignment(Element.ALIGN_CENTER); Paragraph asunto = new Paragraph("FICHA DE EXAMEN", FontFactory.getFont("arial", 12)); asunto.setAlignment(Element.ALIGN_CENTER); Chunk folio1 = new Chunk("FICHA PARA EL EXAMEN DE ADMISIN: ", FontFactory.getFont("arial", 10)); Chunk folio2 = new Chunk(datos.getFicha(), FontFactory.getFont("arial", 10, Font.BOLD)); Phrase fol = new Phrase(); fol.add(folio1); fol.add(folio2); Paragraph noFicha = new Paragraph(fol); noFicha.setAlignment(Element.ALIGN_LEFT); Chunk nombre1 = new Chunk("NOMBRE DEL SOLICITANTE: ", FontFactory.getFont("arial", 10)); Chunk nombre2 = new Chunk(datos.getNombre(), FontFactory.getFont("arial", 10, Font.BOLD)); Phrase nom = new Phrase(); nom.add(nombre1); nom.add(nombre2); Paragraph nombre = new Paragraph(nom); nombre.setAlignment(Element.ALIGN_LEFT); Chunk in1 = new Chunk("PROCESO PARA EL REGISTRO DE ASPIRANTES EN EL PERIODO: ", FontFactory.getFont("arial", 10)); Chunk in2 = new Chunk(datos.getPeriodoConcursa().toUpperCase(), FontFactory.getFont("arial", 10, Font.BOLD)); Phrase in = new Phrase(); in.add(in1); in.add(in2); Paragraph instrucciones = new Paragraph(in); instrucciones.setAlignment(Element.ALIGN_LEFT); Chunk folCen1 = new Chunk("1.- NMERO DE FOLIO CENEVAL: ", FontFactory.getFont("arial", 10)); Chunk folCen2 = new Chunk(datos.getFolioCENEVAL(), FontFactory.getFont("arial", 10, Font.BOLD)); Phrase folC = new Phrase(); folC.add(folCen1); folC.add(folCen2); Paragraph folioCENEVAL = new Paragraph(folC); folioCENEVAL.setAlignment(Element.ALIGN_LEFT); Chunk fechas1 = new Chunk("2.- LOS EX?MENES DE ADMISIN SE APLICAR?N LOS D?AS: ", FontFactory.getFont("arial", 10)); Chunk fechas2 = new Chunk(datos.getFechaExamenCeneval() + " (" + datos.getLugarExamenCeneval() + ")", FontFactory.getFont("arial", 10, Font.BOLD)); Chunk fechas3 = new Chunk(" Y ", FontFactory.getFont("arial", 10)); Chunk fechas4 = new Chunk(datos.getFechaExamenMate() + " (" + datos.getLugarExamenMate() + ")", FontFactory.getFont("arial", 10, Font.BOLD)); Phrase fechas = new Phrase(); fechas.add(fechas1); fechas.add(fechas2); fechas.add(fechas3); fechas.add(fechas4); Paragraph fechaExamenes = new Paragraph(fechas); fechaExamenes.setAlignment(Element.ALIGN_LEFT); Phrase lugar = new Phrase(); Paragraph lugarYhora = new Paragraph(lugar); lugarYhora.setAlignment(Element.ALIGN_LEFT); Chunk paginaPub1 = new Chunk( "3.- LA PUBLICACIN DE LOS RESULTADOS SER? NICAMENTE EN LA P?GINA WEB: ", FontFactory.getFont("arial", 10)); Anchor url_itt = new Anchor(datos.getPagResultados()); url_itt.setReference(datos.getPagResultados()); Phrase pag = new Phrase(); pag.add(paginaPub1); pag.add(url_itt); Paragraph pagWeb = new Paragraph(pag); Chunk diaPub1 = new Chunk("EL D?A: ", FontFactory.getFont("arial", 10)); Chunk diaPub2 = new Chunk(convertir(datos.getDiaPublicacion() + "-"), FontFactory.getFont("arial", 10, Font.BOLD)); Phrase dia = new Phrase(); dia.add(diaPub1); dia.add(diaPub2); Paragraph diaResultados = new Paragraph(dia); diaResultados.setAlignment(Element.ALIGN_LEFT); Chunk notas = new Chunk("\nNOTAS:\n", FontFactory.getFont("arial", 14, Font.BOLD)); Chunk uno = new Chunk("1.- ", FontFactory.getFont("arial", 10, Font.BOLD)); Chunk guias = new Chunk("Guas de estudio:\n - (CENEVAL) \n", FontFactory.getFont("arial", 10)); Anchor url_guia_cen = new Anchor(" " + datos.getEstudioCeneval()); // url_guia_cen.setReference(datos.getEstudioCeneval()); Chunk ceneval_inter = new Chunk("\n - (CENEVAL INTERACTIVA) \n", FontFactory.getFont("arial", 10)); Anchor url_guia_cen_inter = new Anchor(" " + datos.getEstudioCenevalInt()); url_guia_cen_inter.setReference(datos.getEstudioCenevalInt()); Chunk tem_mate_itt = new Chunk("\n - Temario de Matemticas (TECNOLGICO DE TOLUCA)\n\n", FontFactory.getFont("arial", 10)); Chunk dos = new Chunk("2.- ", FontFactory.getFont("arial", 10, Font.BOLD)); Chunk veri = new Chunk("Verifique que el nmero de folio de Ceneval de esta ficha, coincida con el", FontFactory.getFont("arial", 10)); Chunk fol_ceneval = new Chunk(" FOLIO CENEVAL ", FontFactory.getFont("arial", 10, Font.BOLD)); Chunk capturado = new Chunk("capturado en la informacin proporcionada por el Tecnlogico.\n\n", FontFactory.getFont("arial", 10)); Chunk tres = new Chunk("3.- ", FontFactory.getFont("arial", 10, Font.BOLD)); Chunk dia_exam = new Chunk( "El da del examen deber presentarse con el presente documento, pase de ingreso al examen(Ceneval), una identificacin con fotografa reciente(credencial escolar, IMSS, ISSSTE, ISSEMYM, licencia, pasaporte), lpiz del nmero 2 y goma.\n\n", FontFactory.getFont("arial", 10)); Chunk cuatro = new Chunk("4.- ", FontFactory.getFont("arial", 10, Font.BOLD)); Chunk curso = new Chunk( "Si curs sus estudios de secundaria o bachillerato en el extranjero deber presentar revalidacin de estudios correspondientes al momento de la inscripcin.\n", FontFactory.getFont("arial", 10)); Chunk cinco = new Chunk("\n5.- ", FontFactory.getFont("arial", 10, Font.BOLD)); Chunk examenes = new Chunk( "Los exmenes que se evaluarn son: 1) ADMISIN Y DIAGNSTICO. 2) MATEM?TICAS.", FontFactory.getFont("arial", 10)); Phrase ulti = new Phrase(); ulti.add(notas); ulti.add(uno); ulti.add(guias); ulti.add(url_guia_cen); ulti.add(ceneval_inter); ulti.add(url_guia_cen_inter); ulti.add(tem_mate_itt); ulti.add(dos); ulti.add(veri); ulti.add(fol_ceneval); ulti.add(capturado); ulti.add(tres); ulti.add(dia_exam); ulti.add(cuatro); ulti.add(curso); ulti.add(cinco); ulti.add(examenes); Paragraph ultimo = new Paragraph(ulti); ultimo.setAlignment(Element.ALIGN_LEFT); documento.addTitle("Ficha de Examen"); documento.addSubject("Instituto Tecnolgico de Toluca"); documento.addKeywords("Instituto Tecnolgico de Toluca"); documento.addAuthor("Departamento de Servicios escolares"); documento.addCreator("Departamento de Servicios escolares"); documento.add(titulo); documento.add(asunto); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(noFicha); documento.add(nombre); documento.add(new Paragraph(" ")); documento.add(instrucciones); documento.add(new Paragraph(" ")); documento.add(folioCENEVAL); documento.add(fechaExamenes); documento.add(lugarYhora); documento.add(pagWeb); documento.add(diaResultados); documento.add(new Paragraph(" ")); documento.add(ultimo); documento.close(); } catch (DocumentException ex) { Logger.getLogger(CrearPDF_Ficha.class.getName()).log(Level.SEVERE, null, ex); } }