List of usage examples for com.itextpdf.text Document addSubject
public boolean addSubject(String subject)
From source file:eu.geopaparazzi.plugins.pdfexport.PdfExportDialogFragment.java
License:Open Source License
private void startExport() { final Context context = getContext(); new AsyncTask<String, Void, String>() { protected String doInBackground(String... params) { File pdfOutputFile = null; try { boolean hasAtLeastOne = false; /*/*from w w w.j a v a 2 s .c o m*/ * get notes */ List<Note> notesList = DaoNotes.getNotesList(null, false); if (notesList.size() == 0) { return NODATA; } if (isInterrupted) return INTERRUPTED; File pdfExportDir = ResourcesManager.getInstance(getActivity()).getMainStorageDir(); String filename = ResourcesManager.getInstance(getActivity()).getApplicationName() + "_projectexport_" + TimeUtilities.INSTANCE.TIMESTAMPFORMATTER_LOCAL.format(new Date()) + ".pdf"; pdfOutputFile = new File(pdfExportDir, filename); if (exportPath != null) { pdfOutputFile = new File(exportPath); } // TODO export list to pdf Document document = new Document(); document.setMargins(36, 36, 36, 36); PdfWriter.getInstance(document, new FileOutputStream(pdfOutputFile)); document.open(); document.addTitle("Geopaparazzi PDF Export"); document.addSubject("Geopaparazzi PDF Export"); document.addKeywords("geopaparazzi, export, notes"); document.addAuthor("Geopaparazzi User"); document.addCreator("Geopaparazzi - http://www.geopaparazzi.eu"); int index = 1; for (Note note : notesList) { processNote(document, note, index++); } document.close(); return pdfOutputFile.getAbsolutePath(); } catch (Exception e) { // cleanup as it might be inconsistent if (pdfOutputFile != null && pdfOutputFile.exists()) { pdfOutputFile.delete(); } GPLog.error(this, e.getLocalizedMessage(), e); e.printStackTrace(); return ""; //$NON-NLS-1$ } } protected void onPostExecute(String response) { // on UI thread! progressBar.setVisibility(View.GONE); if (response.equals(NODATA)) { String msg = context.getString(R.string.no_data_found_in_project_to_export); alertDialog.setMessage(msg); } else if (response.equals(INTERRUPTED)) { alertDialog.setMessage(context.getString(R.string.interrupted_by_user)); } else if (response.length() > 0) { String msg = context.getString(R.string.datasaved) + " " + response; alertDialog.setMessage(msg); } else { String msg = context.getString(R.string.data_nonsaved); alertDialog.setMessage(msg); } if (positiveButton != null) positiveButton.setEnabled(true); } }.execute((String) null); }
From source file:eu.trentorise.smartcampus.citizenportal.service.PdfCreator.java
private static void addMetaData(Document document) { document.addTitle("Graduatoria Provvisoria"); document.addSubject("Using iText"); document.addKeywords("Graduatoria, Provvisoria, Edilizia Pubblica"); document.addAuthor("Comunita Della Vallagarina"); document.addCreator("Comunita Della Vallagarina"); }
From source file:generadorPDF.generarPDF.java
private static void addMetaData(Document document) { document.addTitle("My first PDF"); document.addSubject("Using iText"); document.addKeywords("Java, PDF, iText"); document.addAuthor("Lars Vogel"); document.addCreator("Lars Vogel"); }/* w w w.j av a2 s . co m*/
From source file:GUI.Carburant.java
private static void addMetaData(Document document) { document.addTitle("Carburant PDF"); document.addSubject("subject"); document.addKeywords("Car Fleet Management, PDF, JAVA"); document.addAuthor("Marwen"); document.addCreator("Marwen"); }
From source file:GUI.Cars.java
private static void addMetaData(Document document) { document.addTitle("Cars PDF"); document.addSubject("subject"); document.addKeywords("Car Fleet Management, PDF, JAVA"); document.addAuthor("Marwen"); document.addCreator("Marwen"); }
From source file:GUI.Fixings.java
private static void addMetaData(Document document) { document.addTitle("Fixing PDF"); document.addSubject("subject"); document.addKeywords("Car Fleet Management, PDF, JAVA"); document.addAuthor("Marwen"); document.addCreator("Marwen"); }
From source file:has.GenerateReceipt.java
private static void addMetaData(Document document) { document.addTitle("RECEPIT "); document.addSubject("Using iText"); document.addKeywords("Java, PDF, iText"); document.addAuthor("Kesava"); document.addCreator("Kesava"); }
From source file:ics4u.ics4u_final_project.Recipe.java
License:Open Source License
private void addMetaData(Document doc) { //add all the meta data of the docmuent doc.addTitle(title);/*from w ww. j a v a2s . c o m*/ doc.addSubject("Recipies"); doc.addKeywords("recipe, " + title); doc.addAuthor("Isaac Wismer"); doc.addCreator("Nutrient Calculator. Made using the iTextPDF Library 5.5.8 http://itextpdf.com/"); }
From source file:info.sarihh.unimodeling.gui.DynamicBPEstimateFrame.java
public static void writeChartAsPDF(OutputStream out, JFreeChart chart, int width, int height, FontMapper mapper) throws IOException { Rectangle pagesize = new Rectangle(width, height); Document document = new Document(pagesize, 50, 50, 50, 50); try {/* ww w. j a v a 2 s . c om*/ PdfWriter writer = PdfWriter.getInstance(document, out); document.addAuthor("JFreeChart"); document.addSubject("Demonstration"); document.open(); PdfContentByte cb = writer.getDirectContent(); PdfTemplate tp = cb.createTemplate(width, height); Graphics2D g2 = tp.createGraphics(width, height, mapper); Rectangle2D r2D = new Rectangle2D.Double(0, 0, width, height); chart.draw(g2, r2D, null); g2.dispose(); cb.addTemplate(tp, 0, 0); } catch (DocumentException de) { System.err.println(de.getMessage()); } document.close(); }
From source file:itext_result.Main.java
private int developScreeningSheet() { new SwingWorker<Object, Object>() { String filename;//from w w w . j a v a 2 s . c om @Override protected void done() { // ConsoleMsg("Printing PROFILE SHEET IN PROGRESS.. "); } public PdfPCell createBarcode(PdfWriter writer, String code) throws DocumentException, IOException { BarcodeEAN barcode = new BarcodeEAN(); barcode.setCodeType(Barcode.EAN8); barcode.setCode(code); PdfPCell cell = new PdfPCell( barcode.createImageWithBarcode(writer.getDirectContent(), BaseColor.BLACK, BaseColor.GRAY), true); cell.setPadding(10); return cell; } class ImageContent implements PdfPTableEvent { protected com.itextpdf.text.Image content; public ImageContent(com.itextpdf.text.Image content) { this.content = content; } public void tableLayout(PdfPTable table, float[][] widths, float[] heights, int headerRows, int rowStart, PdfContentByte[] canvases) { try { PdfContentByte canvas = canvases[PdfPTable.TEXTCANVAS]; float x = widths[3][1] + 10; float y = heights[3] - 10 - content.getScaledHeight(); content.setAbsolutePosition(x, y); canvas.addImage(content); } catch (DocumentException e) { throw new ExceptionConverter(e); } } } @Override protected Object doInBackground() throws Exception { // System.err.println(" Roll No Received ....." + rollno); Document doc = new Document(); try { PdfWriter writer = PdfWriter.getInstance(doc, new FileOutputStream("12345" + ".pdf")); doc.open(); doc.addTitle("Recruitment PET Sheett - " + "Created By SOS : "); doc.addSubject("Confidential Report Eyes Only"); doc.addKeywords(""); doc.addAuthor("SOS"); doc.addCreator("SOS"); // A4 = 210mm x 297mm ~ 605points x 855points doc.setPageSize(PageSize.A5); doc.setMargins(15f, 15f, 15f, 15f); ///////////////////////////////////////////////////////////// int pageno = 1; for (int i = 0; i == pageno; i++) { // doc.add(imageRight); } PdfContentByte cb = writer.getDirectContent(); //DONE BarcodeEAN codeEAN = new BarcodeEAN(); codeEAN.setCodeType(Barcode.EAN8); Barcode128 code128 = new Barcode128(); code128.setCode(String.valueOf("123456")); Barcode128 code128_jacket = new Barcode128(); code128_jacket.setCode(String.valueOf("10345")); codeEAN.setCode(String.valueOf("123456")); com.itextpdf.text.Image imageEAN = code128.createImageWithBarcode(cb, null, null); // imageEAN.scalePercent(10f); //464f, 725f // imageEAN.setAbsolutePosition(474f, 662f); int i = 1; while (i <= pageno) { doc.newPage(); // cb.addImage(imageRight); // cb.addImage(imageEAN); i++; } com.itextpdf.text.Image carcode = code128_jacket.createImageWithBarcode(cb, null, null); carcode.scaleAbsolute(100f, 35f); carcode.setAbsolutePosition(500f, 600f); writer.addDirectImageSimple(carcode); // cb.addImage(carcode); com.itextpdf.text.Image carcode2 = code128.createImageWithBarcode(cb, null, null); carcode2.scaleAbsolute(100f, 35f); carcode2.setAbsolutePosition(450f, 760f); writer.addDirectImageSimple(carcode2); // cb.addImage(carcode2); Image image1 = Image.getInstance("jklogo.gif"); PdfPTable table = new PdfPTable(1); table.setWidthPercentage(99); table.addCell(image1); doc.add(table); table = new PdfPTable(4); table.setWidthPercentage(99); float[] columnWidths = { 6, 2 }; PdfPTable CandidateTable = new PdfPTable(columnWidths); Font f = new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL, GrayColor.BLACK); Font fsmall = new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL, GrayColor.BLACK); PdfPCell rollno = new PdfPCell(new Phrase("Roll No# " + String.valueOf("123456"), fsmall)); PdfPCell cname = new PdfPCell(new Phrase("Name #" + String.valueOf("John Doe"), fsmall)); // DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy"); // String today = formatter.format(cInfo.getDob()); PdfPCell dob = new PdfPCell(new Phrase("DOB#" + String.valueOf("12-03-1989"), fsmall)); PdfPCell fname = new PdfPCell(new Phrase("F/H Name #" + String.valueOf("Big John"), fsmall)); PdfPCell type = new PdfPCell(new Phrase("Total Time #" + String.valueOf("350.00"), fsmall)); // String scrtoday = formatter.format(cInfo.getScreeningdate()); // System.out.println("Today : " + today); PdfPCell scrdate = new PdfPCell(new Phrase("Laps #" + String.valueOf("4"), fsmall)); PdfPCell cell = new PdfPCell(new Phrase(" ", fsmall)); rollno.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); cname.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); rollno.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); dob.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); fname.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); type.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); scrdate.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); cell.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); CandidateTable.addCell(rollno); CandidateTable.addCell(cell); CandidateTable.addCell(cname); CandidateTable.addCell(cell); CandidateTable.addCell(dob); CandidateTable.addCell(cell); PdfPTable CandidateOtherTable = new PdfPTable(columnWidths); CandidateOtherTable.addCell(fname); CandidateOtherTable.addCell(cell); CandidateOtherTable.addCell(scrdate); CandidateOtherTable.addCell(cell); CandidateOtherTable.addCell(type); CandidateOtherTable.addCell(cell); PdfPCell race_start_time = new PdfPCell(new Phrase("Start Time :XX-XX-XX ", fsmall)); PdfPCell race_end_time = new PdfPCell(new Phrase("End Time :XX-XX-XX", fsmall)); PdfPCell race_total_time = new PdfPCell(new Phrase("Total Time : 350.00 ", fsmall)); race_start_time.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); race_end_time.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); race_total_time.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); PdfPTable CandidateRaceDetails = new PdfPTable(columnWidths); CandidateRaceDetails.addCell(race_start_time); CandidateRaceDetails.addCell(cell); CandidateRaceDetails.addCell(race_end_time); CandidateRaceDetails.addCell(cell); CandidateRaceDetails.addCell(race_total_time); CandidateRaceDetails.addCell(cell); PdfPTable tablewith3cells = new PdfPTable(3); //1 St Col for Roll No Name and DOB tablewith3cells.addCell(CandidateTable); //2 nd Col for Father Name sCREEning Date Gurkha tablewith3cells.addCell(CandidateOtherTable); //3rd Col for Barcode to be Printed tablewith3cells.addCell(CandidateRaceDetails); // Setting the Width here to 101 tablewith3cells.setWidthPercentage(99); doc.add(tablewith3cells); PdfPTable userArea = new PdfPTable(1); userArea.setWidthPercentage(99); userArea.addCell(" \n \n Congratulations \n \n "); doc.add(userArea); PdfPTable footerCSBC = new PdfPTable(2); footerCSBC.setWidthPercentage(99); PdfPCell height_box = new PdfPCell(new Phrase("Height \n\n\n", f)); height_box.setBorder(com.itextpdf.text.Rectangle.BOX); PdfPCell chest_box = new PdfPCell(new Phrase("Chest \n\n\n", f)); chest_box.setBorder(com.itextpdf.text.Rectangle.BOX); PdfPCell chest_exp_box = new PdfPCell(new Phrase("Chest Exp \n\n\n", f)); chest_exp_box.setBorder(com.itextpdf.text.Rectangle.BOX); PdfPCell pushup_box = new PdfPCell(new Phrase("Pushup \n\n\n", f)); pushup_box.setBorder(com.itextpdf.text.Rectangle.BOX); //CSignatureBox.setBorder(com.itextpdf.text.Rectangle.BOX); // ASignatureBox.setBorder(com.itextpdf.text.Rectangle.BOX); footerCSBC.addCell(height_box); footerCSBC.addCell(chest_box); footerCSBC.addCell(chest_exp_box); footerCSBC.addCell(pushup_box); doc.add(footerCSBC); float[] columnWidths_ForBarcode = { 6, 3 }; PdfPTable terminalinfo = new PdfPTable(columnWidths_ForBarcode); // terminalinfo.setWidthPercentage(99); String computername = InetAddress.getLocalHost().getHostName(); System.out.println(computername); PdfPCell pcname = new PdfPCell(new Phrase("\t Jacket \n\n ", f)); String UserMatchScore = "\t Barcode\n\n"; PdfPCell score = new PdfPCell(new Phrase(UserMatchScore, f)); PdfPCell barcode = new PdfPCell(carcode2); PdfPCell jacketnumber = new PdfPCell(carcode); pcname.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); score.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); barcode.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); jacketnumber.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); terminalinfo.addCell(score); terminalinfo.addCell(pcname); terminalinfo.addCell(barcode); terminalinfo.addCell(jacketnumber); doc.add(terminalinfo); PdfPCell eula_notice = new PdfPCell(new Phrase(" ", f)); eula_notice.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); cell.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPTable eula_notice_table = new PdfPTable(1); eula_notice_table.setWidthPercentage(25); eula_notice_table.addCell(eula_notice); doc.add(eula_notice_table); } catch (Exception e) { System.err.println(e.getMessage()); // ConsoleMsg(e.getMessage()); } finally { doc.close(); doc.close(); doc.close(); } //ConsoleMsg("PDF... GENERATED"); return null; // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }.execute(); return 0; }