List of usage examples for com.itextpdf.text Font BOLDITALIC
int BOLDITALIC
To view the source code for com.itextpdf.text Font BOLDITALIC.
Click Source Link
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();// w ww . j a va2s . 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 . j av a2s . co 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();//from w w w. jav a 2s .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();/*from w w w .ja v a 2s . c o m*/ 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:com.dexter.fms.mbean.ReportsMBean.java
@SuppressWarnings("deprecation") private PdfPTable exportPDFTable(int type) { int numberOfColumns = 0; PdfPTable pdfTable = null;//w w w . j a va2 s. c om switch (type) { case 1: // all users report { numberOfColumns = 7; pdfTable = new PdfPTable(numberOfColumns); BaseFont helvetica = null; try { helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED); } catch (Exception e) { } Font font = new Font(helvetica, 8, Font.BOLDITALIC); pdfTable.addCell(new Paragraph("User name", font)); pdfTable.addCell(new Paragraph("Full name", font)); pdfTable.addCell(new Paragraph("Email", font)); pdfTable.addCell(new Paragraph("Department", font)); pdfTable.addCell(new Paragraph("Region", font)); pdfTable.addCell(new Paragraph("Phone", font)); pdfTable.addCell(new Paragraph("Position", font)); font = new Font(helvetica, 8, Font.NORMAL); if (getAllUsers() != null) { for (PartnerUser e : getAllUsers()) { pdfTable.addCell(new Paragraph(e.getUsername(), font)); pdfTable.addCell(new Paragraph( e.getPersonel().getFirstname() + " " + e.getPersonel().getLastname(), font)); pdfTable.addCell(new Paragraph(e.getPersonel().getEmail(), font)); pdfTable.addCell(new Paragraph( (e.getPersonel().getDepartment() != null) ? e.getPersonel().getDepartment().getName() : "N/A", font)); pdfTable.addCell(new Paragraph( (e.getPersonel().getRegion() != null) ? e.getPersonel().getRegion().getName() : "N/A", font)); pdfTable.addCell(new Paragraph(e.getPersonel().getPhone(), font)); pdfTable.addCell(new Paragraph(e.getPersonel().getPosition(), font)); } } break; } case 2: // due driver's license { numberOfColumns = 6; pdfTable = new PdfPTable(numberOfColumns); BaseFont helvetica = null; try { helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED); } catch (Exception e) { } Font font = new Font(helvetica, 8, Font.BOLDITALIC); pdfTable.addCell(new Paragraph("Full Name", font)); pdfTable.addCell(new Paragraph("Dept", font)); pdfTable.addCell(new Paragraph("Region", font)); pdfTable.addCell(new Paragraph("Phone", font)); pdfTable.addCell(new Paragraph("Position", font)); pdfTable.addCell(new Paragraph("License Due Date", font)); font = new Font(helvetica, 8, Font.NORMAL); if (getDueDriversLic() != null) { for (DriverLicense e : getDueDriversLic()) { pdfTable.addCell(new Paragraph(e.getDriver().getPersonel().getFirstname() + " " + e.getDriver().getPersonel().getLastname(), font)); pdfTable.addCell(new Paragraph(e.getDriver().getPersonel().getDepartment() != null ? e.getDriver().getPersonel().getDepartment().getName() : "N/A", font)); pdfTable.addCell(new Paragraph(e.getDriver().getPersonel().getRegion() != null ? e.getDriver().getPersonel().getRegion().getName() : "N/A", font)); pdfTable.addCell(new Paragraph(e.getDriver().getPersonel().getPhone(), font)); pdfTable.addCell(new Paragraph(e.getDriver().getPersonel().getPosition(), font)); pdfTable.addCell(new Paragraph(e.getLic_end_dt().toLocaleString(), font)); } } break; } case 3: // accidents { numberOfColumns = 8; pdfTable = new PdfPTable(numberOfColumns); BaseFont helvetica = null; try { helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED); } catch (Exception e) { } Font font = new Font(helvetica, 8, Font.BOLDITALIC); pdfTable.addCell(new Paragraph("Reg No.", font)); pdfTable.addCell(new Paragraph("Accident Date", font)); pdfTable.addCell(new Paragraph("Description", font)); pdfTable.addCell(new Paragraph("Driver", font)); pdfTable.addCell(new Paragraph("Driver Comment", font)); pdfTable.addCell(new Paragraph("Police Officer", font)); pdfTable.addCell(new Paragraph("Police Station", font)); pdfTable.addCell(new Paragraph("Police Comment", font)); font = new Font(helvetica, 8, Font.NORMAL); if (getVehicleAccidents() != null) { for (VehicleAccident e : getVehicleAccidents()) { pdfTable.addCell(new Paragraph(e.getVehicle().getRegistrationNo(), font)); pdfTable.addCell(new Paragraph(e.getAccident_dt().toLocaleString(), font)); pdfTable.addCell(new Paragraph(e.getAccidentDescription(), font)); pdfTable.addCell(new Paragraph(e.getDriver_name(), font)); pdfTable.addCell(new Paragraph(e.getDriverComment(), font)); pdfTable.addCell(new Paragraph(e.getPoliceOfficer(), font)); pdfTable.addCell(new Paragraph(e.getPoliceStation(), font)); pdfTable.addCell(new Paragraph(e.getPoliceComment(), font)); } } break; } case 4: // vehicles by brand { numberOfColumns = 4; pdfTable = new PdfPTable(numberOfColumns); BaseFont helvetica = null; try { helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED); } catch (Exception e) { } Font font = new Font(helvetica, 8, Font.BOLDITALIC); pdfTable.addCell(new Paragraph("Make", font)); pdfTable.addCell(new Paragraph("Model", font)); pdfTable.addCell(new Paragraph("Year", font)); pdfTable.addCell(new Paragraph("Reg No.", font)); font = new Font(helvetica, 8, Font.NORMAL); if (getVehiclesByBrand() != null) { for (Vehicle e : getVehiclesByBrand()) { pdfTable.addCell(new Paragraph(e.getModel().getMaker().getName(), font)); pdfTable.addCell(new Paragraph(e.getModel().getName(), font)); pdfTable.addCell(new Paragraph(e.getModel().getYear(), font)); pdfTable.addCell(new Paragraph(e.getRegistrationNo(), font)); } } break; } case 5: // routine maintenance { numberOfColumns = 8; pdfTable = new PdfPTable(numberOfColumns); BaseFont helvetica = null; try { helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED); } catch (Exception e) { } Font font = new Font(helvetica, 8, Font.BOLDITALIC); pdfTable.addCell(new Paragraph("Reg No.", font)); pdfTable.addCell(new Paragraph("Requester", font)); pdfTable.addCell(new Paragraph("Description", font)); pdfTable.addCell(new Paragraph("Start Date", font)); pdfTable.addCell(new Paragraph("Initial Cost", font)); pdfTable.addCell(new Paragraph("Status", font)); pdfTable.addCell(new Paragraph("Close Date", font)); pdfTable.addCell(new Paragraph("Final Cost", font)); font = new Font(helvetica, 8, Font.NORMAL); if (getRmaints() != null) { for (VehicleRoutineMaintenance e : getRmaints()) { pdfTable.addCell(new Paragraph(e.getVehicle().getRegistrationNo(), font)); pdfTable.addCell(new Paragraph(e.getCreatedBy().getPersonel().getFirstname() + " " + e.getCreatedBy().getPersonel().getLastname(), font)); pdfTable.addCell(new Paragraph(e.getDescription(), font)); pdfTable.addCell(new Paragraph(e.getStart_dt().toLocaleString(), font)); pdfTable.addCell(new Paragraph(e.getInitial_amount().toPlainString(), font)); pdfTable.addCell(new Paragraph(e.getStatus(), font)); pdfTable.addCell(new Paragraph(e.getClose_dt().toLocaleString(), font)); pdfTable.addCell(new Paragraph(e.getClosed_amount().toPlainString(), font)); } } break; } case 6: // ad hoc maintenance { numberOfColumns = 8; pdfTable = new PdfPTable(numberOfColumns); BaseFont helvetica = null; try { helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED); } catch (Exception e) { } Font font = new Font(helvetica, 8, Font.BOLDITALIC); pdfTable.addCell(new Paragraph("Reg No.", font)); pdfTable.addCell(new Paragraph("Requester", font)); pdfTable.addCell(new Paragraph("Description", font)); pdfTable.addCell(new Paragraph("Start Date", font)); pdfTable.addCell(new Paragraph("Initial Cost", font)); pdfTable.addCell(new Paragraph("Status", font)); pdfTable.addCell(new Paragraph("Close Date", font)); pdfTable.addCell(new Paragraph("Final Cost", font)); font = new Font(helvetica, 8, Font.NORMAL); if (getAdhocmaints() != null) { for (VehicleAdHocMaintenance e : getAdhocmaints()) { pdfTable.addCell(new Paragraph(e.getVehicle().getRegistrationNo(), font)); pdfTable.addCell(new Paragraph(e.getCreatedBy().getPersonel().getFirstname() + " " + e.getCreatedBy().getPersonel().getLastname(), font)); pdfTable.addCell(new Paragraph(e.getDescription(), font)); pdfTable.addCell(new Paragraph(e.getStart_dt().toLocaleString(), font)); pdfTable.addCell(new Paragraph(e.getInitial_cost().toPlainString(), font)); pdfTable.addCell(new Paragraph(e.getStatus(), font)); pdfTable.addCell(new Paragraph(e.getClose_dt().toLocaleString(), font)); pdfTable.addCell(new Paragraph(e.getClosed_cost().toPlainString(), font)); } } break; } case 7: // active accidents { numberOfColumns = 8; pdfTable = new PdfPTable(numberOfColumns); BaseFont helvetica = null; try { helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED); } catch (Exception e) { } Font font = new Font(helvetica, 8, Font.BOLDITALIC); pdfTable.addCell(new Paragraph("Reg No.", font)); pdfTable.addCell(new Paragraph("Accident Date", font)); pdfTable.addCell(new Paragraph("Description", font)); pdfTable.addCell(new Paragraph("Driver Name", font)); pdfTable.addCell(new Paragraph("Driver Comment", font)); pdfTable.addCell(new Paragraph("Police Name", font)); pdfTable.addCell(new Paragraph("Station Name", font)); pdfTable.addCell(new Paragraph("Police Comment", font)); font = new Font(helvetica, 8, Font.NORMAL); if (getActiveAccidents() != null) { for (VehicleAccident e : getActiveAccidents()) { pdfTable.addCell(new Paragraph(e.getVehicle().getRegistrationNo(), font)); pdfTable.addCell(new Paragraph(e.getAccident_dt().toLocaleString(), font)); pdfTable.addCell(new Paragraph(e.getAccidentDescription(), font)); pdfTable.addCell(new Paragraph(e.getDriver_name(), font)); pdfTable.addCell(new Paragraph(e.getDriverComment(), font)); pdfTable.addCell(new Paragraph(e.getPoliceOfficer(), font)); pdfTable.addCell(new Paragraph(e.getPoliceStation(), font)); pdfTable.addCell(new Paragraph(e.getPoliceComment(), font)); } } break; } case 8: // coporate trips { numberOfColumns = 9; pdfTable = new PdfPTable(numberOfColumns); BaseFont helvetica = null; try { helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED); } catch (Exception e) { } Font font = new Font(helvetica, 6, Font.BOLDITALIC); pdfTable.addCell(new Paragraph("Requester", font)); pdfTable.addCell(new Paragraph("Department", font)); pdfTable.addCell(new Paragraph("Reg No.", font)); pdfTable.addCell(new Paragraph("Departure Location", font)); pdfTable.addCell(new Paragraph("Arrival Location", font)); pdfTable.addCell(new Paragraph("Departure Date and Time", font)); pdfTable.addCell(new Paragraph("Est. Arrival Date and Time", font)); pdfTable.addCell(new Paragraph("Act. Arrival Date and Time", font)); pdfTable.addCell(new Paragraph("Status", font)); font = new Font(helvetica, 6, Font.NORMAL); if (getCorTrips() != null) { for (CorporateTrip e : getCorTrips()) { pdfTable.addCell( new Paragraph(e.getStaff().getFirstname() + " " + e.getStaff().getLastname(), font)); pdfTable.addCell(new Paragraph( (e.getStaff().getDepartment() != null) ? e.getStaff().getDepartment().getName() : "N/A", font)); pdfTable.addCell(new Paragraph( e.getVehicle() != null ? e.getVehicle().getRegistrationNo() : "N/A", font)); pdfTable.addCell(new Paragraph(e.getDepartureLocation(), font)); pdfTable.addCell(new Paragraph(e.getArrivalLocation(), font)); pdfTable.addCell(new Paragraph(e.getDepartureDateTime().toLocaleString(), font)); pdfTable.addCell(new Paragraph(e.getEstimatedArrivalDateTime().toLocaleString(), font)); pdfTable.addCell(new Paragraph( e.getCompleteRequestDateTime() != null ? e.getCompleteRequestDateTime().toLocaleString() : "N/A", font)); pdfTable.addCell(new Paragraph(e.getTripStatus(), font)); } } break; } case 9: // expense report { numberOfColumns = 4; pdfTable = new PdfPTable(numberOfColumns); BaseFont helvetica = null; try { helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED); } catch (Exception e) { } Font font = new Font(helvetica, 8, Font.BOLDITALIC); pdfTable.addCell(new Paragraph("Type", font)); pdfTable.addCell(new Paragraph("Date", font)); pdfTable.addCell(new Paragraph("Amount", font)); pdfTable.addCell(new Paragraph("Detail", font)); font = new Font(helvetica, 8, Font.NORMAL); if (getExpenses() != null) { for (Expense e : getExpenses()) { pdfTable.addCell(new Paragraph(e.getType().getName(), font)); pdfTable.addCell(new Paragraph(e.getExpense_dt().toLocaleString(), font)); pdfTable.addCell(new Paragraph("" + e.getAmount(), font)); pdfTable.addCell(new Paragraph(e.getRemarks(), font)); } } break; } case 10: // vehicle ages { numberOfColumns = 6; pdfTable = new PdfPTable(numberOfColumns); BaseFont helvetica = null; try { helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED); } catch (Exception e) { } Font font = new Font(helvetica, 8, Font.BOLDITALIC); pdfTable.addCell(new Paragraph("Make", font)); pdfTable.addCell(new Paragraph("Model", font)); pdfTable.addCell(new Paragraph("Year", font)); pdfTable.addCell(new Paragraph("Reg No.", font)); pdfTable.addCell(new Paragraph("Date of Purchase", font)); pdfTable.addCell(new Paragraph("Age (in years)", font)); font = new Font(helvetica, 8, Font.NORMAL); if (getVehiclesAges() != null) { for (Vehicle e : getVehiclesAges()) { pdfTable.addCell(new Paragraph( e.getModel().getMaker() != null ? e.getModel().getMaker().getName() : "N/A", font)); pdfTable.addCell(new Paragraph(e.getModel() != null ? e.getModel().getName() : "N/A", font)); pdfTable.addCell(new Paragraph(e.getModel() != null ? e.getModel().getYear() : "N/A", font)); pdfTable.addCell(new Paragraph(e.getRegistrationNo(), font)); pdfTable.addCell(new Paragraph( e.getPurchaseDate() != null ? e.getPurchaseDate().toLocaleString() : "N/A", font)); pdfTable.addCell(new Paragraph("" + e.getAge(), font)); } } break; } case 11: // vehicle fuelings { numberOfColumns = 5; pdfTable = new PdfPTable(numberOfColumns); BaseFont helvetica = null; try { helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED); } catch (Exception e) { } Font font = new Font(helvetica, 8, Font.BOLDITALIC); pdfTable.addCell(new Paragraph("Date", font)); pdfTable.addCell(new Paragraph("Reg No.", font)); pdfTable.addCell(new Paragraph("Litres", font)); pdfTable.addCell(new Paragraph("Amount", font)); pdfTable.addCell(new Paragraph("Source", font)); font = new Font(helvetica, 8, Font.NORMAL); if (getFuelings() != null) { for (VehicleFueling e : getFuelings()) { pdfTable.addCell(new Paragraph(e.getCaptured_dt().toLocaleString(), font)); pdfTable.addCell(new Paragraph(e.getVehicle().getRegistrationNo(), font)); pdfTable.addCell(new Paragraph("" + e.getLitres(), font)); pdfTable.addCell(new Paragraph("" + e.getAmt(), font)); pdfTable.addCell(new Paragraph(e.getSource(), font)); } } break; } case 12: // due vehicle licenses { numberOfColumns = 5; pdfTable = new PdfPTable(numberOfColumns); BaseFont helvetica = null; try { helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED); } catch (Exception e) { } Font font = new Font(helvetica, 8, Font.BOLDITALIC); pdfTable.addCell(new Paragraph("Reg No.", font)); pdfTable.addCell(new Paragraph("Fleet", font)); pdfTable.addCell(new Paragraph("Make", font)); pdfTable.addCell(new Paragraph("Model", font)); pdfTable.addCell(new Paragraph("License Due Date", font)); font = new Font(helvetica, 8, Font.NORMAL); if (getDueVehicleLicenses() != null) { for (VehicleLicense e : getDueVehicleLicenses()) { pdfTable.addCell(new Paragraph(e.getVehicle().getRegistrationNo(), font)); pdfTable.addCell(new Paragraph(e.getVehicle().getFleet().getName(), font)); pdfTable.addCell(new Paragraph( e.getVehicle().getModel() != null ? e.getVehicle().getModel().getMaker().getName() : "N/A", font)); pdfTable.addCell(new Paragraph( e.getVehicle().getModel() != null ? e.getVehicle().getModel().getName() : "N/A", font)); pdfTable.addCell(new Paragraph(e.getLic_end_dt().toLocaleString(), font)); } } break; } } pdfTable.setWidthPercentage(100); return pdfTable; }
From source file:com.dexter.fuelcard.mbean.UtilMBean.java
public byte[] createInvoicePDF(int pageType, String title, String dateperiod, String amount, String chargeType, String chargeAmount, String total) { try {/* w w w .j a va2s . c o m*/ Document document = new Document(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter writer = PdfWriter.getInstance(document, baos); writer.setPageEvent(new HeaderFooter()); writer.setBoxSize("footer", new Rectangle(36, 54, 559, 788)); if (!document.isOpen()) { document.open(); } switch (pageType) { case 1: document.setPageSize(PageSize.A4); break; case 2: document.setPageSize(PageSize.A4.rotate()); break; } document.addAuthor("FUELCARD"); document.addCreationDate(); document.addCreator("FUELCARD"); document.addSubject("Invoice"); document.addTitle(title); PdfPTable headerTable = new PdfPTable(1); ServletContext servletContext = (ServletContext) FacesContext.getCurrentInstance().getExternalContext() .getContext(); String logo = servletContext.getRealPath("") + File.separator + "resources" + File.separator + "images" + File.separator + "satraklogo.jpg"; PdfPCell c = new PdfPCell(Image.getInstance(logo)); c.setBorder(0); c.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); headerTable.addCell(c); Paragraph stars = new Paragraph(20); stars.add(Chunk.NEWLINE); stars.setSpacingAfter(20); c = new PdfPCell(stars); c.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); c.setBorder(0); headerTable.addCell(c); BaseFont helvetica = null; try { helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED); } catch (Exception e) { //font exception } Font font = new Font(helvetica, 16, Font.NORMAL | Font.BOLD); c = new PdfPCell(new Paragraph(title, font)); c.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); c.setBorder(0); headerTable.addCell(c); if (dateperiod != null) { stars = new Paragraph(20); stars.add(Chunk.NEWLINE); stars.setSpacingAfter(10); c = new PdfPCell(stars); c.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); c.setBorder(0); headerTable.addCell(c); new Font(helvetica, 12, Font.NORMAL); Paragraph ch = new Paragraph("For " + dateperiod, font); c = new PdfPCell(ch); c.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); headerTable.addCell(c); } stars = new Paragraph(20); stars.add(Chunk.NEWLINE); stars.setSpacingAfter(20); c = new PdfPCell(stars); c.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); c.setBorder(0); headerTable.addCell(c); document.add(headerTable); PdfPTable pdfTable = new PdfPTable(4); try { helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED); } catch (Exception e) { } font = new Font(helvetica, 8, Font.BOLDITALIC); pdfTable.addCell(new Paragraph("Charge Type", font)); // % per transaction or flat per license pdfTable.addCell(new Paragraph("Charge Amount", font)); // the amount of the charge setting if (chargeType.equalsIgnoreCase("Percent-Per-Tran")) { pdfTable.addCell(new Paragraph("Total Amount", font)); // the amount of the charge setting } else { pdfTable.addCell(new Paragraph("Total License", font)); // the amount of the charge setting } //pdfTable.addCell(new Paragraph("Description", font)); // the pdfTable.addCell(new Paragraph("Amount Due", font)); font = new Font(helvetica, 8, Font.NORMAL); pdfTable.addCell(new Paragraph(chargeType, font)); pdfTable.addCell(new Paragraph(chargeAmount, font)); pdfTable.addCell(new Paragraph(total, font)); pdfTable.addCell(new Paragraph(amount, font)); pdfTable.setWidthPercentage(100); if (pdfTable != null) document.add(pdfTable); //Keep modifying your pdf file (add pages and more) document.close(); return baos.toByteArray(); } catch (Exception e) { e.printStackTrace(); return null; } }
From source file:com.iox.rms.mbean.UserBean.java
@SuppressWarnings("deprecation") private byte[] generateInvoiceForCustomerPurchase(CustomerProduct cp) { byte[] data = null; if (cp != null) { Document document = new Document(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); try {//from www . ja v a 2s . c o m PdfWriter writer = PdfWriter.getInstance(document, baos); writer.setPageEvent(new HeaderFooter()); writer.setBoxSize("footer", new Rectangle(36, 54, 559, 788)); if (!document.isOpen()) { document.open(); } document.setPageSize(PageSize.A4); document.addAuthor("AutoLife"); document.addCreationDate(); document.addCreator("AutoLife"); document.addSubject("Invoice"); document.addTitle("Purchase Invoice"); PdfPTable headerTable = new PdfPTable(3); ServletContext servletContext = (ServletContext) FacesContext.getCurrentInstance() .getExternalContext().getContext(); String logo = servletContext.getRealPath("") + File.separator + "images" + File.separator + "sattrak-logo.png"; PdfPCell c = new PdfPCell(Image.getInstance(logo)); c.setBorder(0); c.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); headerTable.addCell(c); BaseFont helvetica = null; try { helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED); } catch (Exception e) { } Font font = new Font(helvetica, 16, Font.NORMAL | Font.BOLD); c = new PdfPCell(new Paragraph("INVOICE", font)); c.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); c.setBorder(0); headerTable.addCell(c); font = new Font(helvetica, 10, Font.NORMAL | Font.BOLD); c = new PdfPCell(new Paragraph("TRANSACTION REF. NO.: " + cp.getPurchaseTranRef(), font)); c.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); c.setBorder(0); headerTable.addCell(c); document.add(headerTable); font = new Font(helvetica, 12, Font.NORMAL | Font.BOLD); Paragraph p = new Paragraph("DETAILS", font); p.setAlignment(Paragraph.ALIGN_CENTER); document.add(p); PdfPTable pdfTable = new PdfPTable(3); font = new Font(helvetica, 8, Font.BOLDITALIC); pdfTable.addCell(new Paragraph("INITIATED DATE", font)); pdfTable.addCell(new Paragraph("PRODUCT", font)); pdfTable.addCell(new Paragraph("AMOUNT", font)); font = new Font(helvetica, 8, Font.NORMAL); pdfTable.addCell( new Paragraph(cp.getPurchaseTransaction().getTranInitDate().toLocaleString(), font)); pdfTable.addCell(new Paragraph(cp.getProductBooked().getDetails(), font)); pdfTable.addCell(new Paragraph("" + cp.getPurchasedAmount(), font)); document.add(pdfTable); document.close(); data = baos.toByteArray(); } catch (Exception ex) { ex.printStackTrace(); } } return data; }
From source file:com.zentrix.minutas.SMinuta.java
/** * Handles the HTTP <code>POST</code> method. * * @param request servlet request/*from www. j a va2s .c om*/ * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //obtenemos los datos de la forma String titulo = request.getParameter("titulo"); String cuerpo = request.getParameter("cuerpominuta"); ServletOutputStream sos = response.getOutputStream(); response.setContentType("application/pdf"); //creamos un nuevo documento Document doc = new Document(); //creamos los estilos y las fuentes Font bfBold20 = new Font(FontFamily.TIMES_ROMAN, 20, Font.BOLD, new BaseColor(0, 0, 0)); Font bfBold12 = new Font(FontFamily.TIMES_ROMAN, 12, Font.BOLDITALIC, new BaseColor(0, 0, 0)); Font bf12 = new Font(FontFamily.TIMES_ROMAN, 12); try { //creamos un instancio de PdfWriter usando el OutputStream PdfWriter.getInstance(doc, sos); doc.addAuthor("Sistema Gestor de Academias"); doc.addCreationDate(); doc.addProducer(); doc.addCreator("Sistema de Academias"); doc.addTitle(titulo); doc.setPageSize(PageSize.LETTER); doc.open(); doc.add(new Paragraph(titulo, bfBold20)); doc.add(new Paragraph(cuerpo, bf12)); doc.close(); // PrintWriter out = response.getWriter(); // out.println("titulo "+ titulo); // out.println("cuerpo "+ cuerpo); } catch (DocumentException ex) { ex.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } }
From source file:comedor.actions.OperacionesComedorAction.java
private void crearPDF() throws IOException, DocumentException { Restaurante restaurante = godr.obtenerDatosRestaurante(); //Creamos el directorio donde almacenar los pdf sino existe File file = new File(RUTA_CUENTAS); //Especificamos la ruta if (!file.exists()) { //Si el directorio no existe if (file.mkdir()) { //Creamos el directorio //Le asignamos los permisos 777 file.setExecutable(true);//from w ww. j a va 2 s .c o m file.setReadable(true); file.setExecutable(true); } else { System.err.println("Error al crear el directorio especificado"); throw new IOException(); //Lanzamos una excepcion } } if (file.exists()) { //Si el directorio existe //Creamos el documento Document documento = new Document(); //Creamos el OutputStream para el fichero pdf FileOutputStream destino = new FileOutputStream(RUTA_CUENTAS + nombreDocumento); //Asociamos el FileOutputStream al Document PdfWriter.getInstance(documento, destino); //Abrimos el documento documento.open(); //Aadimos el nombre del restaurante Font titulo = FontFactory.getFont(FontFactory.TIMES, 16, Font.BOLDITALIC); Chunk chunk = new Chunk(restaurante.getNombre(), titulo); Paragraph parrafo = new Paragraph(chunk); parrafo.setAlignment(Element.ALIGN_CENTER); documento.add(parrafo); //Aadimos la imagen String path = request.getServletContext().getRealPath("/img/elvis.png"); Image foto = Image.getInstance(path); foto.scaleToFit(100, 100); foto.setAlignment(Chunk.ALIGN_MIDDLE); documento.add(foto); //Aadimos los datos del restaurante Font datos = FontFactory.getFont(FontFactory.TIMES, 12, Font.NORMAL); chunk = new Chunk(getText("cuenta.cif") + ": " + restaurante.getCif(), datos); documento.add(new Paragraph(chunk)); chunk = new Chunk(getText("cuenta.direccion") + ": " + restaurante.getDireccion(), datos); documento.add(new Paragraph(chunk)); chunk = new Chunk(getText("cuenta.telefono") + ": " + restaurante.getTelefono(), datos); documento.add(new Paragraph(chunk)); //Aadimos los datos de la cuenta chunk = new Chunk(getText("cuenta.cuentaId") + ": " + cuenta.getId(), datos); documento.add(new Paragraph(chunk)); SimpleDateFormat formatoFecha = new SimpleDateFormat("dd-MM-yyyy"); chunk = new Chunk(getText("cuenta.fecha") + ": " + formatoFecha.format(cuenta.getFecha()), datos); documento.add(new Paragraph(chunk)); SimpleDateFormat formtoHora = new SimpleDateFormat("HH:mm:ss"); chunk = new Chunk(getText("cuenta.hora") + ": " + formtoHora.format(cuenta.getFecha()), datos); documento.add(new Paragraph(chunk)); //Aadimos los datos del pedido //Obtenemos el usuario, es decir, del camarero con el nombre que tenemos registrado en la session chunk = new Chunk(getText("cuenta.camarero") + ": " + session.get("usuario").toString(), datos); documento.add(new Paragraph(chunk)); documento.add(new Chunk(Chunk.NEWLINE)); //Salto de linea //Aadimos la tabla con los datos del pedido //Creamos una tabla PdfPTable tabla = new PdfPTable(4); //Especificamos el numero de columnas //Aadimos la cabecera de la tabla tabla.addCell(getText("cuenta.producto")); tabla.addCell(getText("cuenta.unidades")); tabla.addCell(getText("cuenta.pvp")); tabla.addCell(getText("cuenta.total")); for (Producto producto : pedido.getListaProductos()) { tabla.addCell(producto.getNombre()); tabla.addCell(String.valueOf(producto.getUnidades())); tabla.addCell(String.valueOf(producto.getPrecio())); tabla.addCell(String.valueOf(producto.getPrecio() * producto.getUnidades())); if (producto instanceof Hamburguesa) { Hamburguesa h = (Hamburguesa) producto; for (Producto extra : h.getListaProductosExtra()) { tabla.addCell("(E) " + extra.getNombre()); tabla.addCell(String.valueOf(extra.getUnidades())); tabla.addCell(String.valueOf(extra.getPrecio())); tabla.addCell(String.valueOf(extra.getPrecio() * extra.getUnidades())); } } } //Aadimos la tabla al documento documento.add(tabla); documento.add(new Chunk(Chunk.NEWLINE)); //Salto de linea //Aadimos una tabla con los impuestos y el total a pagar tabla = new PdfPTable(3); //Especificamos el numero de columnas tabla.addCell(getText("cuenta.baseImponible") + ": " + pedido.getImporte() + ""); tabla.addCell(""); tabla.addCell(""); DecimalFormat formato = new DecimalFormat("#.##"); for (Impuesto dato : listaImpuestos) { tabla.addCell(""); tabla.addCell(dato.getNombre() + ": " + dato.getValor()); double impuesto = (pedido.getImporte() * dato.getValor()) / 100; tabla.addCell( getText("cuenta.impuesto") + " " + dato.getNombre() + ": " + formato.format(impuesto)); } tabla.addCell(getText("cuenta.total") + ": " + cuenta.getCantidad() + ""); tabla.addCell(""); tabla.addCell(""); //Aadimos la tabla al documento documento.add(tabla); //Cerramos el documento documento.close(); } else { //Si el directoiro no existe System.err.println("OperacionesComedorAction. Error no existe el directorio especificado"); throw new IOException(); //Lanzamos una excepcion } }
From source file:Controlador.ControladorCrearPase.java
public void generaPDF(String Prueba, String Causa, Integer idCita, Integer idPaciente, Integer idPersona) throws FileNotFoundException, DocumentException, IOException { Calendar cal = Calendar.getInstance(); String time = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(cal.getTime()); String timename = new SimpleDateFormat("yyyyMMddHHmm").format(cal.getTime()); File file = new File("PaseServicio" + timename + ".pdf"); FileOutputStream fileout = new FileOutputStream(file); Document document = new Document(); PdfWriter writer;//from w w w. j a va 2 s . co m writer = PdfWriter.getInstance(document, fileout); Font fuente = new Font(); Font fuente2 = new Font(); Font fuente3 = new Font(); // fuente.setColor(BaseColor.BLUE); fuente.setStyle(Font.UNDERLINE | Font.BOLDITALIC); fuente2.setStyle(Font.BOLD); fuente2.setSize(12); fuente3.setSize(20); fuente3.setStyle(Font.BOLD); document.open(); document.add(new Paragraph("\n \n \n \n \n")); document.add(new Paragraph("Clinica Mdica INFTEL", fuente3)); String imageUrl = "src/Imagen/logo.png"; // String imagen="src\Imagen\logo.png"; Image image = Image.getInstance(imageUrl); image.setAbsolutePosition(300, 750); image.scalePercent(80f); document.add(image); document.add(new Paragraph(" ")); document.add(new Paragraph("---------------------")); document.add(new Paragraph("DATOS DEL PACIENTE", fuente)); document.add(new Paragraph(" ")); document.add( new Paragraph("Apellidos y Nombre : " + paciente.getApellidos() + ", " + paciente.getNombre())); document.add(new Paragraph("NIF : " + paciente.getNif())); document.add(new Paragraph("NSS : " + paciente.getNumSS())); document.add(new Paragraph("Direccion : " + paciente.getDireccion())); document.add(new Paragraph("Telefono : " + paciente.getTelefono())); document.add(new Paragraph("Email : " + paciente.getEmail())); document.add(new Paragraph("ID Paciente : " + idPaciente)); document.add(new Paragraph(" ")); document.add(new Paragraph("---------------------")); document.add(new Paragraph(" ")); document.add(new Paragraph("DATOS ", fuente)); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph("Prueba : ", fuente2)); document.add(new Paragraph(Prueba)); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph("Causa : ", fuente2)); document.add(new Paragraph(Causa)); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); absText(writer, time, 450, 50); document.close(); File myfile = new File("PaseServicio" + timename + ".pdf"); Desktop.getDesktop().open(myfile); }