List of usage examples for com.itextpdf.text Document close
boolean close
To view the source code for com.itextpdf.text Document close.
Click Source Link
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 {/*w w w . ja v a 2 s .c om*/ 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:Clases.NuevoPdf.java
public static void main() { try {/*from w w w . j a v a 2 s . c o m*/ /*Espaciador*/ Paragraph espaciador = new Paragraph(); addEmptyLine(espaciador, 2); /** * */ Document document = new Document(); if (Variables.guardar == false) { PdfWriter.getInstance(document, new FileOutputStream(FILE)); } else { JFileChooser dig = new JFileChooser(); int opcion = dig.showSaveDialog(null); if (opcion == JFileChooser.APPROVE_OPTION) { File f = dig.getSelectedFile(); String Direccion = f.toString(); FileOutputStream archivo = new FileOutputStream(Direccion + ".pdf"); PdfWriter.getInstance(document, archivo); Variables.guardar = false; } } //Document document = new Document(); // PdfWriter.getInstance(document, new FileOutputStream(FILE)); document.open(); addMetaData(document); addTitlePage(document); document.add(espaciador); addTableClienteYFactura(document); document.add(espaciador); addTableProducts(document); document.add(espaciador); addTableTotales(document); addFooter(document); document.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:Clases.PDF.java
public void crearPDF(String filename, String nombre, String objetosComprados) throws DocumentException, IOException { // step 1//w ww . ja v a 2 s. co m Document document = new Document(); // step 2 PdfWriter.getInstance(document, new FileOutputStream(filename)); // step 3 document.open(); // step 4 /* Image image1 = Image.getInstance("/Users/davfer29/NetBeansProjects/DiarioFacilWeb/build/web/images/client.png"); document.add(image1); image1.scaleAbsolute(150f, 150f);*/ //esto se usa para adjuntar imagenes al pdf y centrarlas document.addTitle("Bienvenido a DiarioFacil"); document.add(new Paragraph("Su compra de los articulos " + objetosComprados + " ha sido exitosa")); document.add(new Paragraph("Gracias! Agradecemos que haya elegido nuestra pagina " + nombre)); // step 5 document.close(); }
From source file:Classes.GerarPdf.java
public static void main(String arg[]) throws Exception { File arquivo = new File("odontograma.pdf"); System.out.print(arquivo.getAbsolutePath()); File file = new File(arquivo.getAbsolutePath()); file.delete();// w w w.jav a2s .com Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream("odontograma.pdf")); document.open(); document.add(new Paragraph("ODONTOGRAMA")); document.add(new Paragraph("\nCodigo Paciente: " + arg[0])); document.add(new Paragraph("Nome Paciente: " + arg[1])); document.add(new Paragraph("Codigo Procedimento: " + arg[2])); document.add(new Paragraph("Procedimento: " + arg[3])); document.add(new Paragraph("\nDetalhes : " + arg[4])); document.add(new Paragraph("\nValor : " + arg[5])); document.close(); }
From source file:classes.PdfFiles.java
public static void createPdf(java.util.List<Product> selling_list) { try {/*w w w . j a v a2s .co m*/ /*Create new document*/ Document document = new Document(); /*Path and name based on date*/ String FILE = "C:/Users/Dominik/Computer-Service-ERP/Pliki PDF/Faktura - " + new Date().toString().substring(4, 11) + new Date().toString().substring(25) + '-' + new Date().toString().substring(11, 13) + new Date().toString().substring(14, 16) + new Date().toString().substring(17, 19) + ".pdf"; /*Open file*/ PdfWriter.getInstance(document, new FileOutputStream(FILE)); document.open(); /*Title*/ addTitlePage(document); /*Table*/ createTable(document, selling_list); /*Closing*/ document.close(); } catch (Exception e) { e.printStackTrace(); } }
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 w w w . j a v a 2s . 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 w w w . ja v a 2 s . com*/ 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();//from w w w . j a va2 s. c om 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; }
From source file:classes.utils.createPDF_PayBack.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. j av a 2 s . com principal = st.nextToken(); interestRate = st.nextToken(); data = st.nextToken(); Document document = new Document(PageSize.LETTER, 80, 80, 50, 50); FileOutputStream salida = new FileOutputStream(project + "_PayBackPeriod.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\nPAYBACK PERIOD"); paragraph.setAlignment(Paragraph.ALIGN_CENTER); // TODO: Change absolute to relative //Image image = Image.getInstance("/home/isaac/IdeaProjects/ProjectEvaluation/src/images/logo_report.png"); //image.scaleToFit(150, 150); Image image1 = Image.getInstance(project + "/" + project + "_PBP_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 CUMMULATIVE 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: \n Principal: " + principal + " \n Numero de Periodos: " + period + "\nInterest Rate %" + interestRate); 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 + "_PBP_NCF.png"); document.add(image1); document.add(image2); document.add(paragraph_2); document.close(); return null; }
From source file:client.tools.ClientTool.java
public static void enregistrer(String url, String titre, ArrayList<String> cont) { try {//w w w . j av a 2s . co m Document document = new Document(); FileOutputStream fos = new FileOutputStream( url + System.getProperty("file.separator") + titre + ".pdf"); PdfWriter.getInstance(document, fos); document.open(); document.addTitle(titre); document.addCreationDate(); int i = 0; for (String str : cont) { if (i == 0) { document.add(new Paragraph(str, new Font(Font.FontFamily.HELVETICA, 25, Font.UNDERLINE))); document.add(new Paragraph(" ", new Font(Font.FontFamily.HELVETICA, 25))); } else { document.add(new Paragraph(str, new Font(Font.FontFamily.HELVETICA, 18))); } i++; } document.close(); } catch (Exception e) { System.out.println(e.getMessage()); } }