List of usage examples for com.itextpdf.text PageSize LETTER
Rectangle LETTER
To view the source code for com.itextpdf.text PageSize LETTER.
Click Source Link
From source file:cis_690_report.DynamicReporter.java
private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed // TODO add your handling code here: // build a controller SwingController controller = new SwingController(); // Build a SwingViewFactory configured with the controller SwingViewBuilder factory = new SwingViewBuilder(controller); // Use the factory to build a JPanel that is pre-configured //with a complete, active Viewer UI. JPanel viewerComponentPanel = factory.buildViewerPanel(); // add copy keyboard command ComponentKeyBinding.install(controller, viewerComponentPanel); // add interactive mouse link annotation support via callback controller.getDocumentViewController().setAnnotationCallback( new org.icepdf.ri.common.MyAnnotationCallback(controller.getDocumentViewController())); // Create a JFrame to display the panel in JFrame window = new JFrame("Using the Viewer Component"); window.getContentPane().add(viewerComponentPanel); window.pack();/*from w w w.j a v a2 s .c 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.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 a 2s . co 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(); }/* ww w. j av a 2 s . c om*/ 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:clases.Funciones.java
private String GenerateReporte_pdf(JTable t, String title, int open) { Document documento = new Document(PageSize.LETTER.rotate(), 10, 10, 10, 10); FileOutputStream ficheroPdf;/* w ww .j a v a2s .c o m*/ File ruta = null; com.itextpdf.text.Image imagen = null; try { imagen = com.itextpdf.text.Image.getInstance(p.ReturnPropiedad(p.Ruta_logo)); char rt = p.ReturnPropiedad(p.Ruta_SaveReports) .charAt(p.ReturnPropiedad(p.Ruta_SaveReports).length() - 1); if ("/".equalsIgnoreCase(String.valueOf(rt))) { ruta = new File(p.ReturnPropiedad(p.Ruta_SaveReports) + ReturnNombreUsuario().replace(" ", "_") + "_" + GetFechaAndHourActual().replace(" ", "_").replace(":", "_").replace("-", "_") + ".pdf"); } else { ruta = new File(p.ReturnPropiedad(p.Ruta_SaveReports) + "/" + ReturnNombreUsuario().replace(" ", "_") + "_" + GetFechaAndHourActual().replace(" ", "_").replace(":", "_").replace("-", "_") + ".pdf"); } ficheroPdf = new FileOutputStream(ruta); PdfWriter.getInstance(documento, ficheroPdf).setInitialLeading(20); } catch (DocumentException | IOException ex) { Alert("Verifique las rutas de guardado de reportes y logo."); } try { documento.open(); title += "\nGENER: " + ReturnNombreUsuario(); Paragraph Title = new Paragraph(title.toUpperCase()); Title.setAlignment(1); documento.add(Title); imagen.setAlignment(Element.ALIGN_CENTER); imagen.scaleToFit(200, 100); String membrete = ReturnDatosFisicos(this.Datos_Nombre) + "\n"; membrete += "DIRECCION: " + ReturnDatosFisicos(this.Datos_Direccion) + "\n"; membrete += "RFC: " + ReturnDatosFisicos(this.Datos_Rfc) + "\n"; membrete += "TELEFONO: " + ReturnDatosFisicos(this.Datos_Telefono) + "\n"; membrete += "GENERO DOCUMENTO: " + ReturnNombreUsuario() + "\n"; membrete += "FECHA Y HORA DE GENERACION: " + GetFechaAndHourActual() + "\n"; ///////// PdfPTable HeaderDatos = new PdfPTable(2); HeaderDatos.setWidthPercentage(100); documento.add(new Paragraph("\n")); PdfPCell cell = new PdfPCell(new Phrase(membrete)); cell.setBorder(0); HeaderDatos.addCell(cell); cell = new PdfPCell(imagen); cell.setBorder(0); cell.setHorizontalAlignment(1); HeaderDatos.addCell(cell); documento.add(HeaderDatos); documento.add(new Paragraph("\n")); ///////// PdfPTable tabla = new PdfPTable(t.getColumnCount()); tabla.setWidthPercentage(100); for (int i = 0; i < t.getColumnCount(); i++) { Paragraph header = new Paragraph(t.getColumnName(i)); header.setAlignment(1); tabla.addCell(header); } for (int i = 0; i < t.getRowCount(); i++) { for (int a = 0; a < t.getColumnCount(); a++) { Paragraph campo = new Paragraph(String.valueOf(t.getValueAt(i, a))); campo.setAlignment(1); tabla.addCell(campo); } } documento.add(tabla); documento.add(new Paragraph(" ")); Paragraph footer = new Paragraph("SOFTWARE Y MAS ! - WWW.CYBERCHOAPAS.COM"); footer.setAlignment(1); documento.add(footer); documento.close(); if (open > 0) { Desktop.getDesktop().open(ruta); } } catch (IOException | DocumentException ex) { Alert(ex.getMessage()); } return ruta.getAbsolutePath(); }
From source file:clases.Funciones.java
public boolean GenerateReporte_Service(JTable t_client, JTable t_vehiculos, int open, String S_solicitad, String S_realizado, JTable t_productos, String Total, String Prioridad, JComboBox client, JComboBox vehiculos, Double km) { boolean r = false; int Folio = GenerateFolioService(); if (AddService(client, vehiculos, S_solicitad, S_realizado, t_productos, Double.parseDouble(Total), "URGENTE".equals(Prioridad)) && vehiculos.getSelectedIndex() > 0) { UpdateKilometraje((String) ListVehiculos.get(vehiculos.getSelectedIndex()), km); Table_LoadClient(t_client, client); Table_LoadCar(t_vehiculos, vehiculos); Document documento = new Document(PageSize.LETTER, 10, 10, 10, 10); FileOutputStream ficheroPdf; File ruta = null;/* w w w. ja v a 2s . co m*/ com.itextpdf.text.Image imagen = null; try { imagen = com.itextpdf.text.Image.getInstance(p.ReturnPropiedad(p.Ruta_logo)); char rt = p.ReturnPropiedad(p.Ruta_SaveReports) .charAt(p.ReturnPropiedad(p.Ruta_SaveReports).length() - 1); if ("/".equalsIgnoreCase(String.valueOf(rt))) { ruta = new File(p.ReturnPropiedad(p.Ruta_SaveReports) + ReturnNombreUsuario().replace(" ", "_") + "_" + GetFechaAndHourActual().replace(" ", "_").replace(":", "_").replace("-", "_") + ".pdf"); } else { ruta = new File(p.ReturnPropiedad(p.Ruta_SaveReports) + "/" + ReturnNombreUsuario().replace(" ", "_") + "_" + GetFechaAndHourActual().replace(" ", "_").replace(":", "_").replace("-", "_") + ".pdf"); } ficheroPdf = new FileOutputStream(ruta); PdfWriter.getInstance(documento, ficheroPdf).setInitialLeading(20); } catch (DocumentException | IOException ex) { Alert("Verifique las rutas de guardado de reportes y logo."); } try { documento.open(); imagen.setAlignment(Element.ALIGN_CENTER); imagen.scaleToFit(200, 100); String membrete = "REPORTE DE SERVICIO NO: " + Folio + "\n\n"; membrete += ReturnDatosFisicos(this.Datos_Nombre) + "\n"; membrete += "DIRECCION: " + ReturnDatosFisicos(this.Datos_Direccion) + "\n"; membrete += "RFC: " + ReturnDatosFisicos(this.Datos_Rfc) + "\n"; membrete += "TELEFONO: " + ReturnDatosFisicos(this.Datos_Telefono) + "\n"; membrete += "GENERO DOCUMENTO: " + ReturnNombreUsuario() + "\n"; membrete += "GENERADO: " + GetFechaAndHourActual() + "\n"; PdfPTable HeaderDatos = new PdfPTable(2); HeaderDatos.setWidthPercentage(100); documento.add(new Paragraph("\n")); PdfPCell cell = new PdfPCell(new Phrase(membrete)); cell.setBorder(0); HeaderDatos.addCell(cell); cell = new PdfPCell(imagen); cell.setBorder(0); cell.setHorizontalAlignment(1); cell.setVerticalAlignment(1); HeaderDatos.addCell(cell); documento.add(HeaderDatos); documento.add(new Paragraph("\n")); ///////// //Tabla_Clientes String Client_header = "CLIENTE"; Paragraph Title = new Paragraph(Client_header.toUpperCase()); Title.setAlignment(1); documento.add(Title); documento.add(new Paragraph(" ")); PdfPTable tabla = new PdfPTable(t_client.getColumnCount()); tabla.setWidthPercentage(100); for (int i = 0; i < t_client.getColumnCount(); i++) { Paragraph header = new Paragraph(t_client.getColumnName(i)); header.setAlignment(1); tabla.addCell(header); } for (int i = 0; i < t_client.getRowCount(); i++) { for (int a = 0; a < t_client.getColumnCount(); a++) { Paragraph campo = new Paragraph(String.valueOf(t_client.getValueAt(i, a))); campo.setAlignment(1); tabla.addCell(campo); } } documento.add(tabla); documento.add(new Paragraph(" ")); //Tabla_Vehiculos String Vehiculos_header = "VEHICULO"; Paragraph Title1 = new Paragraph(Vehiculos_header.toUpperCase()); Title1.setAlignment(1); documento.add(Title1); documento.add(new Paragraph(" ")); PdfPTable tabla_vehiculos = new PdfPTable(t_vehiculos.getColumnCount()); tabla_vehiculos.setWidthPercentage(100); for (int i = 0; i < t_vehiculos.getColumnCount(); i++) { Paragraph header = new Paragraph(t_vehiculos.getColumnName(i)); header.setAlignment(1); tabla_vehiculos.addCell(header); } for (int i = 0; i < t_vehiculos.getRowCount(); i++) { for (int a = 0; a < t_vehiculos.getColumnCount(); a++) { Paragraph campo = new Paragraph(String.valueOf(t_vehiculos.getValueAt(i, a))); campo.setAlignment(1); tabla_vehiculos.addCell(campo); } } documento.add(tabla_vehiculos); documento.add(new Paragraph("SERVICIO SOLICITADO: " + S_solicitad.toUpperCase())); documento.add(new Paragraph("SERVICIO REALIZADO: " + S_realizado.toUpperCase())); documento.add(new Paragraph("PRIORIDAD: " + Prioridad)); //Tabla de servicios y productos String Service_header = "\nSERVICIOS Y PRODUCTOS UTILIZADOS"; Paragraph Title2 = new Paragraph(Service_header.toUpperCase()); Title2.setAlignment(1); documento.add(Title2); documento.add(new Paragraph(" ")); PdfPTable tabla_PRODUCTS = new PdfPTable(t_productos.getColumnCount()); tabla_PRODUCTS.setWidthPercentage(100); for (int i = 0; i < t_productos.getColumnCount(); i++) { Paragraph header = new Paragraph(t_productos.getColumnName(i)); header.setAlignment(1); tabla_PRODUCTS.addCell(header); } for (int i = 0; i < t_productos.getRowCount(); i++) { for (int a = 0; a < t_productos.getColumnCount(); a++) { Paragraph campo = new Paragraph(String.valueOf(t_productos.getValueAt(i, a))); campo.setAlignment(1); tabla_PRODUCTS.addCell(campo); } } documento.add(tabla_PRODUCTS); documento.add(new Paragraph("")); // documento.add(new Paragraph("COSTO TOTAL DE SERVICIO $ " + Total)); documento.add(new Paragraph( "FECHA Y HORA DE ENTREGA: ____________________________________________________")); documento.add(new Paragraph( "NOMBRE Y FIRMA DEL QUE REALIZA: _____________________________________________")); documento.add(new Paragraph( "CONFORMIDAD, NOMBRE Y FIRMA DE QUIEN RECIBE: _______________________________")); documento.add(new Paragraph( "PROXIMO SERVICIO: ___________________________________________________________")); Paragraph footer = new Paragraph("SOFTWARE Y MAS ! - WWW.CYBERCHOAPAS.COM"); footer.setAlignment(1); documento.add(footer); documento.close(); r = true; if (open > 0) { Desktop.getDesktop().open(ruta); } } catch (IOException | DocumentException ex) { Alert(ex.getMessage()); } } else { Alert("VERIFIQUE SU INFORMACION"); } return r; }
From source file:clases.Funciones.java
public void ReGenerateReporte_Service(JTable t) { int id = 0, id_cliente = 0; double total = 0; String id_vehiculo = "", s_solicitado = "", s_realizado = "", productos = ""; boolean p_urgente = false; try {//www .j ava2s . com coneccion = new Conexion(); try (ResultSet rs = coneccion.Consulta( "SELECT id, id_cliente, id_vehiculo, s_solicitado, s_realizado, productos, total, p_urgente FROM services where id = " + Integer.parseInt((String) t.getValueAt(t.getSelectedRow(), 0)) + " ")) { if (rs.next()) { id = rs.getInt(1); id_cliente = rs.getInt(2); id_vehiculo = rs.getString(3); s_solicitado = rs.getString(4); s_realizado = rs.getString(5); productos = rs.getString(6); total = rs.getDouble(7); p_urgente = rs.getBoolean(8); } } } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | SQLException ex) { Alert(ex.getMessage()); } int Folio = id; JTable t_client = new JTable(); JTable t_vehiculos = new JTable(); Table_LoadClient(t_client, id_cliente); Table_LoadCar(t_vehiculos, id_vehiculo); Document documento = new Document(PageSize.LETTER, 10, 10, 10, 10); FileOutputStream ficheroPdf; File ruta = null; com.itextpdf.text.Image imagen = null; try { imagen = com.itextpdf.text.Image.getInstance(p.ReturnPropiedad(p.Ruta_logo)); char rt = p.ReturnPropiedad(p.Ruta_SaveReports) .charAt(p.ReturnPropiedad(p.Ruta_SaveReports).length() - 1); if ("/".equalsIgnoreCase(String.valueOf(rt))) { ruta = new File(p.ReturnPropiedad(p.Ruta_SaveReports) + ReturnNombreUsuario().replace(" ", "_") + "_" + GetFechaAndHourActual().replace(" ", "_").replace(":", "_").replace("-", "_") + ".pdf"); } else { ruta = new File(p.ReturnPropiedad(p.Ruta_SaveReports) + "/" + ReturnNombreUsuario().replace(" ", "_") + "_" + GetFechaAndHourActual().replace(" ", "_").replace(":", "_").replace("-", "_") + ".pdf"); } ficheroPdf = new FileOutputStream(ruta); PdfWriter.getInstance(documento, ficheroPdf).setInitialLeading(20); } catch (DocumentException | IOException ex) { Alert("Verifique las rutas de guardado de reportes y logo."); } try { documento.open(); imagen.setAlignment(Element.ALIGN_CENTER); imagen.scaleToFit(200, 100); String membrete = "REPORTE DE SERVICIO NO: " + Folio + "\n\n"; membrete += ReturnDatosFisicos(this.Datos_Nombre) + "\n"; membrete += "DIRECCION: " + ReturnDatosFisicos(this.Datos_Direccion) + "\n"; membrete += "RFC: " + ReturnDatosFisicos(this.Datos_Rfc) + "\n"; membrete += "TELEFONO: " + ReturnDatosFisicos(this.Datos_Telefono) + "\n"; membrete += "GENERO DOCUMENTO: " + ReturnNombreUsuario() + "\n"; membrete += "GENERADO: " + GetFechaAndHourActual() + "\n"; PdfPTable HeaderDatos = new PdfPTable(2); HeaderDatos.setWidthPercentage(100); documento.add(new Paragraph("\n")); PdfPCell cell = new PdfPCell(new Phrase(membrete)); cell.setBorder(0); HeaderDatos.addCell(cell); cell = new PdfPCell(imagen); cell.setBorder(0); cell.setHorizontalAlignment(1); cell.setVerticalAlignment(1); HeaderDatos.addCell(cell); documento.add(HeaderDatos); documento.add(new Paragraph("\n")); ///////// //Tabla_Clientes String Client_header = "CLIENTE"; Paragraph Title = new Paragraph(Client_header.toUpperCase()); Title.setAlignment(1); documento.add(Title); documento.add(new Paragraph(" ")); PdfPTable tabla = new PdfPTable(t_client.getColumnCount()); tabla.setWidthPercentage(100); for (int i = 0; i < t_client.getColumnCount(); i++) { Paragraph header = new Paragraph(t_client.getColumnName(i)); header.setAlignment(1); tabla.addCell(header); } for (int i = 0; i < t_client.getRowCount(); i++) { for (int a = 0; a < t_client.getColumnCount(); a++) { Paragraph campo = new Paragraph(String.valueOf(t_client.getValueAt(i, a))); campo.setAlignment(1); tabla.addCell(campo); } } documento.add(tabla); documento.add(new Paragraph(" ")); //Tabla_Vehiculos String Vehiculos_header = "VEHICULO"; Paragraph Title1 = new Paragraph(Vehiculos_header.toUpperCase()); Title1.setAlignment(1); documento.add(Title1); documento.add(new Paragraph(" ")); PdfPTable tabla_vehiculos = new PdfPTable(t_vehiculos.getColumnCount()); tabla_vehiculos.setWidthPercentage(100); for (int i = 0; i < t_vehiculos.getColumnCount(); i++) { Paragraph header = new Paragraph(t_vehiculos.getColumnName(i)); header.setAlignment(1); tabla_vehiculos.addCell(header); } for (int i = 0; i < t_vehiculos.getRowCount(); i++) { for (int a = 0; a < t_vehiculos.getColumnCount(); a++) { Paragraph campo = new Paragraph(String.valueOf(t_vehiculos.getValueAt(i, a))); campo.setAlignment(1); tabla_vehiculos.addCell(campo); } } documento.add(tabla_vehiculos); documento.add(new Paragraph("SERVICIO SOLICITADO: " + s_solicitado.toUpperCase())); documento.add(new Paragraph("SERVICIO REALIZADO: " + s_realizado.toUpperCase())); String var = ""; if (p_urgente) { var = "URGENTE"; } else { var = "PROGRAMAR"; } documento.add(new Paragraph("PRIORIDAD: " + var)); //Tabla de servicios y productos String Service_header = "\nSERVICIOS Y PRODUCTOS UTILIZADOS"; Paragraph Title2 = new Paragraph(Service_header.toUpperCase()); Title2.setAlignment(1); documento.add(Title2); documento.add(new Paragraph(" ")); JTable t_productos = new JTable(); Table_LoadProductsServicio(t_productos); String[] result = productos.replace("+", ",").split(","); if (result.length >= 1) { for (String r : result) { if (!r.equalsIgnoreCase("") || !r.isEmpty()) { if (ExistProduct(r)) { Table_AddProductsServicio(t_productos, r); } } } } PdfPTable tabla_PRODUCTS = new PdfPTable(t_productos.getColumnCount()); tabla_PRODUCTS.setWidthPercentage(100); for (int i = 0; i < t_productos.getColumnCount(); i++) { Paragraph header = new Paragraph(t_productos.getColumnName(i)); header.setAlignment(1); tabla_PRODUCTS.addCell(header); } for (int i = 0; i < t_productos.getRowCount(); i++) { for (int a = 0; a < t_productos.getColumnCount(); a++) { Paragraph campo = new Paragraph(String.valueOf(t_productos.getValueAt(i, a))); campo.setAlignment(1); tabla_PRODUCTS.addCell(campo); } } documento.add(tabla_PRODUCTS); documento.add(new Paragraph("")); // documento.add(new Paragraph("COSTO TOTAL DE SERVICIO $ " + total)); documento.add( new Paragraph("FECHA Y HORA DE ENTREGA: ____________________________________________________")); documento.add( new Paragraph("NOMBRE Y FIRMA DEL QUE REALIZA: _____________________________________________")); documento.add( new Paragraph("CONFORMIDAD, NOMBRE Y FIRMA DE QUIEN RECIBE: _______________________________")); documento.add( new Paragraph("PROXIMO SERVICIO: ___________________________________________________________")); Paragraph footer = new Paragraph("SOFTWARE Y MAS ! - WWW.CYBERCHOAPAS.COM"); footer.setAlignment(1); documento.add(footer); documento.close(); Desktop.getDesktop().open(ruta); } catch (IOException | DocumentException ex) { Alert(ex.getMessage()); } catch (ClassNotFoundException | SQLException | InstantiationException | IllegalAccessException ex) { Alert(ex.getMessage()); } }
From source file:clases.Funciones.java
public void ReGenerateReporte_Service(int id_service) { int id = 0, id_cliente = 0; double total = 0; String id_vehiculo = "", s_solicitado = "", s_realizado = "", productos = ""; boolean p_urgente = false; try {//from w ww .jav a2s .c o m coneccion = new Conexion(); try (ResultSet rs = coneccion.Consulta( "SELECT id, id_cliente, id_vehiculo, s_solicitado, s_realizado, productos, total, p_urgente FROM services where id = " + id_service + " ")) { if (rs.next()) { id = rs.getInt(1); id_cliente = rs.getInt(2); id_vehiculo = rs.getString(3); s_solicitado = rs.getString(4); s_realizado = rs.getString(5); productos = rs.getString(6); total = rs.getDouble(7); p_urgente = rs.getBoolean(8); } } } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | SQLException ex) { Alert(ex.getMessage()); } int Folio = id; JTable t_client = new JTable(); JTable t_vehiculos = new JTable(); Table_LoadClient(t_client, id_cliente); Table_LoadCar(t_vehiculos, id_vehiculo); Document documento = new Document(PageSize.LETTER, 10, 10, 10, 10); FileOutputStream ficheroPdf; File ruta = null; com.itextpdf.text.Image imagen = null; try { imagen = com.itextpdf.text.Image.getInstance(p.ReturnPropiedad(p.Ruta_logo)); char rt = p.ReturnPropiedad(p.Ruta_SaveReports) .charAt(p.ReturnPropiedad(p.Ruta_SaveReports).length() - 1); if ("/".equalsIgnoreCase(String.valueOf(rt))) { ruta = new File(p.ReturnPropiedad(p.Ruta_SaveReports) + ReturnNombreUsuario().replace(" ", "_") + "_" + GetFechaAndHourActual().replace(" ", "_").replace(":", "_").replace("-", "_") + ".pdf"); } else { ruta = new File(p.ReturnPropiedad(p.Ruta_SaveReports) + "/" + ReturnNombreUsuario().replace(" ", "_") + "_" + GetFechaAndHourActual().replace(" ", "_").replace(":", "_").replace("-", "_") + ".pdf"); } ficheroPdf = new FileOutputStream(ruta); PdfWriter.getInstance(documento, ficheroPdf).setInitialLeading(20); } catch (DocumentException | IOException ex) { Alert("Verifique las rutas de guardado de reportes y logo."); } try { documento.open(); imagen.setAlignment(Element.ALIGN_CENTER); imagen.scaleToFit(200, 100); String membrete = "REPORTE DE SERVICIO NO: " + Folio + "\n\n"; membrete += ReturnDatosFisicos(this.Datos_Nombre) + "\n"; membrete += "DIRECCION: " + ReturnDatosFisicos(this.Datos_Direccion) + "\n"; membrete += "RFC: " + ReturnDatosFisicos(this.Datos_Rfc) + "\n"; membrete += "TELEFONO: " + ReturnDatosFisicos(this.Datos_Telefono) + "\n"; membrete += "GENERO DOCUMENTO: " + ReturnNombreUsuario() + "\n"; membrete += "GENERADO: " + GetFechaAndHourActual() + "\n"; PdfPTable HeaderDatos = new PdfPTable(2); HeaderDatos.setWidthPercentage(100); documento.add(new Paragraph("\n")); PdfPCell cell = new PdfPCell(new Phrase(membrete)); cell.setBorder(0); HeaderDatos.addCell(cell); cell = new PdfPCell(imagen); cell.setBorder(0); cell.setHorizontalAlignment(1); cell.setVerticalAlignment(1); HeaderDatos.addCell(cell); documento.add(HeaderDatos); documento.add(new Paragraph("\n")); ///////// //Tabla_Clientes String Client_header = "CLIENTE"; Paragraph Title = new Paragraph(Client_header.toUpperCase()); Title.setAlignment(1); documento.add(Title); documento.add(new Paragraph(" ")); PdfPTable tabla = new PdfPTable(t_client.getColumnCount()); tabla.setWidthPercentage(100); for (int i = 0; i < t_client.getColumnCount(); i++) { Paragraph header = new Paragraph(t_client.getColumnName(i)); header.setAlignment(1); tabla.addCell(header); } for (int i = 0; i < t_client.getRowCount(); i++) { for (int a = 0; a < t_client.getColumnCount(); a++) { Paragraph campo = new Paragraph(String.valueOf(t_client.getValueAt(i, a))); campo.setAlignment(1); tabla.addCell(campo); } } documento.add(tabla); documento.add(new Paragraph(" ")); //Tabla_Vehiculos String Vehiculos_header = "VEHICULO"; Paragraph Title1 = new Paragraph(Vehiculos_header.toUpperCase()); Title1.setAlignment(1); documento.add(Title1); documento.add(new Paragraph(" ")); PdfPTable tabla_vehiculos = new PdfPTable(t_vehiculos.getColumnCount()); tabla_vehiculos.setWidthPercentage(100); for (int i = 0; i < t_vehiculos.getColumnCount(); i++) { Paragraph header = new Paragraph(t_vehiculos.getColumnName(i)); header.setAlignment(1); tabla_vehiculos.addCell(header); } for (int i = 0; i < t_vehiculos.getRowCount(); i++) { for (int a = 0; a < t_vehiculos.getColumnCount(); a++) { Paragraph campo = new Paragraph(String.valueOf(t_vehiculos.getValueAt(i, a))); campo.setAlignment(1); tabla_vehiculos.addCell(campo); } } documento.add(tabla_vehiculos); documento.add(new Paragraph("SERVICIO SOLICITADO: " + s_solicitado.toUpperCase())); documento.add(new Paragraph("SERVICIO REALIZADO: " + s_realizado.toUpperCase())); String var = ""; if (p_urgente) { var = "URGENTE"; } else { var = "PROGRAMAR"; } documento.add(new Paragraph("PRIORIDAD: " + var)); //Tabla de servicios y productos String Service_header = "\nSERVICIOS Y PRODUCTOS UTILIZADOS"; Paragraph Title2 = new Paragraph(Service_header.toUpperCase()); Title2.setAlignment(1); documento.add(Title2); documento.add(new Paragraph(" ")); JTable t_productos = new JTable(); Table_LoadProductsServicio(t_productos); String[] result = productos.replace("+", ",").split(","); if (result.length >= 1) { for (String r : result) { if (!r.equalsIgnoreCase("") || !r.isEmpty()) { if (ExistProduct(r)) { Table_AddProductsServicio(t_productos, r); } } } } PdfPTable tabla_PRODUCTS = new PdfPTable(t_productos.getColumnCount()); tabla_PRODUCTS.setWidthPercentage(100); for (int i = 0; i < t_productos.getColumnCount(); i++) { Paragraph header = new Paragraph(t_productos.getColumnName(i)); header.setAlignment(1); tabla_PRODUCTS.addCell(header); } for (int i = 0; i < t_productos.getRowCount(); i++) { for (int a = 0; a < t_productos.getColumnCount(); a++) { Paragraph campo = new Paragraph(String.valueOf(t_productos.getValueAt(i, a))); campo.setAlignment(1); tabla_PRODUCTS.addCell(campo); } } documento.add(tabla_PRODUCTS); documento.add(new Paragraph("")); // documento.add(new Paragraph("COSTO TOTAL DE SERVICIO $ " + total)); documento.add( new Paragraph("FECHA Y HORA DE ENTREGA: ____________________________________________________")); documento.add( new Paragraph("NOMBRE Y FIRMA DEL QUE REALIZA: _____________________________________________")); documento.add( new Paragraph("CONFORMIDAD, NOMBRE Y FIRMA DE QUIEN RECIBE: _______________________________")); documento.add( new Paragraph("PROXIMO SERVICIO: ___________________________________________________________")); Paragraph footer = new Paragraph("SOFTWARE Y MAS ! - WWW.CYBERCHOAPAS.COM"); footer.setAlignment(1); documento.add(footer); documento.close(); Desktop.getDesktop().open(ruta); } catch (IOException | DocumentException ex) { Alert(ex.getMessage()); } catch (ClassNotFoundException | SQLException | InstantiationException | IllegalAccessException ex) { Alert(ex.getMessage()); } }
From source file:classes.utils.crearPDF_Depreciacion.java
public String writePDF(String datos, Scene scene) throws FileNotFoundException, DocumentException, BadElementException, IOException { javafx.scene.control.TextField projectName = (TextField) scene.lookup(CNodeID.TEXTFIELD_PROJECT_NAME); String project = projectName.getText(); StringTokenizer st = new StringTokenizer(datos, "_"); principal = st.nextToken();//from www . j a v a2 s .c o m salvageV = st.nextToken(); period = st.nextToken(); tax = st.nextToken(); periodSalvage = st.nextToken(); category = st.nextToken(); data = st.nextToken(); Document document = new Document(PageSize.LETTER, 80, 80, 50, 50); FileOutputStream salida = new FileOutputStream(project + "_depreciation.pdf"); PdfWriter writer = PdfWriter.getInstance(document, salida); writer.setInitialLeading(0); Paragraph paragraph = new Paragraph(); paragraph.setFont(new Font(FontFactory.getFont("Courier", 20, Font.BOLDITALIC, BaseColor.RED))); paragraph.add("\n\n\nDEPRECIACION"); paragraph.setAlignment(Paragraph.ALIGN_CENTER); //System.out.println(getClass().getResource("images/logo_report.png")); //Image image = Image.getInstance("/home/isaac/IdeaProjects/ProjectEvaluation/src/images/logo_report.png"); //image.scaleToFit(150, 150); Image image1 = Image.getInstance(project + "/" + project + "_DEP_TY.png"); image1.scaleToFit(300, 300); //image.setAlignment(Chunk.ALIGN_RIGHT); image1.setAlignment(Chunk.ALIGN_CENTER); Paragraph paragraph_2 = new Paragraph(); paragraph_2.setFont(new Font(FontFactory.getFont("Courier", 12, Font.BOLD, BaseColor.BLUE))); paragraph_2.add( "\n\n\n\n\n\n\n\n\n\n\nADMINISTRACION Y EVALUACION DE PROYECTOS\n\n SERGIO VALDES TORRES A01365520\n ERIK MARTIN A01365096\nISAAC SECUNDINO A01361162\n IVAN CABRER A01184937"); paragraph_2.setAlignment(Paragraph.ALIGN_RIGHT); Paragraph paragraph_3 = new Paragraph(); paragraph_3.setFont(new Font(FontFactory.getFont("Courier", 11, Font.BOLD, BaseColor.BLACK))); paragraph_3.add("\n " + data); paragraph_3.setAlignment(Paragraph.ALIGN_LEFT); Paragraph paragraph_5 = new Paragraph(); paragraph_5.setFont(new Font(FontFactory.getFont("Courier", 6, Font.BOLD, BaseColor.BLUE))); paragraph_5.add("\n\nP DEPRECIATON RATE ANNUAL DEPRECIATON CUMMULATIVE DEPRECIATON VALUE IN LEDGERS "); paragraph_5.setAlignment(Paragraph.ALIGN_LEFT); Paragraph paragraph_4 = new Paragraph(); paragraph_4.setFont(new Font(FontFactory.getFont("Courier", 9, Font.BOLD, BaseColor.BLACK))); paragraph_4.add("Nombre del Evaluador: \n Principal: " + principal + " \n Salvag Value: " + salvageV + " \n Numero de Periodos: " + period + "\n Tax: " + tax + " \n Salvage Period: " + periodSalvage + "\n Categoria: " + category); paragraph_4.setAlignment(Paragraph.ALIGN_LEFT); Paragraph paragraph_6 = new Paragraph(); paragraph_6.setFont(new Font(FontFactory.getFont("Courier", 15, Font.BOLD, BaseColor.GRAY))); paragraph_6.add("\n GRAFICAS\n"); paragraph_6.setAlignment(Paragraph.ALIGN_CENTER); document.open(); //document.add(image); document.add(paragraph); document.add(paragraph_4); document.add(paragraph_5); document.add(paragraph_3); document.add(paragraph_6); Image image2 = Image.getInstance(project + "/" + project + "_DEP_DR.png"); Image image3 = Image.getInstance(project + "/" + project + "_DEP_AD.png"); Image image4 = Image.getInstance(project + "/" + project + "_DEP_ACD.png"); Image image5 = Image.getInstance(project + "/" + project + "_DEP_LV.png"); document.add(image2); document.add(image3); document.add(image4); document.add(image5); document.add(image1); document.add(paragraph_2); document.close(); return null; }
From source file:classes.utils.createPDF_checkList.java
public String writePDF(Scene scene, String datos) throws FileNotFoundException, DocumentException, BadElementException, IOException { javafx.scene.control.TextField projectName = (javafx.scene.control.TextField) scene .lookup(CNodeID.TEXTFIELD_PROJECT_NAME); String project = projectName.getText(); StringTokenizer st = new StringTokenizer(datos, "*"); dato1 = st.nextToken();/*from ww w . j av a 2 s .c o m*/ dato2 = st.nextToken(); dato3 = st.nextToken(); dato4 = st.nextToken(); dato5 = st.nextToken(); dato6 = st.nextToken(); dato7 = st.nextToken(); dato8 = st.nextToken(); dato9 = st.nextToken(); dato10 = st.nextToken(); dato11 = st.nextToken(); dato12 = st.nextToken(); dato13 = st.nextToken(); dato14 = st.nextToken(); dato15 = st.nextToken(); dato16 = st.nextToken(); dato17 = st.nextToken(); Document document = new Document(PageSize.LETTER, 80, 80, 50, 50); FileOutputStream salida = new FileOutputStream(project + "_CheckList.pdf"); PdfWriter writer = PdfWriter.getInstance(document, salida); writer.setInitialLeading(0); Paragraph paragraph = new Paragraph(); paragraph.setFont(new Font(FontFactory.getFont("Courier", 20, Font.BOLDITALIC, BaseColor.RED))); paragraph.add("\n\n\nCHECK LIST"); paragraph.setAlignment(Paragraph.ALIGN_CENTER); //Image image = Image.getInstance("/home/isaac/IdeaProjects/ProjectEvaluation/src/images/logo_report.png"); //image.scaleToFit(150, 150); //image.setAlignment(Chunk.ALIGN_RIGHT); Paragraph paragraph_2 = new Paragraph(); paragraph_2.setFont(new Font(FontFactory.getFont("Courier", 12, Font.BOLD, BaseColor.BLUE))); paragraph_2.add( "\n\n\n\n\n\n\nADMINISTRACION Y EVALUACION DE PROYECTOS\n\n SERGIO VALDES TORRES A01365520\n ERIK MARTIN A01365096\nISAAC SECUNDINO A01361162\n IVAN CABRER A01184937"); paragraph_2.setAlignment(Paragraph.ALIGN_RIGHT); Paragraph paragraph_4 = new Paragraph(); paragraph_4.setFont(new Font(FontFactory.getFont("Courier", 6, Font.BOLD, BaseColor.BLACK))); paragraph_4.add("Strategy---Alignment What specific organization strategy does this project align with?" + " " + dato1 + "\n" + "Driver---What business problem does the project solve?" + " " + dato2 + "\n" + "Success Metrics---How will measure success?" + " " + dato3 + "\n" + "Sponsorship---Who is the project sponsor?" + " " + dato4 + "\n" + "Risk---What is the impact of not doing this project?" + " " + dato5 + "\n" + "Risk---What is the project risk to our organization?" + " " + dato6 + "\n" + "Risk---Where does the proposed project fit in our risk profile?" + " " + dato7 + "\n" + "Benefits, value---What is the value of the project organization?" + " " + dato8 + "\n" + "Benefits, value---When will the project shows results?" + " " + dato9 + "\n" + "Objectives---What are the project objectives?" + " " + dato10 + "\n" + "Organization Culture---Is our organization culture right for this type of project?" + " " + dato11 + "\n" + "Resources---Will internal resources be available for this project?" + " " + dato12 + "\n" + "Approach---Will we build or buy?" + " " + dato13 + "\n" + "Schedule---How long will this project take?" + " " + dato14 + "\n" + "Schedule---Is the timeline realistic?" + " " + dato15 + "\n" + "Training/Resources---Will staff training be required?" + " " + dato16 + "\n" + "Finance/Portfolio---What is the estimated cost of the project?" + " " + dato17 + "\n"); /*+ "Portfolio---Is this a new initiative or path of an existing initiative?"+" "+dato18+"\n" + "Portfolio---How does this project interact with current projects?"+" "+dato19+"\n" + "Technology---Is the technology available or new?"+" "+dato20+""); */ paragraph_4.setAlignment(Paragraph.ALIGN_LEFT); document.open(); //document.add(image); document.add(paragraph); document.add(paragraph_4); document.add(paragraph_2); document.close(); return "pdf Creado"; }
From source file:classes.utils.createPDF_NetPresent.java
public String writePDF(Scene scene, String datos) throws FileNotFoundException, DocumentException, BadElementException, IOException { javafx.scene.control.TextField projectName = (javafx.scene.control.TextField) scene .lookup(CNodeID.TEXTFIELD_PROJECT_NAME); String project = projectName.getText(); StringTokenizer st = new StringTokenizer(datos, "_"); period = st.nextToken();// w ww . java2s . c o m principal = st.nextToken(); interestRate = st.nextToken(); tax = st.nextToken(); salvageV = st.nextToken(); periodSalvage = st.nextToken(); data = st.nextToken(); Document document = new Document(PageSize.LETTER, 80, 80, 50, 50); FileOutputStream salida = new FileOutputStream(project + "_NetPresentValue.pdf"); PdfWriter writer = PdfWriter.getInstance(document, salida); writer.setInitialLeading(0); Paragraph paragraph = new Paragraph(); paragraph.setFont(new Font(FontFactory.getFont("Courier", 20, Font.BOLDITALIC, BaseColor.RED))); paragraph.add("\n\n\nNET PRESENT VALUE"); paragraph.setAlignment(Paragraph.ALIGN_CENTER); //Image image = Image.getInstance("/home/isaac/IdeaProjects/ProjectEvaluation/src/images/logo_report.png"); //image.scaleToFit(150, 150); Image image1 = Image.getInstance(project + "/" + project + "_NPV_CCF.png"); image1.scaleToFit(300, 300); //image.setAlignment(Chunk.ALIGN_RIGHT); image1.setAlignment(Chunk.ALIGN_CENTER); Paragraph paragraph_2 = new Paragraph(); paragraph_2.setFont(new Font(FontFactory.getFont("Courier", 12, Font.BOLD, BaseColor.BLUE))); paragraph_2.add( "\n\n\n\n\n\n\n\n\n\n\nADMINISTRACION Y EVALUACION DE PROYECTOS\n\n SERGIO VALDES TORRES A01365520\n ERIK MARTIN A01365096\nISAAC SECUNDINO A01361162\n IVAN CABRER A01184937"); paragraph_2.setAlignment(Paragraph.ALIGN_RIGHT); Paragraph paragraph_3 = new Paragraph(); paragraph_3.setFont(new Font(FontFactory.getFont("Courier", 11, Font.BOLD, BaseColor.BLACK))); paragraph_3.add("\n " + data); paragraph_3.setAlignment(Paragraph.ALIGN_LEFT); Paragraph paragraph_5 = new Paragraph(); paragraph_5.setFont(new Font(FontFactory.getFont("Courier", 10, Font.BOLD, BaseColor.BLUE))); paragraph_5.add("\n\nP OUTFLOW INFLOW NET CASH FLOW CUMULATIVE CASH "); paragraph_5.setAlignment(Paragraph.ALIGN_LEFT); Paragraph paragraph_4 = new Paragraph(); paragraph_4.setFont(new Font(FontFactory.getFont("Courier", 9, Font.BOLD, BaseColor.BLACK))); paragraph_4.add("Nombre del Evaluador: \nPeriods: " + period + "\n Principal: " + principal + " \n Interest Rate%: " + interestRate + " \n Tax Rate %: " + tax + "\n Salvage Value: " + salvageV + " \n Period SV: " + periodSalvage); paragraph_4.setAlignment(Paragraph.ALIGN_LEFT); Paragraph paragraph_6 = new Paragraph(); paragraph_6.setFont(new Font(FontFactory.getFont("Courier", 15, Font.BOLD, BaseColor.GRAY))); paragraph_6.add("\n GRAFICAS\n"); paragraph_6.setAlignment(Paragraph.ALIGN_CENTER); document.open(); //document.add(image); document.add(paragraph); document.add(paragraph_4); document.add(paragraph_5); document.add(paragraph_3); document.add(paragraph_6); document.add(image1); Image image2 = Image.getInstance(project + "/" + project + "_NPV_NCF.png"); document.add(image2); document.add(paragraph_2); document.close(); return null; }