List of usage examples for com.itextpdf.layout Document close
@Override public void close()
From source file:controller.ReporteDiarioController.java
public void generaPDF(ActionEvent evt) throws FileNotFoundException, MalformedURLException, IOException, RemoteException, NotBoundException { Registry reg = LocateRegistry.getRegistry(host, 27019); oasiscrud.oasisrimbd inter = (oasiscrud.oasisrimbd) reg.lookup("OasisSev"); FileChooser file = new FileChooser(); file.getExtensionFilters().add(new FileChooser.ExtensionFilter("Documento PDF", " *.PDF")); File f = file.showSaveDialog(null); PdfWriter writer = new PdfWriter(f.getAbsolutePath()); PdfDocument pdf = new PdfDocument(writer); pdf.setDefaultPageSize(PageSize.LETTER.rotate()); Document document = new Document(pdf); Cell c;//from w w w.jav a 2 s.c o m Table tc; Paragraph p = new Paragraph(); Image img = new Image(ImageDataFactory.create(getClass().getResource("/images/pdf-logo.png"))); img.setHorizontalAlignment(HorizontalAlignment.CENTER); document.add(img); document.add(new Paragraph("\n")); tc = new Table(1); tc.addCell(generaCabezera("Reporte del dia " + date.getValue().getDayOfWeek().getDisplayName(TextStyle.FULL, Locale.getDefault()) + " " + date.getValue().format(DateTimeFormatter.ISO_LOCAL_DATE))); document.add(tc); generaTitulo(document, "Detalles de asistencias General"); generaTablaAsistencia(document); pdf.addNewPage(); document.add(new AreaBreak()); generaTitulo(document, "Detalles de Aperturas de mesas"); generaTablaAperturaMesas(document); pdf.addNewPage(); document.add(new AreaBreak()); generaTitulo(document, "Detalles de Pases generados"); generaTablaPases(document); pdf.addNewPage(); document.add(new AreaBreak()); generaTitulo(document, "Detalles de Autorizaciones"); generaTablaAutorizaciones(document); pdf.addNewPage(); document.add(new AreaBreak()); generaTitulo(document, "Detalles de accesos al sistema"); generaTablaAcceso(document); pdf.addNewPage(); document.add(new AreaBreak()); generaTitulo(document, "Detalles de busquedas en el sistema"); generaTablaBusqueda(document); document.close(); System.out.println(f.getAbsolutePath()); close(evt); }
From source file:controller.ReporteFechaController.java
public void generaPDF(ActionEvent evt) throws FileNotFoundException, MalformedURLException, IOException, RemoteException, NotBoundException { Registry reg = LocateRegistry.getRegistry(host, 27019); oasiscrud.oasisrimbd inter = (oasiscrud.oasisrimbd) reg.lookup("OasisSev"); FileChooser file = new FileChooser(); file.getExtensionFilters().add(new FileChooser.ExtensionFilter("Documento PDF", " *.PDF")); File f = file.showSaveDialog(null); PdfWriter writer = new PdfWriter(f.getAbsolutePath()); PdfDocument pdf = new PdfDocument(writer); pdf.setDefaultPageSize(PageSize.LETTER.rotate()); Document document = new Document(pdf); Cell c;//from w w w. j a v a 2s. c o m Table tc; Paragraph p = new Paragraph(); Image img = new Image(ImageDataFactory.create(getClass().getResource("/images/pdf-logo.png"))); img.setHorizontalAlignment(HorizontalAlignment.CENTER); document.add(img); document.add(new Paragraph("\n")); tc = new Table(1); tc.addCell(generaCabezera("Reporte desde el dia " + from.getValue().getDayOfWeek().getDisplayName(TextStyle.FULL, Locale.getDefault()) + " " + from.getValue().format(DateTimeFormatter.ISO_LOCAL_DATE) + " hasta el dia " + to.getValue().getDayOfWeek().getDisplayName(TextStyle.FULL, Locale.getDefault()) + " " + to.getValue().format(DateTimeFormatter.ISO_LOCAL_DATE))); document.add(tc); generaTitulo(document, "Detalles de asistencias General"); generaTablaAsistencia(document); pdf.addNewPage(); document.add(new AreaBreak()); generaTitulo(document, "Detalles de Aperturas de mesas"); generaTablaAperturaMesas(document); pdf.addNewPage(); document.add(new AreaBreak()); generaTitulo(document, "Detalles de Pases generados"); generaTablaPases(document); pdf.addNewPage(); document.add(new AreaBreak()); generaTitulo(document, "Detalles de Autorizaciones"); generaTablaAutorizaciones(document); pdf.addNewPage(); document.add(new AreaBreak()); generaTitulo(document, "Detalles de accesos al sistema"); generaTablaAcceso(document); pdf.addNewPage(); document.add(new AreaBreak()); generaTitulo(document, "Detalles de busquedas en el sistema"); generaTablaBusqueda(document); document.close(); System.out.println(f.getAbsolutePath()); close(evt); }
From source file:controller.ReporteMesController.java
public void generaPDF(ActionEvent evt) throws FileNotFoundException, MalformedURLException, IOException, RemoteException, NotBoundException { Registry reg = LocateRegistry.getRegistry(host, 27019); oasiscrud.oasisrimbd inter = (oasiscrud.oasisrimbd) reg.lookup("OasisSev"); FileChooser file = new FileChooser(); file.getExtensionFilters().add(new FileChooser.ExtensionFilter("Documento PDF", " *.PDF")); File f = file.showSaveDialog(null); PdfWriter writer = new PdfWriter(f.getAbsolutePath()); PdfDocument pdf = new PdfDocument(writer); pdf.setDefaultPageSize(PageSize.LETTER.rotate()); Document document = new Document(pdf); Cell c;/* w w w.java2 s . co m*/ Table tc; Paragraph p = new Paragraph(); Image img = new Image(ImageDataFactory.create(getClass().getResource("/images/pdf-logo.png"))); img.setHorizontalAlignment(HorizontalAlignment.CENTER); document.add(img); document.add(new Paragraph("\n")); tc = new Table(1); tc.addCell(generaCabezera("Reporte del mes " + cbmes.getSelectionModel().getSelectedItem() + " del ao " + cbano.getSelectionModel().getSelectedItem())); document.add(tc); generaTitulo(document, "Detalles de asistencias General"); generaTablaAsistencia(document); pdf.addNewPage(); document.add(new AreaBreak()); generaTitulo(document, "Detalles de Aperturas de mesas"); generaTablaAperturaMesas(document); pdf.addNewPage(); document.add(new AreaBreak()); generaTitulo(document, "Detalles de Pases generados"); generaTablaPases(document); pdf.addNewPage(); document.add(new AreaBreak()); generaTitulo(document, "Detalles de Autorizaciones"); generaTablaAutorizaciones(document); pdf.addNewPage(); document.add(new AreaBreak()); generaTitulo(document, "Detalles de accesos al sistema"); generaTablaAcceso(document); pdf.addNewPage(); document.add(new AreaBreak()); generaTitulo(document, "Detalles de busquedas en el sistema"); generaTablaBusqueda(document); document.close(); System.out.println(f.getAbsolutePath()); close(evt); }
From source file:controller.ReservaController.java
public void exportPDF() throws RemoteException, NotBoundException, FileNotFoundException, IOException { Registry reg = LocateRegistry.getRegistry(host, 27019); oasiscrud.oasisrimbd inter = (oasiscrud.oasisrimbd) reg.lookup("OasisSev"); FileChooser file = new FileChooser(); file.getExtensionFilters().add(new FileChooser.ExtensionFilter("Documento PDF", " *.pdf")); File f = file.showSaveDialog(null); PdfWriter writer = new PdfWriter(f.getAbsolutePath()); PdfDocument pdf = new PdfDocument(writer); pdf.setDefaultPageSize(PageSize.LETTER); Document document = new Document(pdf); com.itextpdf.layout.element.Image img = new com.itextpdf.layout.element.Image( ImageDataFactory.create(getClass().getResource("/images/pdf-logo.png"))); img.setHorizontalAlignment(HorizontalAlignment.CENTER); document.add(img);/* ww w .j a v a 2 s . com*/ generaTitulo(document, "Lista de reservaciones"); document.add(new Paragraph("\n")); Table t = generaCabezera( Arrays.asList("Titular", "Cedula", "Telefono", "Plan", "Invitados", "Fecha", "Observaciones")); document.add(t); for (int i = 0; i < table.getItems().size(); i++) { generaReservas(document, (Reserva) table.getItems().get(i)); white *= -1; } document.close(); }
From source file:controller.VisitasController.java
public void generaPDF(ActionEvent evt) throws FileNotFoundException, MalformedURLException, IOException, RemoteException, NotBoundException { Registry reg = LocateRegistry.getRegistry(host, 27019); oasiscrud.oasisrimbd inter = (oasiscrud.oasisrimbd) reg.lookup("OasisSev"); FileChooser file = new FileChooser(); file.getExtensionFilters().add(new FileChooser.ExtensionFilter("Documento PDF", " *.PDF")); File f = file.showSaveDialog(null); PdfWriter writer = new PdfWriter(f.getAbsolutePath()); PdfDocument pdf = new PdfDocument(writer); pdf.setDefaultPageSize(PageSize.LETTER.rotate()); Document document = new Document(pdf); com.itextpdf.layout.element.Cell c;/* w ww. j a v a 2 s . c o m*/ Table tc; Paragraph p = new Paragraph(); Image img = new Image(ImageDataFactory.create(getClass().getResource("/images/pdf-logo.png"))); img.setHorizontalAlignment(com.itextpdf.layout.property.HorizontalAlignment.CENTER); document.add(img); document.add(new Paragraph("\n")); generaTitulo(document, "Detalles de asistencias General"); generaTablaAsistencia(document); pdf.addNewPage(); document.add(new AreaBreak()); document.close(); System.out.println(f.getAbsolutePath()); }
From source file:dbchubreast_web.controller.download.DownloadFichesPatientsPdf.java
License:Open Source License
/** ====================================================================================== */ private void generatePdf(HttpServletResponse response, List<String> listIdPatients) throws IOException { String fileName = fileService.generateFileName("PROBREAST_fiches_patients", "pdf"); response.setHeader("Content-disposition", "attachment; filename=" + fileName); response.setContentType("application/pdf"); PdfWriter writer = new PdfWriter(response.getOutputStream()); PdfDocument pdfDoc = new PdfDocument(writer); Document document = new Document(pdfDoc); pdfService.createHeaderFooter(pdfDoc, document); pdfService.createPdf(listIdPatients, document, null, "confidentielle"); document.close(); response.flushBuffer();/*from w w w .j a v a 2 s . co m*/ }
From source file:dbchubreast_web.controller.PdfController.java
License:Open Source License
/** ====================================================================================== */ @RequestMapping(value = "/pdf/patient/{idPatient}", method = RequestMethod.GET) public void downloadPdf(Model model, @PathVariable String idPatient, HttpServletRequest request, HttpServletResponse response) throws IOException { String fileName = "fiche_patient_" + idPatient + ".pdf"; response.setHeader("Content-disposition", "attachment; filename=" + fileName); response.setContentType("application/pdf"); PdfWriter writer = new PdfWriter(response.getOutputStream()); PdfDocument pdfDoc = new PdfDocument(writer); Document document = new Document(pdfDoc); pdfService.createHeaderFooter(pdfDoc, document); List<String> listIdPatients = new ArrayList<String>(); listIdPatients.add(idPatient);/* w w w . j a v a 2 s .c om*/ List<ChuPatient> listPatients = patientService.findAsList(idPatient); consistencyService.clearMessages(); consistencyService.checkConsistency(listPatients); pdfService.createPdf(listIdPatients, document, consistencyService.getMapMessages(), "confidentielle"); // pdfService.createPdf(listIdPatients, document, "publique"); document.close(); response.flushBuffer(); }
From source file:machinetoolstore.core.util.PdfGenerator.java
public static boolean getGeneratedPdfByArtifact(ThreeRollMill artifact, String fileName) throws Exception { PdfWriter writer = new PdfWriter(GENERATED_FILES_PATH + fileName); PdfDocument pdfDocument = new PdfDocument(writer); Document document = new Document(pdfDocument, PageSize.A4); document.setMargins(15, 15, 15, 40); PdfFont mainFont = PdfFontFactory.createFont(FONTS_PATH + "calibril.ttf", "cp1251", false); //Header//w w w. j a v a 2 s . c om Paragraph headerParagraph = new Paragraph(artifact.getBrand() + " " + artifact.getModel()); headerParagraph.setItalic(); headerParagraph.setTextAlignment(TextAlignment.CENTER); headerParagraph.setFont(mainFont); headerParagraph.setFontSize(20); document.add(headerParagraph); //Image block witch characteristic Table table = new Table(3); table.setWidthPercent(100); //Image cell Cell imageCell = new Cell(); imageCell.setBorder(Border.NO_BORDER); Image machineImage = new Image(ImageDataFactory.create(IMAGE_PATH + artifact.getMainPhoto())); machineImage.setWidth(100); machineImage.setHeight(100); imageCell.add(machineImage); //Main characteristic cell Cell mainCharacteristicCell = new Cell(); List mainCharacteristicList = new List().setSymbolIndent(5).setListSymbol("\uFFFF").setFont(mainFont) .setFontSize(12); mainCharacteristicList.add("ID:").add(":").add(" ?:") .add("?:").add("??:").add(", $:"); mainCharacteristicCell.add(mainCharacteristicList); Cell valuesCell = new Cell(); List valuesList = new List().setSymbolIndent(5).setListSymbol("\uFFFF").setFont(mainFont).setFontSize(12); valuesList.add(artifact.getId().toString()).add(artifact.getManufacturer()) .add(artifact.getYearOfIssue().toString()).add(artifact.getLocation()) .add(artifact.getMachineState()).add(artifact.getMachinePrice().toString()); valuesCell.add(valuesList); table.addCell(imageCell); table.addCell(mainCharacteristicCell); table.addCell(valuesCell); //Paragraph Paragraph contentParagraph = new Paragraph("? ?"); contentParagraph.setItalic(); contentParagraph.setTextAlignment(TextAlignment.CENTER); contentParagraph.setFont(mainFont); contentParagraph.setFontSize(14); contentParagraph.setFixedPosition(1, 635, 600); document.add(contentParagraph); //Main table Table mainTable = new Table(2); mainTable.setFont(mainFont); mainTable.setFontSize(10); mainTable.setMarginTop(35); mainTable.addCell(" ?").addCell(artifact.getType()); mainTable.addCell(" , ") .addCell(artifact.getMaterialThickness().toString()); mainTable.addCell(" , ").addCell(artifact.getMaterialWidth().toString()); mainTable.addCell("? , /").addCell(artifact.getBendingSpeed().toString()); mainTable.addCell("Min max ?, ") .addCell(artifact.getMinDiameterMaxBend().toString()); mainTable.addCell(" , ") .addCell(artifact.getTopRollDiameter().toString()); mainTable.addCell(" ? , ") .addCell(artifact.getMiddleRollDiameter().toString()); mainTable.addCell("??? ? , ") .addCell(artifact.getDistanceOfBottomTwoRolls().toString()); mainTable.addCell( "? ? ? ?, ") .addCell(artifact.getMaterialProofStress().toString()); mainTable.addCell("? ?, ") .addCell(artifact.getMainEnginePower().toString()); mainTable.addCell(" , ").addCell(artifact.getMachineDimensions()); mainTable.addCell("? ?, ").addCell(artifact.getMachineWeight().toString()); mainTable.addCell("?").addCell(artifact.getDescription()); document.add(table); document.add(mainTable); document.close(); return true; }
From source file:model.PrintPDF.java
public void inThongKeCanBo(ArrayList<CanBo> listCanBo, String pathName, String nam, int gt, String tongNhanVien, String soNVVH) {//from w w w . j a v a 2 s . c om PdfWriter pdfWriter = null; String gioiTinh = ""; if (gt == 1) { gioiTinh = "n"; } else { gioiTinh = "nam"; } try { pdfWriter = new PdfWriter(pathName); PdfDocument pdfDocument = new PdfDocument(pdfWriter); Document document = new Document(pdfDocument, PageSize.A4.rotate()); PdfFont hfont = PdfFontFactory.createFont("C:\\Windows\\Fonts\\tahoma.ttf", PdfEncodings.IDENTITY_H, true); document.setMargins(50, 50, 50, 50); document.add(new Paragraph("TRNG ?I HC B?CH KHOA H NI ").setFont(hfont).setBold() .setTextAlignment(TextAlignment.CENTER).setFontSize(16)); document.add(new Paragraph("Thng k cn b " + gioiTinh + " nm " + nam + "\n\n").setFont(hfont) .setBold().setTextAlignment(TextAlignment.CENTER).setFontSize(14)); float[] columnWidths = { 1, 2, 4, 3, 4 }; Table table = new Table(columnWidths); table.setWidthPercent(100); table.addHeaderCell(new Paragraph("STT").setFont(hfont).setTextAlignment(TextAlignment.CENTER).setBold() .setFontSize(14)); table.addHeaderCell(new Paragraph("M cn b").setFont(hfont).setTextAlignment(TextAlignment.CENTER) .setBold().setFontSize(14)); table.addHeaderCell(new Paragraph("H? v tn ").setFont(hfont) .setTextAlignment(TextAlignment.CENTER).setBold().setFontSize(14)); table.addHeaderCell(new Paragraph("Ngy sinh").setFont(hfont).setTextAlignment(TextAlignment.CENTER) .setBold().setFontSize(14)); table.addHeaderCell(new Paragraph("S in thoi").setFont(hfont) .setTextAlignment(TextAlignment.CENTER).setBold().setFontSize(14)); // ni dung ca bng thng k for (int i = 0; i < listCanBo.size(); i++) { table.addCell(new Paragraph((i + 1) + "").setFont(hfont).setTextAlignment(TextAlignment.CENTER)); table.addCell(new Paragraph(listCanBo.get(i).getMaCB()).setFont(hfont) .setTextAlignment(TextAlignment.CENTER)); table.addCell(new Paragraph(listCanBo.get(i).getHoTen()).setFont(hfont) .setTextAlignment(TextAlignment.CENTER)); table.addCell(new Paragraph(dateFormat.format(listCanBo.get(i).getNgaySinh())).setFont(hfont) .setTextAlignment(TextAlignment.CENTER)); table.addCell(new Paragraph(listCanBo.get(i).getSDT()).setFont(hfont) .setTextAlignment(TextAlignment.CENTER)); } document.add(table); document.add(new Paragraph("\n\n Tng s nhn vin : " + tongNhanVien).setFont(hfont) .setTextAlignment(TextAlignment.LEFT)); document.add(new Paragraph(" Tng s nhn vin sp v? hu : " + tongNhanVien).setFont(hfont) .setTextAlignment(TextAlignment.LEFT)); document.add(new Paragraph( "\n\n\n H Ni, ngy thng nm \n Ng?i lp phiu \n ( Ghi r h? tn) ") .setFont(hfont).setTextAlignment(TextAlignment.RIGHT).setItalic().setMarginRight(40)); document.close(); } catch (FileNotFoundException ex) { Logger.getLogger(PrintPDF.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(PrintPDF.class.getName()).log(Level.SEVERE, null, ex); } finally { try { pdfWriter.close(); } catch (IOException ex) { Logger.getLogger(PrintPDF.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:model.PrintPDF.java
public void thongKeDoanPhi(ArrayList<String> listDataTable, String pathName, String nam, String tongDoanVien, String tienDoanPhi) {/*from w ww . j av a 2 s .com*/ PdfWriter pdfWriter = null; String gioiTinh = ""; try { pdfWriter = new PdfWriter(pathName); PdfDocument pdfDocument = new PdfDocument(pdfWriter); Document document = new Document(pdfDocument, PageSize.A4.rotate()); PdfFont hfont = PdfFontFactory.createFont("C:\\Windows\\Fonts\\tahoma.ttf", PdfEncodings.IDENTITY_H, true); document.setMargins(50, 50, 50, 50); document.add(new Paragraph("TRNG ?I HC B?CH KHOA H NI ").setFont(hfont).setBold() .setTextAlignment(TextAlignment.CENTER).setFontSize(16)); document.add(new Paragraph("Thng k on vin " + gioiTinh + " nm " + nam + "\n\n") .setFont(hfont).setBold().setTextAlignment(TextAlignment.CENTER).setFontSize(14)); float[] columnWidths = { 1, 2, 4, 3, 4 }; Table table = new Table(columnWidths); table.setWidthPercent(100); table.addHeaderCell(new Paragraph("STT").setFont(hfont).setTextAlignment(TextAlignment.CENTER).setBold() .setFontSize(14)); table.addHeaderCell(new Paragraph("M cn b").setFont(hfont).setTextAlignment(TextAlignment.CENTER) .setBold().setFontSize(14)); table.addHeaderCell(new Paragraph("H? v tn ").setFont(hfont) .setTextAlignment(TextAlignment.CENTER).setBold().setFontSize(14)); table.addHeaderCell(new Paragraph("Ngy sinh").setFont(hfont).setTextAlignment(TextAlignment.CENTER) .setBold().setFontSize(14)); table.addHeaderCell(new Paragraph("S ti khon ").setFont(hfont) .setTextAlignment(TextAlignment.CENTER).setBold().setFontSize(14)); // ni dung ca bng thng k for (int i = 0; i < listDataTable.size(); i++) { table.addCell(new Paragraph(listDataTable.get(i)).setFont(hfont) .setTextAlignment(TextAlignment.CENTER).setFontSize(14)); } document.add(table); document.add(new Paragraph("\n\n Tng s on vin : " + tongDoanVien).setFont(hfont) .setTextAlignment(TextAlignment.LEFT)); document.add(new Paragraph(" ?on ph (VN? / ?on Vin) : " + tienDoanPhi + "VN?") .setFont(hfont).setTextAlignment(TextAlignment.LEFT)); double tongTienDoanPhi = Integer.parseInt(tongDoanVien) * Integer.parseInt(tienDoanPhi); document.add(new Paragraph(" Tng s ti?n on ph : " + tongTienDoanPhi + " VND") .setFont(hfont).setTextAlignment(TextAlignment.LEFT)); document.add(new Paragraph( "\n\n\n H Ni, ngy thng nm \n Ng?i lp phiu \n ( Ghi r h? tn) ") .setFont(hfont).setTextAlignment(TextAlignment.RIGHT).setItalic().setMarginRight(40)); document.close(); } catch (FileNotFoundException ex) { Logger.getLogger(PrintPDF.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(PrintPDF.class.getName()).log(Level.SEVERE, null, ex); } finally { try { pdfWriter.close(); } catch (IOException ex) { Logger.getLogger(PrintPDF.class.getName()).log(Level.SEVERE, null, ex); } } }