List of usage examples for com.itextpdf.text Document addCreator
public boolean addCreator(String creator)
From source file:cis_690_report.DynamicReporter.java
private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton11ActionPerformed // TODO add your handling code here: // build a controller SwingController controller = new SwingController(); // Build a SwingViewFactory configured with the controller SwingViewBuilder factory = new SwingViewBuilder(controller); // Use the factory to build a JPanel that is pre-configured //with a complete, active Viewer UI. JPanel viewerComponentPanel = factory.buildViewerPanel(); // add copy keyboard command ComponentKeyBinding.install(controller, viewerComponentPanel); // add interactive mouse link annotation support via callback controller.getDocumentViewController().setAnnotationCallback( new org.icepdf.ri.common.MyAnnotationCallback(controller.getDocumentViewController())); // Create a JFrame to display the panel in JFrame window = new JFrame("Using the Viewer Component"); window.getContentPane().add(viewerComponentPanel); window.pack();//w ww.j a v a2 s . c o m window.setVisible(true); String Path; Path = "C:/Users/Shubh Chopra/Documents/reporter.pdf"; try { br1 = new BufferedReader(new FileReader(f)); BufferedReader b1 = new BufferedReader(new FileReader(f)); } catch (FileNotFoundException ex) { } String line = ""; bull1 = new String[number_of_rows - 1][]; int k = 0; BufferedReader br3 = null; try { br3 = new BufferedReader(new FileReader(f)); } catch (FileNotFoundException ex) { } try { while ((line = br3.readLine()) != null) { // use comma as separator String Bull[] = line.split(","); if (k != 0) { System.out.println(Bull.length); bull1[k - 1] = new String[Bull.length]; for (int j = 0; j < Bull.length; j++) { bull1[k - 1][j] = Bull[j]; } } k++; } } catch (IOException ex) { } Document doc = new Document(); PdfWriter docWriter = null; DecimalFormat df = new DecimalFormat("0.00"); try { //special font sizes Font bfBold12 = new Font(Font.FontFamily.TIMES_ROMAN, 8, Font.BOLD, new BaseColor(0, 0, 0)); Font bf12 = new Font(Font.FontFamily.TIMES_ROMAN, 6); Font bfBold20 = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD); //file path docWriter = PdfWriter.getInstance(doc, new FileOutputStream(Path)); //document header attributes doc.addAuthor("Shubh Chopra"); doc.addCreationDate(); doc.addProducer(); doc.addCreator("Shubh Chopra"); doc.addTitle("BES"); doc.setPageSize(PageSize.LETTER.rotate()); //open document doc.open(); //create a paragraph Paragraph paragraph = new Paragraph("BULL EVALUATION\n\n"); paragraph.setFont(bfBold20); paragraph.setAlignment(Element.ALIGN_CENTER); Image img = Image.getInstance("VETMED.png"); img.scaleToFit(300f, 150f); doc.add(paragraph); PdfPTable table1 = new PdfPTable(2); table1.setWidthPercentage(100); PdfPCell cell = new PdfPCell(img); cell.setBorder(PdfPCell.NO_BORDER); table1.addCell(cell); String temp1 = "\tOwner: " + bull1[1][62] + " " + bull1[1][63] + "\n\n\tRanch: " + bull1[1][64] + "\n\n\tAddress: " + bull1[1][55] + "\n\n\tCity: " + bull1[1][57] + "\n\n\tState: " + bull1[1][60] + "\tZip: " + bull1[1][61] + "\n\n\tPhone: " + bull1[1][59] + "\n\n"; table1.addCell(getCell(temp1, PdfPCell.ALIGN_LEFT)); doc.add(table1); //specify column widths int temp = dlm2.size(); float[] columnWidths = new float[temp]; for (int x = 0; x < columnWidths.length; x++) { columnWidths[x] = 2f; } //create PDF table with the given widths PdfPTable table = new PdfPTable(columnWidths); // set table width a percentage of the page width table.setWidthPercentage(90f); DynamicReporter re; re = new DynamicReporter(); for (int i = 0; i < dlm2.size(); i++) { String[] parts = dlm2.get(i).toString().split(": "); String part2 = parts[1]; re.insertCell(table, newhead[Integer.parseInt(part2)], Element.ALIGN_CENTER, 1, bfBold12); } table.setHeaderRows(1); //insert an empty row //create section heading by cell merging //just some random data to fill for (int x = 0; x < dlm3.size(); x++) { String str = dlm3.get(x).toString(); System.out.println(str); String[] parts = str.split(":"); String part2 = parts[1]; System.out.println(part2); int row = Integer.parseInt(part2) - 1; for (int i = 0; i < dlm2.getSize(); i++) for (int j = 0; j < header.length && j < bull1[row].length; j++) { String str1 = dlm2.get(i).toString(); String[] p1 = str1.split(": "); String p2 = p1[0]; if (p2.equals(header[j])) { re.insertCell(table, bull1[row][j], Element.ALIGN_CENTER, 1, bf12); } } // re.insertCell(table, bull1[x][7] , Element.ALIGN_CENTER, 1, bf12); } doc.add(table); if (jCheckBox2.isSelected()) { DefaultCategoryDataset dataSet = new DefaultCategoryDataset(); for (int i = 0; i < dlm3.size(); i++) { String str = dlm3.get(i).toString(); System.out.println(str); String[] parts = str.split(":"); String part1 = parts[0]; String part2 = parts[1]; System.out.println(part2); int row = Integer.parseInt(part2) - 1; float total = (float) 0.0; for (int j = 77; j < header.length && j < bull1[row].length; j++) { if (bull1[row][j].equals("")) { continue; } else { total += Integer.parseInt(bull1[row][j]); } } System.out.println(total); for (int j = 77; j < header.length && j < bull1[row].length; j++) { if (!bull1[row][j].equals("")) { String[] Parts = header[j].split("_"); String Part2 = Parts[1]; dataSet.setValue((Integer.parseInt(bull1[row][j]) * 100) / total, Part2, part1); } else { dataSet.setValue(0, "Percent", header[j]); } } } JFreeChart chart = ChartFactory.createBarChart("Multi Bull Morphology Chart ", "Morphology", "Percent", dataSet, PlotOrientation.VERTICAL, true, true, false); if (dlm3.size() > 12) { doc.newPage(); } PdfContentByte contentByte = docWriter.getDirectContent(); PdfTemplate template = contentByte.createTemplate(325, 250); PdfGraphics2D graphics2d = new PdfGraphics2D(template, 325, 250); Rectangle2D rectangle2d = new Rectangle2D.Double(0, 0, 325, 250); chart.draw(graphics2d, rectangle2d); graphics2d.dispose(); contentByte.addTemplate(template, 0, 0); } if (jCheckBox1.isSelected()) { for (int i = 0; i < dlm3.size(); i++) { DefaultCategoryDataset dataSet = new DefaultCategoryDataset(); String str = dlm3.get(i).toString(); System.out.println(str); String[] parts = str.split(":"); String part1 = parts[0]; String part2 = parts[1]; System.out.println(part2); int row = Integer.parseInt(part2) - 1; float total = (float) 0.0; for (int j = 77; j < header.length && j < bull1[row].length; j++) { if (bull1[row][j].equals("")) { continue; } else { total += Integer.parseInt(bull1[row][j]); } } System.out.println(total); for (int j = 77; j < header.length && j < bull1[row].length; j++) { if (!bull1[row][j].equals("")) { String[] Parts = header[j].split("_"); String Part2 = Parts[1]; dataSet.setValue((Integer.parseInt(bull1[row][j]) * 100) / total, "Percent", Part2); } else { dataSet.setValue(0, "Percent", header[j]); } } JFreeChart chart = ChartFactory.createBarChart("Single Bull Morphology Chart " + part1, "Morphology", "Percent", dataSet, PlotOrientation.VERTICAL, false, true, false); if ((dlm3.size() > 12 && i == 0) || jCheckBox2.isSelected()) { doc.newPage(); } PdfContentByte contentByte = docWriter.getDirectContent(); PdfTemplate template = contentByte.createTemplate(325, 250); PdfGraphics2D graphics2d = new PdfGraphics2D(template, 325, 250); Rectangle2D rectangle2d = new Rectangle2D.Double(0, 0, 325, 250); chart.draw(graphics2d, rectangle2d); graphics2d.dispose(); contentByte.addTemplate(template, 0, 0); doc.newPage(); } } } catch (DocumentException dex) { dex.printStackTrace(); } catch (FileNotFoundException ex) { Logger.getLogger(Reporter.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(Reporter.class.getName()).log(Level.SEVERE, null, ex); } finally { if (doc != null) { //close the document doc.close(); } if (docWriter != null) { //close the writer docWriter.close(); } } controller.openDocument(Path); }
From source file:cis_690_report.Reporter.java
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed File1 = jTextField1.getText(); JFileChooser chooser = new JFileChooser(); int option = chooser.showOpenDialog(null); if (option == JFileChooser.APPROVE_OPTION) { if (chooser.getSelectedFile() != null) { File3 = chooser.getSelectedFile().getAbsolutePath(); }// w w w .j av a 2s. co m File file = new File(File1); try { br1 = new BufferedReader(new FileReader(file)); b1 = new BufferedReader(new FileReader(file)); } catch (FileNotFoundException ex) { } int number_of_rows1 = 0; String line = ""; String cvsSplitBy = ","; try { while ((line = br1.readLine()) != null) { // use comma as separator number_of_rows1++; } } catch (IOException ex) { Logger.getLogger(Reporter.class.getName()).log(Level.SEVERE, null, ex); } bull1 = new String[number_of_rows1][]; int k = 0; BufferedReader br2 = null; try { br2 = new BufferedReader(new FileReader(file)); } catch (FileNotFoundException ex) { } try { while ((line = br2.readLine()) != null) { // use comma as separator String Bull[] = line.split(","); System.out.println(Bull.length); bull1[k] = new String[93]; if (Bull.length < 10) { for (int j = 0; j < 92; j++) { bull1[k][j] = ""; //System.out.println(Bull[j]); } } else { for (int j = 0; j < Bull.length; j++) { bull1[k][j] = Bull[j]; //System.out.println(Bull[j]); } } k++; } } catch (IOException ex) { } Document doc = new Document(); PdfWriter docWriter = null; DecimalFormat df = new DecimalFormat("0.00"); try { //special font sizes Font bfBold12 = new Font(FontFamily.TIMES_ROMAN, 8, Font.BOLD, new BaseColor(0, 0, 0)); Font bf12 = new Font(FontFamily.TIMES_ROMAN, 6); Font bfBold20 = new Font(FontFamily.TIMES_ROMAN, 12, Font.BOLD); //file path docWriter = PdfWriter.getInstance(doc, new FileOutputStream(File3)); //document header attributes doc.addAuthor("Shubh Chopra"); doc.addCreationDate(); doc.addProducer(); doc.addCreator("Shubh Chopra"); doc.addTitle("BES"); doc.setPageSize(PageSize.LETTER.rotate()); //open document doc.open(); //create a paragraph Paragraph paragraph = new Paragraph("BULL EVALUATION\n\n"); paragraph.setFont(bfBold20); paragraph.setAlignment(Element.ALIGN_CENTER); Image img = Image.getInstance("VETMED.png"); img.scaleToFit(300f, 150f); doc.add(paragraph); PdfPTable table1 = new PdfPTable(2); table1.setWidthPercentage(100); PdfPCell cell = new PdfPCell(img); cell.setBorder(PdfPCell.NO_BORDER); table1.addCell(cell); String temp1 = "\tOwner: " + bull1[1][78] + " " + bull1[1][79] + "\n\n\tRanch: " + bull1[1][80] + "\n\n\tAddress: " + bull1[1][71] + "\n\n\tCity: " + bull1[1][73] + "\n\n\tState: " + bull1[1][76] + "\tZip: " + bull1[1][77] + "\n\n\tPhone: " + bull1[1][75] + "\n\n"; table1.addCell(getCell(temp1, PdfPCell.ALIGN_LEFT)); doc.add(table1); boolean[] checkboxs = { jCheckBox1.isSelected(), jCheckBox2.isSelected(), jCheckBox3.isSelected(), jCheckBox4.isSelected(), jCheckBox5.isSelected(), jCheckBox6.isSelected(), jCheckBox7.isSelected(), jCheckBox8.isSelected(), jCheckBox9.isSelected(), jCheckBox10.isSelected(), jCheckBox11.isSelected(), jCheckBox12.isSelected(), jCheckBox13.isSelected() }; //specify column widths int temp = 0; for (int x = 0; x < checkboxs.length; x++) { if (checkboxs[x] == true) { temp++; } } float[] columnWidths = new float[temp + 5]; for (int x = 0; x < columnWidths.length; x++) { if (x < 5) columnWidths[x] = 1f; else if (jCheckBox1.isSelected() && x == 5) columnWidths[x] = 2f; else if (jCheckBox2.isSelected() && jCheckBox3.isSelected() && x == 7) columnWidths[x] = 2f; else if (!jCheckBox2.isSelected() && jCheckBox3.isSelected() && x == 6) columnWidths[x] = 2f; else if (jCheckBox4.isSelected() && x == columnWidths.length - 2) columnWidths[x] = 2f; else if (jCheckBox5.isSelected() && x == columnWidths.length - 1) columnWidths[x] = 2f; else columnWidths[x] = 1f; } //create PDF table with the given widths PdfPTable table = new PdfPTable(columnWidths); // set table width a percentage of the page width table.setWidthPercentage(90f); Reporter re; re = new Reporter(); //insert column headings re.insertCell(table, "ID-Tag", Element.ALIGN_CENTER, 1, bfBold12); re.insertCell(table, "ID-Tatto", Element.ALIGN_CENTER, 1, bfBold12); re.insertCell(table, "ID-RFID", Element.ALIGN_CENTER, 1, bfBold12); re.insertCell(table, "ID-Brand", Element.ALIGN_CENTER, 1, bfBold12); re.insertCell(table, "ID-Other", Element.ALIGN_CENTER, 1, bfBold12); if (jCheckBox1.isSelected()) re.insertCell(table, "Age", Element.ALIGN_CENTER, 1, bfBold12); if (jCheckBox2.isSelected()) re.insertCell(table, "Scrotal", Element.ALIGN_CENTER, 1, bfBold12); if (jCheckBox3.isSelected()) re.insertCell(table, "Motility", Element.ALIGN_CENTER, 1, bfBold12); if (jCheckBox6.isSelected()) re.insertCell(table, "Normal", Element.ALIGN_CENTER, 1, bfBold12); if (jCheckBox7.isSelected()) re.insertCell(table, "M2", Element.ALIGN_CENTER, 1, bfBold12); if (jCheckBox8.isSelected()) re.insertCell(table, "M3", Element.ALIGN_CENTER, 1, bfBold12); if (jCheckBox9.isSelected()) re.insertCell(table, "M4", Element.ALIGN_CENTER, 1, bfBold12); if (jCheckBox10.isSelected()) re.insertCell(table, "M5", Element.ALIGN_CENTER, 1, bfBold12); if (jCheckBox11.isSelected()) re.insertCell(table, "M6", Element.ALIGN_CENTER, 1, bfBold12); if (jCheckBox12.isSelected()) re.insertCell(table, "M7", Element.ALIGN_CENTER, 1, bfBold12); if (jCheckBox13.isSelected()) re.insertCell(table, "M8", Element.ALIGN_CENTER, 1, bfBold12); if (jCheckBox4.isSelected()) re.insertCell(table, "Comments", Element.ALIGN_CENTER, 1, bfBold12); if (jCheckBox5.isSelected()) re.insertCell(table, "Classification", Element.ALIGN_CENTER, 1, bfBold12); table.setHeaderRows(1); //insert an empty row //create section heading by cell merging //just some random data to fill for (int x = 1; x < number_of_rows1; x++) { re.insertCell(table, bull1[x][7], Element.ALIGN_CENTER, 1, bf12); re.insertCell(table, bull1[x][8], Element.ALIGN_CENTER, 1, bf12); re.insertCell(table, bull1[x][6], Element.ALIGN_CENTER, 1, bf12); re.insertCell(table, bull1[x][2], Element.ALIGN_CENTER, 1, bf12); re.insertCell(table, bull1[x][9], Element.ALIGN_CENTER, 1, bf12); if (jCheckBox1.isSelected()) re.insertCell(table, bull1[x][0], Element.ALIGN_CENTER, 1, bf12); if (jCheckBox2.isSelected()) re.insertCell(table, bull1[x][70], Element.ALIGN_CENTER, 1, bf12); if (jCheckBox3.isSelected()) re.insertCell(table, bull1[x][61], Element.ALIGN_CENTER, 1, bf12); if (jCheckBox6.isSelected()) re.insertCell(table, bull1[x][43], Element.ALIGN_CENTER, 1, bf12); if (jCheckBox7.isSelected()) re.insertCell(table, bull1[x][45], Element.ALIGN_CENTER, 1, bf12); if (jCheckBox8.isSelected()) re.insertCell(table, bull1[x][47], Element.ALIGN_CENTER, 1, bf12); if (jCheckBox9.isSelected()) re.insertCell(table, bull1[x][49], Element.ALIGN_CENTER, 1, bf12); if (jCheckBox10.isSelected()) re.insertCell(table, bull1[x][51], Element.ALIGN_CENTER, 1, bf12); if (jCheckBox11.isSelected()) re.insertCell(table, bull1[x][53], Element.ALIGN_CENTER, 1, bf12); if (jCheckBox12.isSelected()) re.insertCell(table, bull1[x][55], Element.ALIGN_CENTER, 1, bf12); if (jCheckBox13.isSelected()) re.insertCell(table, bull1[x][57], Element.ALIGN_CENTER, 1, bf12); if (jCheckBox4.isSelected()) re.insertCell(table, "", Element.ALIGN_CENTER, 1, bf12); if (jCheckBox5.isSelected()) re.insertCell(table, bull1[x][35], Element.ALIGN_CENTER, 1, bf12); } doc.add(table); } catch (DocumentException dex) { dex.printStackTrace(); } catch (FileNotFoundException ex) { Logger.getLogger(Reporter.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(Reporter.class.getName()).log(Level.SEVERE, null, ex); } finally { if (doc != null) { //close the document doc.close(); } if (docWriter != null) { //close the writer docWriter.close(); } } // TODO add your handling code here: } //GEN-LAST:event_jButton1ActionPerformed }
From source file:climbingcompranking.model.ranking.RankingGenerator.java
License:Open Source License
public void createRankingPDF(String competitionName, CompetitionType compType) { doTheRanking(compType);/*www .j a va 2 s .c o m*/ try { Document document = new Document(PageSize.A4.rotate()); // Landscape Date date = new Date(); String dateStr = ""; if (Locale.getDefault().equals(Locale.FRANCE)) { dateStr = new SimpleDateFormat("dd-MM-yyyy").format(date); } else { dateStr = new SimpleDateFormat("yyyy-MM-dd").format(date); } PdfWriter.getInstance(document, new FileOutputStream("data/pdf/" + competitionName + '-' + dateStr + ".pdf")); document.open(); // Meta data document.addTitle(competitionName); document.addSubject(competitionName + " ranking."); document.addKeywords(competitionName + ", ranking, climbingcompetition, climbcompranking"); document.addAuthor("ClimbingCompRanking - https://github.com/Yaty/ClimbingCompRanking"); document.addCreator("ClimbingCompRanking - https://github.com/Yaty/ClimbingCompRanking"); document.addCreationDate(); document.setMargins(0, 0, 0, 0); PdfPCell club = new PdfPCell(new Phrase(I18n.MODEL.getString("Club"))); PdfPCell climberName = new PdfPCell(new Phrase(I18n.MODEL.getString("ClimberName"))); PdfPCell ranking = new PdfPCell(new Phrase(I18n.MODEL.getString("Ranking"))); for (Map.Entry<Category, ArrayList<Climber>> climbersCategory : climbersMap.entrySet()) { if (climbersCategory.getValue().isEmpty()) continue; document.newPage(); // Title Paragraph title = new Paragraph( competitionName + " : " + climbersCategory.getKey().getCategoryName()); title.setAlignment(Element.ALIGN_CENTER); title.setFont(new Font(Font.FontFamily.HELVETICA, 36)); title.setSpacingAfter(20); // Table PdfPTable table = null; switch (compType) { case BOULDERING: case LEAD: case SPEED: table = new PdfPTable(3); // Club | Full name | Ranking table.addCell(club); table.addCell(climberName); table.addCell(ranking); for (Climber climber : climbersCategory.getValue()) { table.addCell(new PdfPCell(new Phrase(climber.getClubName()))); table.addCell(new PdfPCell(new Phrase(climber.getFullName()))); table.addCell(new PdfPCell(new Phrase(String.valueOf(climber.getRank().getOverallRank())))); } break; case LEAD_AND_BOULDERING: table = new PdfPTable(6); // Club | Full name | Ranking table.addCell(club); table.addCell(climberName); table.addCell(new PdfPCell(new Phrase(I18n.MODEL.getString("LeadRanking")))); table.addCell(new PdfPCell(new Phrase(I18n.MODEL.getString("BoulderingRanking")))); table.addCell(new PdfPCell(new Phrase(I18n.MODEL.getString("Sum")))); table.addCell(ranking); for (Climber climber : climbersCategory.getValue()) { table.addCell(new PdfPCell(new Phrase(climber.getClubName()))); table.addCell(new PdfPCell(new Phrase(climber.getFullName()))); table.addCell(new PdfPCell(new Phrase(String.valueOf(climber.getRank().getLeadRank())))); table.addCell( new PdfPCell(new Phrase(String.valueOf(climber.getRank().getBoulderingRank())))); table.addCell(new PdfPCell( new Phrase(String.valueOf(climber.getRank().getTotalPoints(compType))))); table.addCell(new PdfPCell(new Phrase(String.valueOf(climber.getRank().getOverallRank())))); } break; case SPEED_AND_BOULDERING: table = new PdfPTable(6); // Club | Full name | Ranking table.addCell(club); table.addCell(climberName); table.addCell(new PdfPCell(new Phrase(I18n.MODEL.getString("SpeedRanking")))); table.addCell(new PdfPCell(new Phrase(I18n.MODEL.getString("BoulderingRanking")))); table.addCell(new PdfPCell(new Phrase(I18n.MODEL.getString("Sum")))); table.addCell(ranking); for (Climber climber : climbersCategory.getValue()) { table.addCell(new PdfPCell(new Phrase(climber.getClubName()))); table.addCell(new PdfPCell(new Phrase(climber.getFullName()))); table.addCell(new PdfPCell(new Phrase(String.valueOf(climber.getRank().getSpeedRank())))); table.addCell( new PdfPCell(new Phrase(String.valueOf(climber.getRank().getBoulderingRank())))); table.addCell(new PdfPCell( new Phrase(String.valueOf(climber.getRank().getTotalPoints(compType))))); table.addCell(new PdfPCell(new Phrase(String.valueOf(climber.getRank().getOverallRank())))); } break; case SPEED_AND_LEAD: table = new PdfPTable(6); // Club | Full name | Ranking table.addCell(club); table.addCell(climberName); table.addCell(new PdfPCell(new Phrase(I18n.MODEL.getString("SpeedRanking")))); table.addCell(new PdfPCell(new Phrase(I18n.MODEL.getString("LeadRanking")))); table.addCell(new PdfPCell(new Phrase(I18n.MODEL.getString("Sum")))); table.addCell(ranking); for (Climber climber : climbersCategory.getValue()) { table.addCell(new PdfPCell(new Phrase(climber.getClubName()))); table.addCell(new PdfPCell(new Phrase(climber.getFullName()))); table.addCell(new PdfPCell(new Phrase(String.valueOf(climber.getRank().getSpeedRank())))); table.addCell(new PdfPCell(new Phrase(String.valueOf(climber.getRank().getLeadRank())))); table.addCell(new PdfPCell( new Phrase(String.valueOf(climber.getRank().getTotalPoints(compType))))); table.addCell(new PdfPCell(new Phrase(String.valueOf(climber.getRank().getOverallRank())))); } break; case COMBINED: table = new PdfPTable(7); // Club | Full name | Ranking table.addCell(club); table.addCell(climberName); table.addCell(new PdfPCell(new Phrase(I18n.MODEL.getString("LeadRanking")))); table.addCell(new PdfPCell(new Phrase(I18n.MODEL.getString("BoulderingRanking")))); table.addCell(new PdfPCell(new Phrase(I18n.MODEL.getString("SpeedRanking")))); table.addCell(new PdfPCell(new Phrase(I18n.MODEL.getString("Sum")))); table.addCell(ranking); for (Climber climber : climbersCategory.getValue()) { table.addCell(new PdfPCell(new Phrase(climber.getClubName()))); table.addCell(new PdfPCell(new Phrase(climber.getFullName()))); table.addCell(new PdfPCell(new Phrase(String.valueOf(climber.getRank().getLeadRank())))); table.addCell( new PdfPCell(new Phrase(String.valueOf(climber.getRank().getBoulderingRank())))); table.addCell(new PdfPCell(new Phrase(String.valueOf(climber.getRank().getSpeedRank())))); table.addCell(new PdfPCell( new Phrase(String.valueOf(climber.getRank().getTotalPoints(compType))))); table.addCell(new PdfPCell(new Phrase(String.valueOf(climber.getRank().getOverallRank())))); } break; } // Alignment for (PdfPRow row : table.getRows()) { PdfPCell[] cells = row.getCells(); for (PdfPCell cellToAlign : cells) { cellToAlign.setHorizontalAlignment(Element.ALIGN_CENTER); cellToAlign.setVerticalAlignment(Element.ALIGN_CENTER); } } table.setHorizontalAlignment(Element.ALIGN_CENTER); table.setHeaderRows(1); document.add(title); document.add(table); } document.close(); } catch (DocumentException | FileNotFoundException ex) { Logger.getLogger(RankingGenerator.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:co.ordinate.printer.NewJFrame.java
private void A4BTNActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_A4BTNActionPerformed new SwingWorker<Object, Object>() { String filename;/* w w w . j a va 2s . co m*/ @Override protected void done() { ConsoleMsg("Printing PROFILE SHEET IN PROGRESS.. "); } @Override protected Object doInBackground() throws Exception { Document doc = new Document(); try { PdfWriter writer = PdfWriter.getInstance(doc, new FileOutputStream("A4.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.A4); doc.setMargins(10f, 10f, 10f, 10f); ///////////////////////////////////////////////////////////// int pageno = 1; for (int i = 0; i == pageno; i++) { // doc.add(imageRight); } PdfContentByte cb = writer.getDirectContent(); int i = 1; while (i <= pageno) { doc.newPage(); i++; } BaseFont labelFont = BaseFont.createFont(BaseFont.TIMES_ROMAN, "Cp1252", true); float width = doc.getPageSize().getWidth(); float height = doc.getPageSize().getHeight(); for (float h = 0; h <= height; h++) { for (float w = 0; w <= width; w++) { cb.beginText(); // cb.setColorFill(TITLE_COLOR); cb.setFontAndSize(labelFont, 2); cb.setTextMatrix(w, h); cb.showText(String.valueOf(h) + ":" + String.valueOf(w)); cb.endText(); w += 15; } h += 2; } cb.beginText(); // cb.setColorFill(TITLE_COLOR); cb.setFontAndSize(labelFont, 4); cb.setTextMatrix(20f, 220f); cb.showText("abcd"); cb.endText(); } catch (Exception e) { System.err.println(e.getMessage()); ConsoleMsg(e.getMessage()); } finally { doc.close(); } ConsoleMsg("PDF... GENERATED"); return null; // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }.execute(); // TODO add your handling code here: }
From source file:co.ordinate.printer.NewJFrame.java
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed new SwingWorker<Object, Object>() { String filename;/*w w w. j a v a2 s.co m*/ @Override protected void done() { ConsoleMsg("Printing PROFILE SHEET IN PROGRESS.. "); } @Override protected Object doInBackground() throws Exception { Document doc = new Document(); try { PdfWriter writer = PdfWriter.getInstance(doc, new FileOutputStream("letter.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.LETTER); doc.setMargins(10f, 10f, 10f, 10f); ///////////////////////////////////////////////////////////// int pageno = 1; for (int i = 0; i == pageno; i++) { // doc.add(imageRight); } PdfContentByte cb = writer.getDirectContent(); int i = 1; while (i <= pageno) { doc.newPage(); i++; } BaseFont labelFont = BaseFont.createFont(BaseFont.TIMES_ROMAN, "Cp1252", true); float width = doc.getPageSize().getWidth(); float height = doc.getPageSize().getHeight(); for (float h = 0; h <= height; h++) { for (float w = 0; w <= width; w++) { cb.beginText(); // cb.setColorFill(TITLE_COLOR); cb.setFontAndSize(labelFont, 4); cb.setTextMatrix(w, h); cb.showText(String.valueOf(h) + ":" + String.valueOf(w)); cb.endText(); w += 25; } h += 5; } cb.beginText(); // cb.setColorFill(TITLE_COLOR); cb.setFontAndSize(labelFont, 4); cb.setTextMatrix(20f, 220f); cb.showText("abcd"); cb.endText(); } catch (Exception e) { System.err.println(e.getMessage()); ConsoleMsg(e.getMessage()); } finally { doc.close(); } ConsoleMsg("PDF... GENERATED"); return null; // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }.execute(); // TODO add your handling code here: }
From source file:co.ordinate.printer.NewJFrame.java
private void printA6Sheet() { new SwingWorker<Object, Object>() { String filename;// w w w . ja va 2 s . c om @Override protected void done() { ConsoleMsg("Printing PROFILE SHEET IN PROGRESS.. "); System.err.println("Printing Done"); } @Override protected Object doInBackground() throws Exception { Document doc = new Document(); try { PdfWriter writer = PdfWriter.getInstance(doc, new FileOutputStream("A6.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(10f, 10f, 10f, 10f); ///////////////////////////////////////////////////////////// int pageno = 1; for (int i = 0; i == pageno; i++) { // doc.add(imageRight); } PdfContentByte cb = writer.getDirectContent(); int i = 1; while (i <= pageno) { doc.newPage(); i++; } BaseFont labelFont = BaseFont.createFont(BaseFont.TIMES_ROMAN, "Cp1252", true); float width = doc.getPageSize().getWidth(); float height = doc.getPageSize().getHeight(); for (float h = 0; h <= height; h++) { for (float w = 0; w <= width; w++) { cb.beginText(); // cb.setColorFill(TITLE_COLOR); cb.setFontAndSize(labelFont, 4); cb.setTextMatrix(w, h); cb.showText(String.valueOf(h) + ":" + String.valueOf(w)); cb.endText(); w += 30; } h += 8; } cb.beginText(); // cb.setColorFill(TITLE_COLOR); cb.setFontAndSize(labelFont, 4); cb.setTextMatrix(20f, 220f); cb.showText("abcd"); cb.endText(); } catch (Exception e) { System.err.println(e.getMessage()); ConsoleMsg(e.getMessage()); } finally { doc.close(); } ConsoleMsg("PDF... GENERATED"); System.err.println("Printing Done"); return null; // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }.execute(); // TODO add your handling code here: }
From source file:co.unicauca.proyectobase.entidades.MetodosPDF.java
public void createPdf(String filename) throws IOException, DocumentException { // step 1: Crear el objeto Document document = new Document(); // step 2: instanciar para escritura con el objeto creado PdfWriter.getInstance(document, new FileOutputStream(filename)); // step 3: agregar los metadatos document.addTitle("Hello World example"); document.addAuthor("Bruno Lowagie"); document.addSubject("This example shows how to add metadata"); document.addKeywords("Metadata, iText, PDF"); document.addCreator("My program using iText"); document.open();//from ww w.j a v a 2s. co m // step 4: agregar el conteido, en este caso "Parrafo 1" document.add(new Paragraph("Parrafo 1")); // step 5: cerrar el archivo que se creo document.close(); }
From source file:com.ainfosec.macresponse.report.PdfGenerator.java
License:Open Source License
private static void addMetaData(String caseName, String authorName, Document document) { document.addTitle(caseName);/*from www . java 2 s .c o m*/ document.addSubject("MacResponse Console"); document.addKeywords(""); document.addAuthor(authorName); document.addCreator(System.getProperty("user.name")); }
From source file:com.algoboss.erp.util.report.PDFExporter.java
License:Apache License
public void export(FacesContext context, DataTable table, String filename, String encodingType) throws IOException { try {/*from www . ja v a 2 s . c o m*/ Document document = new Document(PageSize.A4, 25f, 25f, 25f, 25f); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter.getInstance(document, baos); if (!document.isOpen()) { document.open(); } document.addAuthor("Algo Boss"); document.addCreator("Real's HowTo"); document.addSubject("Thanks for your support"); document.addCreationDate(); document.addTitle(filename); //document.setMargins(1f, 1f, 1f, 1f); //document.setPageSize(PageSize.A4); document.add(exportPDFTable(context, table, false, false, false, encodingType)); //document.setMargins(1f, 1f, 1f, 1f); //document.setPageSize(PageSize.A4); document.close(); //writePDFToResponse(context.getExternalContext(), baos, filename); writePDFToResponseNew(context.getExternalContext(), baos, filename); } catch (DocumentException e) { throw new IOException(e.getMessage()); } }
From source file:com.algoboss.erp.util.report.PDFExporter2.java
License:Apache License
public void export(FacesContext context, DataTable table, String filename) throws IOException { try {/*from w w w .jav a2 s . c o m*/ Document document = new Document(PageSize.A4); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream baos2 = new ByteArrayOutputStream(1000000); FileOutputStream file = new FileOutputStream("D://Documents//testeLink.pdf"); PdfWriter pdfWriter = PdfWriter.getInstance(document, file); document.open(); document.addAuthor("Algo Boss"); document.addCreator("Real's HowTo"); document.addSubject("Thanks for your support"); document.addCreationDate(); document.addTitle("Please read this"); //XMLWorkerHelper worker = XMLWorkerHelper.getInstance(); DataTableRenderer render = new DataTableRenderer(); HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse(); response.reset(); ExternalContext externalContext = context.getExternalContext(); //BufferedWriter writer = new BufferedWriter(baos2,true); OutputStreamWriter writer = new OutputStreamWriter(baos2, "iso-8859-1"); context.setResponseWriter(context.getRenderKit().createResponseWriter(writer, null, "iso-8859-1")); render.encodeEnd(context, table); //System.out.println(new String(baos2.toByteArray(), "utf-8")); /*writer.write( "<link href=\"/ERP/f/javax.faces.resource/theme.css?ln=primefaces-cupertino\" rel=\"stylesheet\" type=\"text/css\">\n" + "<link href=\"/ERP/f/javax.faces.resource/primefaces.css?ln=primefaces\" rel=\"stylesheet\" type=\"text/css\">\n" + "<link href=\"/ERP/f/javax.faces.resource/schedule/schedule.css?ln=primefaces\" rel=\"stylesheet\" type=\"text/css\">\n" + "<meta content=\"application/pdf; charset=UTF-8\" http-equiv=\"Content-Type\">\n" + "<link type=\"text/css\" rel=\"stylesheet\" href=\"/ERP/resources/css/default.css\">\n" + "<link type=\"text/css\" rel=\"stylesheet\" href=\"/ERP/resources/css/cssLayout.css\">\n" + "<title>Plataforma de Gerenciamento</title>");*/ /* externalContext.setResponseHeader("Expires", "0"); externalContext.setResponseHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0"); externalContext.setResponseHeader("Pragma", "public"); externalContext.setResponseHeader("Content-disposition", "inline;filename=" + filename + ".pdf"); externalContext.setResponseContentType("application/pdf"); externalContext.setResponseContentLength(baos.size()); externalContext.addResponseCookie(Constants.DOWNLOAD_COOKIE, "true", new HashMap<String, Object>()); OutputStream out = externalContext.getResponseOutputStream(); baos.writeTo(out); externalContext.responseFlushBuffer(); */ response.setContentType("application/pdf"); response.setHeader("Content-Disposition", "inline;filename=\"" + filename + "\";"); //String str = "<html><head></head><body>" + new String(baos2.toByteArray()) + "</body></html>"; String str = "<html><head></head><body>" + "<link href=\"/ERP/f/javax.faces.resource/theme.css?ln=primefaces-cupertino\" rel=\"stylesheet\" type=\"text/css\"/>\n" + "<link href=\"/ERP/f/javax.faces.resource/primefaces.css?ln=primefaces\" rel=\"stylesheet\" type=\"text/css\"/>\n" + "<link href=\"/ERP/f/javax.faces.resource/schedule/schedule.css?ln=primefaces\" rel=\"stylesheet\" type=\"text/css\"/>\n" + "<meta content=\"application/pdf; charset=UTF-8\" http-equiv=\"Content-Type\"/>\n" + "<link type=\"text/css\" rel=\"stylesheet\" href=\"/ERP/resources/css/default.css\"/>\n" + "<link type=\"text/css\" rel=\"stylesheet\" href=\"/ERP/resources/css/cssLayout.css\"/>\n" + "<title>Plataforma de Gerenciamento</title>" + "<div id='tabView:ad_j_id77' class='ui-datatable ui-widget ui-algo-element ui-algo-element-container data-list'><div class='ui-datatable-header ui-widget-header ui-corner-top'><div id='tabView:ad_j_id77:ad_j_id41' class='ui-panel ui-widget ui-widget-content ui-corner-all ui-algo-element ui-algo-element-container'><div id='tabView:ad_j_id77:ad_j_id41_content' class='ui-panel-content ui-widget-content'><label id='tabView:ad_j_id77:ad_j_id39' class='ui-outputlabel ui-algo-element ui-algo-element-value'>Listagem: FUNCION?RIO</label><label id='tabView:ad_j_id77:ad_j_id40' class='ui-outputlabel ui-algo-element ui-algo-element-value' style='float:right;top:-5px;position: relative;'>Pesquisar: <input id='tabView:ad_j_id77:globalFilter' name='tabView:ad_j_id77:globalFilter' type='text' value='' onkeyup='funcionarioDataTable.filter()' class='ui-inputfield ui-inputtext ui-widget ui-state-default ui-corner-all ui-algo-element ui-algo-element-value' /><script id='tabView:ad_j_id77:globalFilter_s' type='text/javascript'>PrimeFaces.cw('InputText','widget_tabView_ad_j_id77_globalFilter',{id:'tabView:ad_j_id77:globalFilter'});</script></label></div></div><script id='tabView:ad_j_id77:ad_j_id41_s' type='text/javascript'>PrimeFaces.cw('Panel','widget_tabView_ad_j_id77_ad_j_id41',{id:'tabView:ad_j_id77:ad_j_id41'});</script></div><div id='tabView:ad_j_id77_paginator_top' class='ui-paginator ui-paginator-top ui-widget-header'><span class='ui-paginator-first ui-state-default ui-corner-all ui-state-disabled'><span class='ui-icon ui-icon-seek-first'>p</span></span><span class='ui-paginator-prev ui-state-default ui-corner-all ui-state-disabled'><span class='ui-icon ui-icon-seek-prev'>p</span></span><span class='ui-paginator-pages'><span class='ui-paginator-page ui-state-default ui-state-active ui-corner-all'>1</span><span class='ui-paginator-page ui-state-default ui-corner-all'>2</span></span><span class='ui-paginator-next ui-state-default ui-corner-all'><span class='ui-icon ui-icon-seek-next'>p</span></span><span class='ui-paginator-last ui-state-default ui-corner-all'><span class='ui-icon ui-icon-seek-end'>p</span></span></div><div class='ui-datatable-tablewrapper'><table role='grid'><thead id='tabView:ad_j_id77_head'><tr role='row'><th id='tabView:ad_j_id77:ad_j_id44' class='ui-state-default ui-sortable-column ui-filter-column' role='columnheader'><span>Nome</span><span class='ui-sortable-column-icon ui-icon ui-icon-carat-2-n-s'></span><input id='tabView:ad_j_id77:ad_j_id44:filter' name='tabView:ad_j_id77:ad_j_id44:filter' class='ui-column-filter ui-inputfield ui-inputtext ui-widget ui-state-default ui-corner-all' value='' autocomplete='off' style='display:none;' /></th><th id='tabView:ad_j_id77:ad_j_id48' class='ui-state-default ui-sortable-column ui-filter-column' role='columnheader'><span><span id='tabView:ad_j_id77:ad_j_id45'>Usurio</span></span><span class='ui-sortable-column-icon ui-icon ui-icon-carat-2-n-s'></span><input id='tabView:ad_j_id77:ad_j_id48:filter' name='tabView:ad_j_id77:ad_j_id48:filter' class='ui-column-filter ui-inputfield ui-inputtext ui-widget ui-state-default ui-corner-all' value='' autocomplete='off' style='display:none;' /></th><th id='tabView:ad_j_id77:ad_j_id52' class='ui-state-default ui-sortable-column ui-filter-column' role='columnheader'><span><span id='tabView:ad_j_id77:ad_j_id49'>Admisso</span></span><span class='ui-sortable-column-icon ui-icon ui-icon-carat-2-n-s'></span><input id='tabView:ad_j_id77:ad_j_id52:filter' name='tabView:ad_j_id77:ad_j_id52:filter' class='ui-column-filter ui-inputfield ui-inputtext ui-widget ui-state-default ui-corner-all' value='' autocomplete='off' style='display:none;' /></th><th id='tabView:ad_j_id77:ad_j_id56' class='ui-state-default ui-sortable-column ui-filter-column' role='columnheader' style='text-align:center;'><span><span id='tabView:ad_j_id77:ad_j_id53'>Afastado</span></span><span class='ui-sortable-column-icon ui-icon ui-icon-carat-2-n-s'></span><input id='tabView:ad_j_id77:ad_j_id56:filter' name='tabView:ad_j_id77:ad_j_id56:filter' class='ui-column-filter ui-inputfield ui-inputtext ui-widget ui-state-default ui-corner-all' value='' autocomplete='off' style='display:none;' /></th><th id='tabView:ad_j_id77:ad_j_id60' class='ui-state-default ui-sortable-column ui-filter-column' role='columnheader'><span><span id='tabView:ad_j_id77:ad_j_id57'>Veculo</span></span><span class='ui-sortable-column-icon ui-icon ui-icon-carat-2-n-s'></span><input id='tabView:ad_j_id77:ad_j_id60:filter' name='tabView:ad_j_id77:ad_j_id60:filter' class='ui-column-filter ui-inputfield ui-inputtext ui-widget ui-state-default ui-corner-all' value='' autocomplete='off' style='display:none;' /></th><th id='tabView:ad_j_id77:ad_j_id64' class='ui-state-default ui-sortable-column ui-filter-column' role='columnheader'><span><span id='tabView:ad_j_id77:ad_j_id61'>MATR?CULA</span></span><span class='ui-sortable-column-icon ui-icon ui-icon-carat-2-n-s'></span><input id='tabView:ad_j_id77:ad_j_id64:filter' name='tabView:ad_j_id77:ad_j_id64:filter' class='ui-column-filter ui-inputfield ui-inputtext ui-widget ui-state-default ui-corner-all' value='' autocomplete='off' style='display:none;' /></th><th id='tabView:ad_j_id77:ad_j_id68' class='ui-state-default ui-sortable-column ui-filter-column' role='columnheader'><span><span id='tabView:ad_j_id77:ad_j_id65'>CPF</span></span><span class='ui-sortable-column-icon ui-icon ui-icon-carat-2-n-s'></span><input id='tabView:ad_j_id77:ad_j_id68:filter' name='tabView:ad_j_id77:ad_j_id68:filter' class='ui-column-filter ui-inputfield ui-inputtext ui-widget ui-state-default ui-corner-all' value='' autocomplete='off' style='display:none;' /></th><th id='tabView:ad_j_id77:ad_j_id72' class='ui-state-default' role='columnheader'><span><span id='tabView:ad_j_id77:ad_j_id69'>SAL?RIO</span></span></th><th id='tabView:ad_j_id77:ad_j_id76' class='ui-state-default' role='columnheader' style='text-align:center;'><span>Ao</span></th></tr></thead><tfoot></tfoot><tbody id='tabView:ad_j_id77_data' class='ui-datatable-data ui-widget-content'><tr data-ri='0' data-rk='315' class='ui-widget-content ui-datatable-even' role='row' aria-selected='false'><td role='gridcell'><span id='tabView:ad_j_id77:0:ad_j_id42'>MARCUS2</span><a id='tabView:ad_j_id77:0:ad_j_id43' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:0:ad_j_id43',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:0:ad_j_id46'>SDASA2</span><a id='tabView:ad_j_id77:0:ad_j_id47' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:0:ad_j_id47',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:0:ad_j_id50'>2013/08/15</span><a id='tabView:ad_j_id77:0:ad_j_id51' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:0:ad_j_id51',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell' style='text-align:center;'><span id='tabView:ad_j_id77:0:ad_j_id54' class=' ui-icon ui-icon-cancel ' style='display:inline-block;'>false</span><a id='tabView:ad_j_id77:0:ad_j_id55' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:0:ad_j_id55',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:0:ad_j_id58'>JQV-4404 - GM</span><a id='tabView:ad_j_id77:0:ad_j_id59' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:0:ad_j_id59',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:0:ad_j_id62'>123124</span><a id='tabView:ad_j_id77:0:ad_j_id63' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:0:ad_j_id63',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:0:ad_j_id66'></span><a id='tabView:ad_j_id77:0:ad_j_id67' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:0:ad_j_id67',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:0:ad_j_id70'></span><a id='tabView:ad_j_id77:0:ad_j_id71' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:0:ad_j_id71',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell' style='text-align:center;'><a id='tabView:ad_j_id77:0:ad_j_id73' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:0:ad_j_id73',update:'tabView:j_idt233'});return false;'>Editar</a><span id='tabView:ad_j_id77:0:ad_j_id74'> | </span><a id='tabView:ad_j_id77:0:ad_j_id75' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:0:ad_j_id75',update:'tabView:j_idt233'});return false;'>Excluir</a></td></tr><tr data-ri='1' data-rk='318' class='ui-widget-content ui-datatable-odd' role='row' aria-selected='false'><td role='gridcell'><span id='tabView:ad_j_id77:1:ad_j_id42'>PAULO</span><a id='tabView:ad_j_id77:1:ad_j_id43' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:1:ad_j_id43',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:1:ad_j_id46'>PAULO</span><a id='tabView:ad_j_id77:1:ad_j_id47' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:1:ad_j_id47',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:1:ad_j_id50'>2013/08/07</span><a id='tabView:ad_j_id77:1:ad_j_id51' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:1:ad_j_id51',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell' style='text-align:center;'><span id='tabView:ad_j_id77:1:ad_j_id54' class=' ui-icon ui-icon-cancel ' style='display:inline-block;'>false</span><a id='tabView:ad_j_id77:1:ad_j_id55' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:1:ad_j_id55',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:1:ad_j_id58'></span><a id='tabView:ad_j_id77:1:ad_j_id59' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:1:ad_j_id59',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:1:ad_j_id62'></span><a id='tabView:ad_j_id77:1:ad_j_id63' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:1:ad_j_id63',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:1:ad_j_id66'></span><a id='tabView:ad_j_id77:1:ad_j_id67' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:1:ad_j_id67',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:1:ad_j_id70'></span><a id='tabView:ad_j_id77:1:ad_j_id71' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:1:ad_j_id71',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell' style='text-align:center;'><a id='tabView:ad_j_id77:1:ad_j_id73' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:1:ad_j_id73',update:'tabView:j_idt233'});return false;'>Editar</a><span id='tabView:ad_j_id77:1:ad_j_id74'> | </span><a id='tabView:ad_j_id77:1:ad_j_id75' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:1:ad_j_id75',update:'tabView:j_idt233'});return false;'>Excluir</a></td></tr><tr data-ri='2' data-rk='319' class='ui-widget-content ui-datatable-even' role='row' aria-selected='false'><td role='gridcell'><span id='tabView:ad_j_id77:2:ad_j_id42'>MAIZA</span><a id='tabView:ad_j_id77:2:ad_j_id43' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:2:ad_j_id43',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:2:ad_j_id46'>MAIZA</span><a id='tabView:ad_j_id77:2:ad_j_id47' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:2:ad_j_id47',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:2:ad_j_id50'></span><a id='tabView:ad_j_id77:2:ad_j_id51' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:2:ad_j_id51',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell' style='text-align:center;'><span id='tabView:ad_j_id77:2:ad_j_id54' class=' ui-icon ui-icon-cancel ' style='display:inline-block;'>false</span><a id='tabView:ad_j_id77:2:ad_j_id55' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:2:ad_j_id55',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:2:ad_j_id58'>BMW - BMW-9999</span><a id='tabView:ad_j_id77:2:ad_j_id59' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:2:ad_j_id59',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:2:ad_j_id62'>TESTE123123</span><a id='tabView:ad_j_id77:2:ad_j_id63' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:2:ad_j_id63',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:2:ad_j_id66'>123.123.123-12</span><a id='tabView:ad_j_id77:2:ad_j_id67' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:2:ad_j_id67',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:2:ad_j_id70'>12.345,67</span><a id='tabView:ad_j_id77:2:ad_j_id71' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:2:ad_j_id71',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell' style='text-align:center;'><a id='tabView:ad_j_id77:2:ad_j_id73' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:2:ad_j_id73',update:'tabView:j_idt233'});return false;'>Editar</a><span id='tabView:ad_j_id77:2:ad_j_id74'> | </span><a id='tabView:ad_j_id77:2:ad_j_id75' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:2:ad_j_id75',update:'tabView:j_idt233'});return false;'>Excluir</a></td></tr><tr data-ri='3' data-rk='320' class='ui-widget-content ui-datatable-odd' role='row' aria-selected='false'><td role='gridcell'><span id='tabView:ad_j_id77:3:ad_j_id42'>ELAINE</span><a id='tabView:ad_j_id77:3:ad_j_id43' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:3:ad_j_id43',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:3:ad_j_id46'>ELAINE</span><a id='tabView:ad_j_id77:3:ad_j_id47' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:3:ad_j_id47',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:3:ad_j_id50'>2013/08/22</span><a id='tabView:ad_j_id77:3:ad_j_id51' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:3:ad_j_id51',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell' style='text-align:center;'><span id='tabView:ad_j_id77:3:ad_j_id54' class=' ui-icon ui-icon-cancel ' style='display:inline-block;'>false</span><a id='tabView:ad_j_id77:3:ad_j_id55' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:3:ad_j_id55',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:3:ad_j_id58'>JQV-4404 - GM</span><a id='tabView:ad_j_id77:3:ad_j_id59' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:3:ad_j_id59',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:3:ad_j_id62'></span><a id='tabView:ad_j_id77:3:ad_j_id63' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:3:ad_j_id63',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:3:ad_j_id66'></span><a id='tabView:ad_j_id77:3:ad_j_id67' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:3:ad_j_id67',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:3:ad_j_id70'></span><a id='tabView:ad_j_id77:3:ad_j_id71' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:3:ad_j_id71',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell' style='text-align:center;'><a id='tabView:ad_j_id77:3:ad_j_id73' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:3:ad_j_id73',update:'tabView:j_idt233'});return false;'>Editar</a><span id='tabView:ad_j_id77:3:ad_j_id74'> | </span><a id='tabView:ad_j_id77:3:ad_j_id75' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:3:ad_j_id75',update:'tabView:j_idt233'});return false;'>Excluir</a></td></tr><tr data-ri='4' data-rk='321' class='ui-widget-content ui-datatable-even' role='row' aria-selected='false'><td role='gridcell'><span id='tabView:ad_j_id77:4:ad_j_id42'>CLEIDE2</span><a id='tabView:ad_j_id77:4:ad_j_id43' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:4:ad_j_id43',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:4:ad_j_id46'>CLEIDE DA SILVA</span><a id='tabView:ad_j_id77:4:ad_j_id47' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:4:ad_j_id47',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:4:ad_j_id50'>2013/08/19</span><a id='tabView:ad_j_id77:4:ad_j_id51' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:4:ad_j_id51',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell' style='text-align:center;'><span id='tabView:ad_j_id77:4:ad_j_id54' class=' ui-icon ui-icon-check ' style='display:inline-block;'>true</span><a id='tabView:ad_j_id77:4:ad_j_id55' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:4:ad_j_id55',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:4:ad_j_id58'>EEQEWEQE - QWEQ</span><a id='tabView:ad_j_id77:4:ad_j_id59' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:4:ad_j_id59',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:4:ad_j_id62'></span><a id='tabView:ad_j_id77:4:ad_j_id63' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:4:ad_j_id63',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:4:ad_j_id66'>123.123.123-12</span><a id='tabView:ad_j_id77:4:ad_j_id67' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:4:ad_j_id67',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:4:ad_j_id70'>456,70</span><a id='tabView:ad_j_id77:4:ad_j_id71' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:4:ad_j_id71',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell' style='text-align:center;'><a id='tabView:ad_j_id77:4:ad_j_id73' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:4:ad_j_id73',update:'tabView:j_idt233'});return false;'>Editar</a><span id='tabView:ad_j_id77:4:ad_j_id74'> | </span><a id='tabView:ad_j_id77:4:ad_j_id75' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:4:ad_j_id75',update:'tabView:j_idt233'});return false;'>Excluir</a></td></tr><tr data-ri='5' data-rk='322' class='ui-widget-content ui-datatable-odd' role='row' aria-selected='false'><td role='gridcell'><span id='tabView:ad_j_id77:5:ad_j_id42'>GABRIELA</span><a id='tabView:ad_j_id77:5:ad_j_id43' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:5:ad_j_id43',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:5:ad_j_id46'>GABRIELA</span><a id='tabView:ad_j_id77:5:ad_j_id47' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:5:ad_j_id47',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:5:ad_j_id50'>2013/08/20</span><a id='tabView:ad_j_id77:5:ad_j_id51' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:5:ad_j_id51',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell' style='text-align:center;'><span id='tabView:ad_j_id77:5:ad_j_id54' class=' ui-icon ui-icon-cancel ' style='display:inline-block;'>false</span><a id='tabView:ad_j_id77:5:ad_j_id55' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:5:ad_j_id55',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:5:ad_j_id58'></span><a id='tabView:ad_j_id77:5:ad_j_id59' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:5:ad_j_id59',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:5:ad_j_id62'></span><a id='tabView:ad_j_id77:5:ad_j_id63' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:5:ad_j_id63',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:5:ad_j_id66'></span><a id='tabView:ad_j_id77:5:ad_j_id67' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:5:ad_j_id67',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell'><span id='tabView:ad_j_id77:5:ad_j_id70'></span><a id='tabView:ad_j_id77:5:ad_j_id71' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:5:ad_j_id71',update:'tabView:j_idt233'});return false;'></a></td><td role='gridcell' style='text-align:center;'><a id='tabView:ad_j_id77:5:ad_j_id73' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:5:ad_j_id73',update:'tabView:j_idt233'});return false;'>Editar</a><span id='tabView:ad_j_id77:5:ad_j_id74'> | </span><a id='tabView:ad_j_id77:5:ad_j_id75' href='#' class='ui-commandlink ui-widget' onclick='PrimeFaces.ab({source:'tabView:ad_j_id77:5:ad_j_id75',update:'tabView:j_idt233'});return false;'>Excluir</a></td></tr>" + "</tbody></table></div></div>" + "</body></html>"; //worker.parseXHtml(pdfWriter, document, new StringReader(str)); response.setContentLength(baos.size()); response.getOutputStream().write(baos.toByteArray(), 0, baos.size()); //System.out.println(str); document.close(); pdfWriter.close(); baos.close(); baos2.close(); file.close(); FacesContext.getCurrentInstance().responseComplete(); //writePDFToResponse(context.getExternalContext(), baos, filename); //writePDFToResponseNew(context.getExternalContext(), baos, filename); } catch (IOException e) { throw new IOException(e.getMessage()); } catch (Exception ex) { Logger.getLogger(PDFExporter2.class.getName()).log(Level.SEVERE, null, ex); } }