List of usage examples for com.itextpdf.layout Document close
@Override public void close()
From source file:model.PrintPDF.java
public void thongKeCongDoanPhi(ArrayList<String> listDataTable, String pathName, String nam, String tongCongDoanVien, String tienCongDoanPhi) { PdfWriter pdfWriter = null;/* w w w . j ava 2s . c om*/ 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 cng on vin nm " + nam + "\n\n").setFont(hfont) .setBold().setTextAlignment(TextAlignment.CENTER).setFontSize(14)); float[] columnWidths = { 1, 2, 4, 3, 3, 3 }; 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("Chc v ").setFont(hfont).setTextAlignment(TextAlignment.CENTER) .setBold().setFontSize(14)); table.addHeaderCell(new Paragraph("Cng on ph ").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 nhn vin : " + tongCongDoanVien) .setFont(hfont).setTextAlignment(TextAlignment.LEFT)); document.add(new Paragraph(" Tng cng on ph : " + tienCongDoanPhi).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 thongKeDangPhi(ArrayList<String> listDataTable, String pathName, String nam, String tongDangVien) { PdfWriter pdfWriter = null;/* w w w . j a v a 2 s .c o m*/ 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 ng vin " + " nm " + nam + "\n\n").setFont(hfont) .setBold().setTextAlignment(TextAlignment.CENTER).setFontSize(14)); float[] columnWidths = { 1, 2, 4, 3, 4, 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("Chc v ").setFont(hfont).setTextAlignment(TextAlignment.CENTER) .setBold().setFontSize(14)); table.addHeaderCell(new Paragraph("?ng ph ").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 ng vin : " + tongDangVien).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 thongKeTienThi(ArrayList<String> listDataTable, String pathName) { PdfWriter pdfWriter = null;//w w w .j av a 2s . com 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 ti?n thi ging vin " + "\n\n").setFont(hfont).setBold() .setTextAlignment(TextAlignment.CENTER).setFontSize(14)); float[] columnWidths = { 1, 2, 4, 3, 4, 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("Mn h?c").setFont(hfont).setTextAlignment(TextAlignment.CENTER) .setBold().setFontSize(14)); table.addHeaderCell(new Paragraph("S SV ").setFont(hfont).setTextAlignment(TextAlignment.CENTER) .setBold().setFontSize(14)); table.addHeaderCell(new Paragraph("Ph thi").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\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 thongKeThieuNhi(ArrayList<String> listDataTable, String pathName) { PdfWriter pdfWriter = null;//from www . j a v a2 s .com 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 cc chu thiu nhi " + "\n\n").setFont(hfont).setBold() .setTextAlignment(TextAlignment.CENTER).setFontSize(14)); float[] columnWidths = { 1, 3, 3, 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("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("M cn b").setFont(hfont).setTextAlignment(TextAlignment.CENTER) .setBold().setFontSize(14)); table.addHeaderCell(new Paragraph("H? v tn cn b ").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\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:org.nih.nci.App.java
protected void generatePdf(String dest, NCIDosePdfObject jObject) throws Exception { PdfWriter writer = new PdfWriter(dest, new WriterProperties().addXmpMetadata()); PdfDocument pdfDoc = new PdfDocument(writer); Document document = new Document(pdfDoc, PageSize.LETTER, false); pdfDoc.setTagged();// www .j a va 2 s . co m pdfDoc.getCatalog().setViewerPreferences(new PdfViewerPreferences().setDisplayDocTitle(true)); pdfDoc.getCatalog().setLang(new PdfString("en-US")); pdfDoc.getCatalog().setViewerPreferences(new PdfViewerPreferences().setDisplayDocTitle(true)); PdfDocumentInfo info = pdfDoc.getDocumentInfo(); info.setTitle("Software Transfer Agreement"); Style headerStyle = new Style(); PdfFont headerFont = PdfFontFactory.createFont(FontConstants.HELVETICA); headerStyle.setFont(headerFont).setFontSize(10); HeaderEventHandler handler = new HeaderEventHandler(); pdfDoc.addEventHandler(PdfDocumentEvent.END_PAGE, handler); handler.setHeader("NCI Reference # ___________________"); Style titleStyle = new Style(); PdfFont titleFont = PdfFontFactory.createFont(FontConstants.TIMES_BOLD, true); titleStyle.setFont(titleFont).setFontSize(14); Style normalStyle = new Style(); PdfFont normalFont = PdfFontFactory.createFont(FontConstants.TIMES_ROMAN, true); normalStyle.setFont(normalFont).setFontSize(12); Style italicStyle = new Style(); PdfFont italicFont = PdfFontFactory.createFont(FontConstants.TIMES_ITALIC, true); italicStyle.setFont(italicFont).setFontSize(12); InputStream istream = getClass().getResourceAsStream("/FreeSerif.ttf"); byte[] bytes = IOUtils.toByteArray(istream); PdfFont symbol = PdfFontFactory.createFont(bytes, PdfEncodings.IDENTITY_H, true); Text checkbox = new Text("\u2611");// checkbox.setFont(symbol); checkbox.setFontSize(12); Paragraph p = new Paragraph(); p.setMarginTop(20); p.setTextAlignment(TextAlignment.CENTER); Text text = new Text("SOFTWARE TRANSFER AGREEMENT").addStyle(titleStyle); p.add(text); document.add(p); p = new Paragraph(); p.setMarginLeft(56f); text = new Text("Provider: National Cancer Institute (NCI)").addStyle(normalStyle); p.add(text); document.add(p); p = new Paragraph(); p.setMarginLeft(56f); text = new Text("Recipient Institution: ").addStyle(normalStyle); p.add(text); text = new Text(jObject.getInstitution()).addStyle(italicStyle).setUnderline(); p.add(text); document.add(p); p = new Paragraph(); p.setMarginLeft(28f); text = new Text("WHEREAS, Provider has certain proprietary software and associated material described " + "below (hereinafter, collectively referred to as Software) "); text.addStyle(normalStyle); p.add(text).add(new Text("[Describe all items being " + "transferred such as; software, executable code, source code, documentation, data and all " + "other associated materials]").addStyle(italicStyle)); p.add(new Text(":").addStyle(normalStyle)); document.add(p); for (String str : jObject.getSoftwareText()) { p = new Paragraph(); p.setMarginLeft(56f); text = new Text(str); text.addStyle(normalStyle).setBold(); p.add(checkbox).add(text); document.add(p); } p = new Paragraph(); p.setMarginLeft(28f); text = new Text("Provider agrees to transfer such Software to Recipient Investigator, to be used solely in " + "connection with the following research activity and for the following reasons (hereinafter " + "Project)"); text.addStyle(normalStyle); p.add(text).add(new Text("[Describe with specificity the scope of use of Software under this agreement]") .addStyle(italicStyle)); p.add(new Text(":").addStyle(normalStyle)); document.add(p); p = new Paragraph(); p.setMarginLeft(56f); text = new Text(jObject.getPurpose()); text.addStyle(italicStyle).setUnderline(); p.add(text); document.add(p); p = new Paragraph(); p.setMarginLeft(28f); text = new Text("NOW, THEREFORE, in consideration of the premises and mutual covenants contained " + "herein, the Provider and Recipient agree as follows:"); text.addStyle(normalStyle); p.add(text); document.add(p); List mainList = new List(); mainList.setListSymbol(""); List numberedList = new List(ListNumberingType.DECIMAL); numberedList.setMarginLeft(56f); numberedList.addStyle(normalStyle); numberedList.add("SOFTWARE SHALL NOT BE USED FOR TREATING OR DIAGNOSING " + "HUMAN SUBJECTS."); numberedList.add("Recipient will not license or sell or use Software for commercial purposes or " + "applications. Recipient Investigator shall retain control over Software and further " + "will not transfer the Software to individuals not under Recipient Investigators " + "direct supervision without the advance written approval of Provider. Recipient " + "agrees to comply with all regulations applicable to the Project and the use of the " + "Software."); numberedList.add("Recipient agrees not to copy Software, in whole or in part, except as required for " + "use by Recipient Investigator for the conduct of the Project. Recipient shall not " + "modify, extend, decompile, make derivatives of or reverse engineer the Software " + "without written permission from Provider."); numberedList.add("Information deemed confidential under this Agreement (Confidential Information?) " + "shall be clearly marked CONFIDENTIAL.? Any information that is orally " + "disclosed must be reduced to writing and marked CONFIDENTIAL? by the " + "provider of the information within thirty (30) days of such disclosure. To the extent " + "permitted by applicable law, the Recipient agrees to employ all reasonable efforts to " + "safeguard Providers Confidential Information to ensure that no unauthorized " + "person shall have access thereto and that no unauthorized copy, publication, " + "disclosure or distribution, in whole or in part, in any form shall be made."); numberedList.add("In all oral presentations or written publications concerning the Project, Recipient " + "will acknowledge Providers contribution of Software unless requested otherwise. " + "Recipient may publish or otherwise publicly disclose the results of the Project, but " + "if Provider has given Confidential Information to Recipient, such public disclosure " + "may be made only after Provider has had 30 days to review the proposed disclosure, " + "except when a shortened time period under court order or the Freedom of " + "Information Act pertains."); numberedList.add("The obligations of Recipient under Paragraph 4 above shall not extend to any part " + "of the Confidential Information:"); ListItem item1 = new ListItem(); item1.add(numberedList); mainList.add(item1); List subList = new List(ListNumberingType.ENGLISH_LOWER); subList.addStyle(normalStyle); subList.setMarginLeft(84f); subList.add("that can be demonstrated to have been publicly known at the time of " + "disclosure; or"); subList.add("that can be demonstrated to have been properly in the Recipients " + "possession or that can be demonstrated to have been readily available to the " + "Recipient from another proper source prior to the disclosure; or"); subList.add("that becomes part of the public domain or publicly known by publication or " + "otherwise, not due to any unauthorized act by the Recipient or its " + "subsidiaries; or"); subList.add("that can be demonstrated as independently developed or acquired by the " + "Recipient without reference to or reliance upon such information; or"); subList.add("that is required to be disclosed by law, provided that the Recipient takes " + "reasonable and lawful actions to avoid and/or minimize such disclosure."); ListItem item2 = new ListItem(); item2.add(subList); mainList.add(item2); numberedList = new List(ListNumberingType.DECIMAL); numberedList.setMarginLeft(56f); numberedList.addStyle(normalStyle); numberedList.setItemStartIndex(7); numberedList.add("The Recipients obligations under Paragraphs 4 and 5 shall extend for a period of " + "three (3) years from the date of disclosure."); numberedList.add("Title in the Software shall remain with the Provider. It is understood that nothing " + "herein shall be deemed to constitute, by implication or otherwise, the grant to either " + "Party by the other of any license or other rights under any patent, patent application " + "or other intellectual property right or interest. Provider reserves the right to " + "distribute Software to others and to use it for Providers own purposes."); numberedList.add("When the Project is completed or this Agreement is terminated, whichever occurs " + "first, Recipient will destroy all copies of Software and Providers Confidential " + "Information unless directed otherwise by Provider in writing."); numberedList.add("This Agreement may be terminated by either Recipient or Provider by providing 30 " + "days advance notice."); numberedList.add("The Provider and Recipient each shall retain title to any patent or other intellectual " + "property of their respective employees developed or created in the course of the " + "Project defined in this Agreement. Neither Provider nor Recipient promise rights in " + "advance for inventions developed under this Agreement."); numberedList.add("No indemnification for any loss, claim, damage, or liability is intended or provided " + "by any party under this Agreement. Each party shall be liable for any loss, claim, " + "damage, or liability that said party incurs as a result of said partys activities under " + "this Agreement, except that the NIH, as an agency of the United States, assumes " + "liability only to the extent as provided under the United States Federal Tort Claims " + "Act (28 U.S.C. Chapter 171)."); numberedList.add("Software is supplied AS IS, without any accompanying services or improvements\n" + "from Provider. SOFTWARE IS SUPPLIED TO RECIPIENT WITH NO\n" + "WARRANTIES, EXPRESS OR IMPLIED, INCLUDING ANY WARRANTY OF\n" + "MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Provider\n" + "makes no representations that the use of Software will not infringe any patent or\n" + "proprietary rights of third parties."); ListItem item3 = new ListItem(); item3.add(numberedList); mainList.add(item3); document.add(mainList); p = new Paragraph(); p.setMarginTop(20); p.setTextAlignment(TextAlignment.CENTER); text = new Text("Signatures Begin on Next Page").addStyle(titleStyle).setFontSize(12); p.add(text); document.add(p); document.add(new AreaBreak(AreaBreakType.NEXT_PAGE)); p = new Paragraph(); p.setMarginTop(20f); p.setMarginLeft(28f); text = new Text("For Recipient:").addStyle(titleStyle); p.add(text); document.add(p); p = new Paragraph(); p.setMarginLeft(28f); text = new Text("Authorized Official for Recipient:").addStyle(italicStyle); p.add(text); document.add(p); p = new Paragraph(); p.setMarginTop(10); p.setMarginLeft(28f); text = new Text("Name: _________________________________________ Title: _____________________\n") .addStyle(normalStyle); p.add(text); text = new Text("Signature: ______________________________________ Date: _____________________") .addStyle(normalStyle); p.add(text); document.add(p); p = new Paragraph(); p.setMarginLeft(28f); p.setMarginTop(10); text = new Text("Read and Understood by Recipient Investigator:").addStyle(italicStyle); p.add(text); document.add(p); p = new Paragraph(); p.setMarginLeft(28f); p.setMarginTop(10); p.add(new Text("Name: ").addStyle(normalStyle)).add(new Text(jObject.getFirst()).addStyle(italicStyle)) .add(new Text(" ")).add(new Text(jObject.getLast()).addStyle(italicStyle)).add(new Tab()) .add(new Text("Title: ").addStyle(normalStyle)) .add(new Text(jObject.getTitle()).addStyle(italicStyle)).add(new Text("\n")); text = new Text("Signature: ____________________________________ Date: _____________________") .addStyle(normalStyle); p.add(text); document.add(p); p = new Paragraph(); p.setMarginLeft(28f); p.setMarginTop(10); text = new Text("Recipients Mailing Address for Legal Notices:").addStyle(normalStyle); p.add(text); document.add(p); p = new Paragraph(); p.setMarginLeft(28f); p.setMarginTop(10); text = new Text(jObject.getAddress()).addStyle(italicStyle); p.add(text); document.add(p); p = new Paragraph(); p.setMarginLeft(28f); p.setMarginTop(10); p.add(new Text("Email: ").addStyle(normalStyle)).add(new Text(jObject.getEmail()).addStyle(italicStyle)) .add(new Tab()).add(new Text("Phone: ").addStyle(normalStyle)) .add(new Text(jObject.getPhone()).addStyle(italicStyle)); document.add(p); p = new Paragraph(); p.setMarginLeft(28f); p.setMarginTop(20); text = new Text("For Provider:").addStyle(titleStyle); p.add(text); document.add(p); p = new Paragraph(); p.setMarginLeft(28f); text = new Text("Authorized Official for Provider:").addStyle(italicStyle); p.add(text); document.add(p); p = new Paragraph(); p.setMarginLeft(28f); text = new Text("Name: _________________________________________ Title: _____________________\n") .addStyle(normalStyle); p.add(text); text = new Text("Signature: ______________________________________ Date: _____________________") .addStyle(normalStyle); p.add(text); document.add(p); p = new Paragraph(); p.setMarginLeft(28f); p.setMarginTop(10); text = new Text("Read and Understood by Providers Investigator:").addStyle(italicStyle); p.add(text); document.add(p); p = new Paragraph(); p.setMarginLeft(28f); p.setMarginTop(10); text = new Text("Signature: ______________________________________ Date: _____________________\n" + "Choonsik Lee, PhD\n" + "Senior Investigator\n" + "Radiation Epidemiology Branch\n" + "Division of Cancer Epidemiology & Genetics, NCI, NIH").addStyle(normalStyle); p.add(text); document.add(p); p = new Paragraph(); p.setMarginLeft(28f); text = new Text("Providers Mailing Address for Legal Notices:").addStyle(normalStyle); p.add(text); document.add(p); p = new Paragraph(); p.setMarginLeft(56f); text = new Text( "National Institutes of Health\n" + "National Cancer Institute\n" + "Technology Transfer Center\n" + "9609 Medical Center Dr. Rm 1E530, MSC 9702 Bethesda, MD 20892-9702\n" + "Phone: 240-276-5530 Fax: 240-276-5504").addStyle(normalStyle); p.add(text); document.add(p); addPageNumbers(pdfDoc); document.close(); }
From source file:output.InvoicePDF.java
/** * * @param dest/* ww w .j ava 2 s . com*/ * @throws IOException */ public void generatePDF(String dest) throws FileNotFoundException, MalformedURLException, IOException { PdfWriter writer = new PdfWriter(dest); PdfDocument pdf = new PdfDocument(writer); Document document = new Document(pdf); Image image = new Image(ImageDataFactory.create(LOGO)); image.setWidthPercent(50); image.setHorizontalAlignment(HorizontalAlignment.CENTER); document.add(image); document.add(clientInformation()); document.add(quoteSection()); document.add(new Paragraph(terms())); document.close(); }
From source file:qcas.EndTestController.java
@FXML public void displayPdf() { FileChooser chooser = new FileChooser(); FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("PDF file(*.pdf)", " *.pdf "); chooser.getExtensionFilters().add(extFilter); File file = chooser.showSaveDialog(new Stage()); try {//from w ww . ja v a2s . com WritableImage img = StudentResult.snapshot(null, null); ImageData imgData = ImageDataFactory.create(SwingFXUtils.fromFXImage(img, null), null); com.itextpdf.layout.element.Image pdfImg = new com.itextpdf.layout.element.Image(imgData); System.out.println("Entered 3 "); PdfWriter writer = new PdfWriter(new FileOutputStream(file)); PdfDocument pdfDoc = new PdfDocument(writer); Document doc = new Document(pdfDoc); doc.add(new Paragraph("Hello world, " + "this is a test pdf file.")); doc.add(pdfImg); doc.close(); } catch (Exception exc) { exc.printStackTrace(); } }
From source file:quiz.results.view.QuizSummaryViewController.java
/** * * @param e//from w ww. j av a2 s . c o m */ @FXML public void saveToPdf(ActionEvent e) { FileChooser chooser = new FileChooser(); chooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("PDF files", "*.pdf")); File file = chooser.showSaveDialog(application.stage); if (file != null) { try { // take the snapshot of the result frame and add it to the pdf WritableImage img = resultFrame.snapshot(null, null); ImageData imgData = ImageDataFactory.create(SwingFXUtils.fromFXImage(img, null), null); com.itextpdf.layout.element.Image pdfImg = new com.itextpdf.layout.element.Image(imgData); PdfWriter writer = new PdfWriter(new FileOutputStream(file)); PdfDocument pdfDoc = new PdfDocument(writer); Document doc = new Document(pdfDoc); doc.add(pdfImg); doc.close(); } catch (Exception exc) { exc.printStackTrace(); } } }
From source file:quiz.student.result.NoOfTestTakenController.java
/** * This method exports the statistics to pdf * @param e ActionEvent/* w w w. j a v a 2s. c o m*/ */ @FXML public void viewStats(ActionEvent e) { FileChooser chooser = new FileChooser(); chooser.getExtensionFilters().add(new ExtensionFilter("PDF files", "*.pdf")); File file = chooser.showSaveDialog(application.stage); if (file != null) { try { WritableImage img = Display.snapshot(null, null); ImageData imgData = ImageDataFactory.create(SwingFXUtils.fromFXImage(img, null), null); com.itextpdf.layout.element.Image pdfImg = new com.itextpdf.layout.element.Image(imgData); PdfWriter writer = new PdfWriter(new FileOutputStream(file)); PdfDocument pdfDoc = new PdfDocument(writer); Document doc = new Document(pdfDoc); doc.add(pdfImg); doc.close(); } catch (Exception exc) { exc.printStackTrace(); } } }
From source file:ru.waytosky.itext.Main.java
public static void main(String[] args) throws FileNotFoundException, MalformedURLException { // Document document = new Document(PageSize.A4, 20, 20, 20, 20); // PdfWriter.getInstance(document, new FileOutputStream("C:/test.pdf")); // document.open(); // Image image = Image.getInstance(getClass().getResource("/logo.png")); // document.add(image); // document.close(); //Initialize PDF writer String dest = "hello.pdf"; PdfWriter writer = new PdfWriter(dest); //Initialize PDF document PdfDocument pdf = new PdfDocument(writer); // Initialize document Document document = new Document(pdf); //Add paragraph to the document Image image = new Image(ImageDataFactory.create("darksouls.jpg")); // Image.getInstance(getClass().getResource("/logo.png")); document.add(image);//from ww w . ja v a 2 s . c om //Close document document.close(); }