List of usage examples for com.itextpdf.text Document addCreator
public boolean addCreator(String creator)
From source file:gestionEtat.imprimerBulletin.BulletinCtrl.java
@Override public void enregistrerBulletin() { if (FacesContext.getCurrentInstance().getExternalContext().getSessionMap().containsKey("user")) { if (eleveAnneeClasse.getId() != null) { classematieres.clear();// ww w. j av a 2 s . c o m matieres.clear(); notesPropres.clear(); matiereCompses.clear(); eleveAnneeClasse = eleveAnneeClasseFacade.find(eleveAnneeClasse.getId()); if (sequence != null) { Annee an = anneeFacade.findByEtatSingle(true); Eleveanneeclasse eleveClasse = eleveAnneeClasseFacade.getEleveAnneeClaseByAnneClasse( eleveAnneeClasse.getEleve().getIdeleve(), an.getIdannee()); if (eleveClasse != null) { List<Naturematiere> nature = natureMatiereFacade.findAll(); if (!nature.isEmpty()) { List<Evaluation> notes = evaluationFacadeLocal.getByEleveAnneeSequence( eleveAnneeClasse.getEleve().getIdeleve(), an.getIdannee(), sequence.getIdsequencean()); /*if (!notes.isEmpty()) {*/ try { String bulletinName = "" + eleveAnneeClasse.getEleve().getNom() + "_" + eleveAnneeClasse.getEleve().getPrenom() + "_" + sequence.getIdsequence().getNom() + ".pdf"; Document bulletin = new Document(); PdfWriter.getInstance(bulletin, new FileOutputStream(Utilitaires.path + "/" + Utilitaires.repertoireParDefautBulletin + "/" + bulletinName)); bulletin.setMargins(5, 5, 5, 5); bulletin.addCreator("School Manager"); bulletin.setPageSize(PageSize.A4); bulletin.open(); //tableau qui va contenir les notes PdfPTable table = new PdfPTable(5); table.setComplete(true); //entete de bulletin table.addCell( PrintUtils.createPdfPCell("COLLEGE POZAM Anne Scolaire " + an.getCode() + " - " + (an.getCode() + 1) + " " + an.getTheme(), 5, detail)); table.addCell(PrintUtils.createPdfPCell( "BULLETIN DE NOTES DE : " + sequence.getIdsequence().getNom(), 5, true)); table.addCell(PrintUtils .createPdfPCell("Nom : " + eleveAnneeClasse.getEleve().getNom(), 2, false)); PdfPCell cellLogo = new PdfPCell(new Paragraph(" ")); cellLogo.setRowspan(2); table.addCell(cellLogo); table.addCell(PrintUtils.createPdfPCell( "Matricule : " + eleveAnneeClasse.getEleve().getMatricule(), 2, false)); table.addCell(PrintUtils.createPdfPCell( "Prnom : " + eleveAnneeClasse.getEleve().getPrenom(), 2, false)); //table.addCell("kenne"); PdfPCell cellClasse = new PdfPCell( new Paragraph("Classe : " + eleveClasse.getIdclasse().getNom())); cellClasse.setColspan(2); table.addCell(cellClasse); //debut de saisis de notes PdfPTable entete = new PdfPTable(5); table.addCell(new Paragraph("Dicipline")); table.addCell(PrintUtils.createPdfPCell("Note ", true)); table.addCell(PrintUtils.createPdfPCell("Cofficient ", true)); table.addCell(PrintUtils.createPdfPCell("Total", true)); table.addCell(PrintUtils.createPdfPCell("Apprciation", true)); //partie qui contient es totaux PdfPTable total = new PdfPTable(5); int totalCoef = 0; float totalPoint = 0; classematieres = classeMatiereFacade .get(eleveAnneeClasse.getIdclasse().getIdclasse()); if (!classematieres.isEmpty()) { for (Classematiere m : classematieres) { matieres.add(m.getIdmatiere()); } /*for (Evaluation e : notes) { if (matieres.contains(e.getIdmatiere())) { notesPropres.add(e); matiereCompses.add(e.getIdmatiere()); } }*/ for (int i = 0; i < nature.size(); i++) { table.addCell( PrintUtils.createPdfPCell("Matires " + nature.get(i).getLibelle(), 5, false, PrintUtils.blueFont)); int totalCoefBloc = 0; int totalPointBloc = 0; for (int a = 0; a < matieres.size(); a++) { if (matiereCompses.contains(matieres.get(a))) { //if (Objects.equals(notesPropres.get(a).getIdmatiere(), nature.get(i).getIdnaturematiere())) {; //decompte des coefficient et nombre point globaux //totalCoef += notesPropres.get(a).getIdmatiere().getCoeficient(); // totalPoint += notesPropres.get(a).getNote() * notesPropres.get(a).getIdmatiere().getCoeficient(); //decompte des coef et point par groupe //totalCoefBloc += notesPropres.get(a).getIdmatiere().getCoeficient(); //totalPointBloc += notesPropres.get(a).getNote() * notesPropres.get(a).getIdmatiere().getCoeficient(); // table.addCell(PrintUtils.createPdfPCell("" + notesPropres.get(a).getIdmatiere().getIdtypematiere().getLibelle(), false, new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL))); //table.addCell(PrintUtils.createPdfPCell("" + notesPropres.get(a).getNote(), true, new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL))); //table.addCell(PrintUtils.createPdfPCell("" + notesPropres.get(a).getIdmatiere().getCoeficient(), true, new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL))); //table.addCell(PrintUtils.createPdfPCell("" + (notesPropres.get(a).getNote() * notesPropres.get(a).getIdmatiere().getCoeficient()), true, new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL))); //table.addCell(PrintUtils.createPdfPCell("" + notesPropres.get(a).getObservation(), true, new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.ITALIC))); // } } else { if (Objects.equals( matieres.get(a).getIdnaturematiere().getIdnaturematiere(), nature.get(i).getIdnaturematiere())) { //decompte des coefficient et nombre point globaux // totalCoef += matieres.get(a).get totalPoint += 0; //decompte des coef et point par groupe // totalCoefBloc += matieres.get(a).getCoeficient(); totalPointBloc += 0; // table.addCell(PrintUtils.createPdfPCell("" + matieres.get(a).getIdtypematiere().getLibelle(), false, new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL))); table.addCell(PrintUtils.createPdfPCell("O", true, new Font( Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL))); // table.addCell(PrintUtils.createPdfPCell("" + matieres.get(a).getCoeficient(), true, new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL))); table.addCell(PrintUtils.createPdfPCell("0", true, new Font( Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL))); table.addCell(PrintUtils.createPdfPCell("Pas encore valu", true, new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.ITALIC))); } } } //le texte Total pour chaque bloc PdfPCell cellTotalBlocText = new PdfPCell( new Paragraph("Total Matires " + nature.get(i).getLibelle() + " ", new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.NORMAL))); cellTotalBlocText.setColspan(2); table.addCell(cellTotalBlocText); table.addCell(PrintUtils.createPdfPCell("" + totalCoefBloc, true, new Font( Font.FontFamily.TIMES_ROMAN, 11, Font.NORMAL, BaseColor.RED))); table.addCell(PrintUtils.createPdfPCell("" + totalPointBloc, 2, true, new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.NORMAL, BaseColor.RED))); table.addCell(PrintUtils.createPdfPCell( "Moyenne Matires " + nature.get(i).getLibelle(), 3, false, PrintUtils.blueFont)); if (totalCoefBloc != 0) { table.addCell(PrintUtils.createPdfPCell( "" + (totalPointBloc / totalCoefBloc) + "/20", 2, true, PrintUtils.redFont)); } else { table.addCell(PrintUtils.createPdfPCell("......", 2, true, PrintUtils.redFont)); } table.addCell(PrintUtils.createPdfPCell(" ", 5, false)); } } else { } //on ecrit totaux table.addCell(PrintUtils.createPdfPCell("Totaux ", 2, false, new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.NORMAL, BaseColor.BLUE))); //on met le total de coefficient table.addCell(PrintUtils.createPdfPCell("" + totalCoef, true, new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.NORMAL, BaseColor.RED))); //on met le total de point table.addCell(PrintUtils.createPdfPCell("" + totalPoint, 2, true, new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.NORMAL, BaseColor.RED))); table.addCell(PrintUtils.createPdfPCell( "Moyenne de la " + sequence.getIdsequence().getNom(), 3, false, new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLUE))); if (totalCoef != 0) { table.addCell(PrintUtils.createPdfPCell((totalPoint / totalCoef) + "/20", 2, true, new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.RED))); } bulletin.add(table); bulletin.close(); JsfUtil.addSuccessMessage( "Opration russie,redirigez-vous dans le repertoire bulletin"); } catch (DocumentException ex) { Logger.getLogger(BulletinCtrl.class.getName()).log(Level.SEVERE, null, ex); } catch (FileNotFoundException ex) { Logger.getLogger(BulletinCtrl.class.getName()).log(Level.SEVERE, null, ex); } /*} else { JsfUtil.addErrorMessage("L'lve selectionn n a aucune note la squence slectionne"); }*/ } else { JsfUtil.addErrorMessage("Aucune nature de matiere parametre"); } } else { JsfUtil.addErrorMessage("l'eleve n a pas de classe"); } } else { JsfUtil.addErrorMessage("veuillez selectionner une squence !"); } } else { JsfUtil.addErrorMessage("Veuillez selectionner un lve"); } } else { String sc = FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath(); try { FacesContext.getCurrentInstance().getExternalContext().redirect(sc + "/login.html"); } catch (IOException ex) { Logger.getLogger(BulletinCtrl.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:groove.io.external.util.GraphToPDF.java
License:Apache License
@Override public void renderGraph(JGraph<?> graph, File file) throws PortException { // Get graph bounds. If not available, do nothing (probably empty graph) Rectangle2D bounds = graph.getGraphBounds(); if (bounds == null) { return;/*from w w w.j av a2s . c om*/ } Rectangle bound = new Rectangle((float) bounds.getWidth(), (float) bounds.getHeight()); try (FileOutputStream fos = new FileOutputStream(file)) { Document document = new Document(bound); // Open file, create PDF document PdfWriter writer = PdfWriter.getInstance(document, fos); // Set some metadata document.addCreator(Version.getAbout()); // Open document, get graphics document.open(); PdfContentByte cb = writer.getDirectContent(); boolean onlyShapes = true; //The embedded fonts most likely do not contain all necessary glyphs, so using outlines instead // onlyShapes makes PDF considerably bigger, but no alternative at the moment PdfGraphics2D pdf2d = new PdfGraphics2D(cb, (float) bounds.getWidth(), (float) bounds.getHeight(), new DefaultFontMapper(), onlyShapes, false, (float) 100.0); // Render toGraphics(graph, pdf2d); // Cleanup pdf2d.dispose(); document.close(); } catch (DocumentException | IOException e) { throw new PortException(e); } }
From source file:GUI.Carburant.java
private static void addMetaData(Document document) { document.addTitle("Carburant PDF"); document.addSubject("subject"); document.addKeywords("Car Fleet Management, PDF, JAVA"); document.addAuthor("Marwen"); document.addCreator("Marwen"); }
From source file:GUI.Cars.java
private static void addMetaData(Document document) { document.addTitle("Cars PDF"); document.addSubject("subject"); document.addKeywords("Car Fleet Management, PDF, JAVA"); document.addAuthor("Marwen"); document.addCreator("Marwen"); }
From source file:GUI.Fixings.java
private static void addMetaData(Document document) { document.addTitle("Fixing PDF"); document.addSubject("subject"); document.addKeywords("Car Fleet Management, PDF, JAVA"); document.addAuthor("Marwen"); document.addCreator("Marwen"); }
From source file:has.GenerateReceipt.java
private static void addMetaData(Document document) { document.addTitle("RECEPIT "); document.addSubject("Using iText"); document.addKeywords("Java, PDF, iText"); document.addAuthor("Kesava"); document.addCreator("Kesava"); }
From source file:ics4u.ics4u_final_project.Recipe.java
License:Open Source License
private void addMetaData(Document doc) { //add all the meta data of the docmuent doc.addTitle(title);//from w ww.ja va 2s . co m doc.addSubject("Recipies"); doc.addKeywords("recipe, " + title); doc.addAuthor("Isaac Wismer"); doc.addCreator("Nutrient Calculator. Made using the iTextPDF Library 5.5.8 http://itextpdf.com/"); }
From source file:info.toegepaste.www.service.ProjectServiceImpl.java
public void createPDFje(List<Score> scores) { try {// w w w . j a va 2s .c om Document document = new Document(); // Tijdelijk bestand aanmaken (PDF) File temp = File.createTempFile("resultaat", ".pdf"); //PDF openen en bewerken PdfWriter.getInstance(document, new FileOutputStream(temp.getAbsolutePath())); document.open(); // MetaData toevoegen document.addTitle("Resulaten"); document.addAuthor("Score Tracker"); document.addCreator("Score Tracker"); // Titel toevoegen Paragraph preface = new Paragraph(); preface.add(new Paragraph("Resultaten van de gekozen scores")); addEmptyLine(preface, 2); document.add(preface); // Tabel toevoegen met 5 kolommen PdfPTable table = new PdfPTable(5); PdfPCell c1 = new PdfPCell(new Phrase("Klas")); c1.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(c1); c1 = new PdfPCell(new Phrase("Student")); c1.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(c1); c1 = new PdfPCell(new Phrase("Vak")); c1.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(c1); c1 = new PdfPCell(new Phrase("Test")); c1.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(c1); c1 = new PdfPCell(new Phrase("Resultaat")); c1.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(c1); table.setHeaderRows(1); //tabel opvullen met scores uit "List<Score> scores" for (Score score : scores) { table.addCell(score.getStudent().getKlas().getGroep()); table.addCell(score.getStudent().getNaam()); table.addCell(score.getTest().getVak().getNaam()); table.addCell(score.getTest().getNaam()); table.addCell(score.getPunt() + " / " + score.getTest().getMaxScore()); } // breedte van de kolommen float[] columnWidths = new float[] { 10f, 25f, 20f, 20f, 15f }; table.setWidths(columnWidths); document.add(table); document.close(); // PDF downloaden exportPdf(temp); } catch (Exception e) { e.printStackTrace(); } }
From source file:info.toegepaste.www.service.ProjectServiceImpl.java
public void createPDF(List<Score> scores) { try {/*from w w w . j a va 2 s .co m*/ Document document = new Document(); // Tijdelijk bestand aanmaken (PDF) File temp = File.createTempFile("resultaat", ".pdf"); //PDF openen en bewerken PdfWriter.getInstance(document, new FileOutputStream(temp.getAbsolutePath())); document.open(); // MetaData toevoegen document.addTitle("Resulaten"); document.addAuthor("Score Tracker"); document.addCreator("Score Tracker"); // Titel toevoegen Paragraph preface = new Paragraph(); preface.add(new Paragraph("Resultaten van de gekozen scores")); addEmptyLine(preface, 2); document.add(preface); // Tabel toevoegen PdfPTable table = new PdfPTable(4); PdfPCell c1 = new PdfPCell(new Phrase("Student")); c1.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(c1); c1 = new PdfPCell(new Phrase("Vak")); c1.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(c1); c1 = new PdfPCell(new Phrase("Test")); c1.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(c1); c1 = new PdfPCell(new Phrase("Resultaat")); c1.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(c1); table.setHeaderRows(1); //tabel opvullen met scores uit "List<Score> scores" for (Score score : scores) { table.addCell(score.getStudent().getNaam()); table.addCell(score.getTest().getVak().getNaam()); table.addCell(score.getTest().getNaam()); table.addCell(score.getPunt() + " / " + score.getTest().getMaxScore()); } // breedte van de kolommen float[] columnWidths = new float[] { 10f, 25f, 20f, 20f, 15f }; table.setWidths(columnWidths); document.add(table); document.close(); // PDF downloaden exportPdf(temp); } catch (Exception e) { e.printStackTrace(); } }
From source file:itext_result.Main.java
private int developScreeningSheet() { new SwingWorker<Object, Object>() { String filename;// www . j av a 2 s . c o m @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; }