List of usage examples for com.lowagie.text Document addCreationDate
public boolean addCreationDate()
From source file:org.openepics.discs.names.ui.ReportManager.java
License:Open Source License
public void preProcessPDF(Object document) throws IOException, BadElementException, DocumentException { Document pdf = (Document) document; pdf.setPageSize(PageSize.LETTER.rotate()); // pdf.open(); // pdf.setPageSize(PageSize.LETTER.rotate()); pdf.addCreationDate(); pdf.addHeader("Header", "Proteus: Naming Convention Rep"); pdf.addTitle("Proteus: Naming Convention Report"); // ServletContext servletContext = (ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext(); // String logo = servletContext.getRealPath("") + File.separator + "images" + File.separator + "prime_logo.png"; // pdf.add(Image.getInstance(logo)); }
From source file:org.silverpeas.components.almanach.control.AlmanachPdfGenerator.java
License:Open Source License
static public void buildPdf(String name, AlmanachSessionController almanach, String mode) throws AlmanachRuntimeException { try {// w w w . j av a 2 s.c o m String fileName = FileRepositoryManager.getTemporaryPath(almanach.getSpaceId(), almanach.getComponentId()) + name; Document document = new Document(PageSize.A4, 50, 50, 50, 50); // we add some meta information to the document document.addAuthor(almanach.getSettings().getString("author", "")); document.addSubject(almanach.getSettings().getString("subject", "")); document.addCreationDate(); PdfWriter.getInstance(document, new FileOutputStream(fileName)); document.open(); try { Calendar currentDay = Calendar.getInstance(); currentDay.setTime(almanach.getCurrentDay()); String sHeader = almanach.getString("events"); if (mode.equals(PDF_MONTH_ALLDAYS) || mode.equals(PDF_MONTH_EVENTSONLY)) { sHeader += " " + almanach.getString("GML.mois" + currentDay.get(Calendar.MONTH)); } sHeader += " " + currentDay.get(Calendar.YEAR); HeaderFooter header = new HeaderFooter(new Phrase(sHeader), false); HeaderFooter footer = new HeaderFooter(new Phrase("Page "), true); footer.setAlignment(Element.ALIGN_CENTER); document.setHeader(header); document.setFooter(footer); createFirstPage(almanach, document); document.newPage(); Font titleFont = new Font(Font.HELVETICA, 24, Font.NORMAL, new Color(255, 255, 255)); Paragraph cTitle = new Paragraph(almanach.getString("Almanach") + " " + almanach.getString("GML.mois" + currentDay.get(Calendar.MONTH)) + " " + currentDay.get(Calendar.YEAR), titleFont); Chapter chapter = new Chapter(cTitle, 1); // Collection<EventDetail> events = // almanach.getListRecurrentEvent(mode.equals(PDF_YEAR_EVENTSONLY)); AlmanachCalendarView almanachView; if (PDF_YEAR_EVENTSONLY.equals(mode)) { almanachView = almanach.getYearlyAlmanachCalendarView(); } else { almanachView = almanach.getMonthlyAlmanachCalendarView(); } List<DisplayableEventOccurrence> occurrences = almanachView.getEvents(); generateAlmanach(chapter, almanach, occurrences, mode); document.add(chapter); } catch (Exception ex) { throw new AlmanachRuntimeException("PdfGenerator.generate", AlmanachRuntimeException.WARNING, "AlmanachRuntimeException.EX_PROBLEM_TO_GENERATE_PDF", ex); } document.close(); } catch (Exception e) { throw new AlmanachRuntimeException("PdfGenerator.generate", AlmanachRuntimeException.WARNING, "AlmanachRuntimeException.EX_PROBLEM_TO_GENERATE_PDF", e); } }
From source file:pentaho.kettle.step.plugs.pdfout.PDFOutputGenerate.java
License:Apache License
public void generatePDF(String OutputFileName) throws IOException { if (Const.isWindows()) { if (OutputFileName.startsWith("file:///")) OutputFileName = OutputFileName.substring(8); OutputFileName = OutputFileName.replace("\\", "\\\\"); }/* w w w .j ava 2 s .c om*/ Document document = new Document(); PdfWriter writer; try { writer = PdfWriter.getInstance(document, new FileOutputStream(OutputFileName)); document.open(); document.add(new Paragraph("Hello Rishu Here !!")); /* * Setting up File Attributes - Document Description */ document.addAuthor("Rishu Shrivastava"); document.addCreationDate(); document.addCreator("Rishu"); document.addTitle("Set Attribute Example"); document.addSubject("An example to show how attributes can be added to pdf files."); document.close(); writer.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } }