private void addMetaData(Document document) { document.addTitle("Expense Report"); document.addSubject("Expense Report"); document.addKeywords("Java, PDF, iText"); document.addAuthor("www.Ihalkhata.com"); document.addCreator("www.Ihalkhata.com"); }
private static void addMetaData(Document document) { document.addTitle("Report Eventi"); document.addSubject("Report Eventi selezionati nella console Govpay"); document.addKeywords("Report, Eventi, Govpay"); document.addAuthor("Govpay"); document.addCreator("Govpay"); }
private PdfWorksheet(OutputStream out, Collection<SubjectArea> subjectAreas, String courseNumber) throws IOException, DocumentException { iUseCommitedAssignments = ApplicationProperty.WorksheetPdfUseCommittedAssignments.isTrue(); iSubjectAreas = new TreeSet<SubjectArea>( new Comparator<SubjectArea>() { @Override public int compare(SubjectArea s1, SubjectArea s2) { return s1.getSubjectAreaAbbreviation().compareTo(s2.getSubjectAreaAbbreviation()); } }); iSubjectAreas.addAll(subjectAreas); iCourseNumber = courseNumber; if (iCourseNumber != null && (iCourseNumber.trim().length() == 0 || "*".equals(iCourseNumber.trim().length()))) iCourseNumber = null; iDoc = new Document(PageSize.LETTER.rotate()); iOut = out; PdfWriter.getInstance(iDoc, iOut); String session = null; String subjects = ""; for (SubjectArea sa : iSubjectAreas) { if (subjects.isEmpty()) subjects += ", "; subjects += sa.getSubjectAreaAbbreviation(); if (session == null) session += sa.getSession().getLabel(); } iDoc.addTitle(subjects + (iCourseNumber == null ? "" : " " + iCourseNumber) + " Worksheet"); iDoc.addAuthor( ApplicationProperty.WorksheetPdfAuthor.value().replace("%", Constants.getVersion())); iDoc.addSubject(subjects + (session == null ? "" : " -- " + session)); iDoc.addCreator("UniTime " + Constants.getVersion() + ", www.unitime.org"); if (!iSubjectAreas.isEmpty()) iCurrentSubjectArea = iSubjectAreas.first(); iDoc.open(); printHeader(); }
/** * Shows how a table is split if it doesn't fit the page. * * @param args no arguments needed */ public static void main(String[] args) { System.out.println("table splitting"); // creation of the document with a certain size and certain margins Document document = new Document(PageSize.A4.rotate(), 50, 50, 50, 50); try { // creation of the different writers PdfWriter.getInstance(document, new FileOutputStream("repeatingtable.pdf")); // we add some meta information to the document document.addAuthor("Alan Soukup"); document.addSubject("This is the result of a Test."); document.open(); Table datatable = new Table(10); int headerwidths[] = {10, 24, 12, 12, 7, 7, 7, 7, 7, 7}; datatable.setWidths(headerwidths); datatable.setWidth(100); datatable.setPadding(3); // the first cell spans 10 columns Cell cell = new Cell( new Phrase( "Administration -System Users Report", FontFactory.getFont(FontFactory.HELVETICA, 24, Font.BOLD))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setLeading(30); cell.setColspan(10); cell.setBorder(Rectangle.NO_BORDER); cell.setBackgroundColor(new Color(0xC0, 0xC0, 0xC0)); datatable.addCell(cell); // These cells span 2 rows datatable.getDefaultCell().setBorderWidth(2); datatable.getDefaultCell().setHorizontalAlignment(1); datatable.addCell("User Id"); datatable.addCell("Name\nAddress"); datatable.addCell("Company"); datatable.addCell("Department"); datatable.addCell("Admin"); datatable.addCell("Data"); datatable.addCell("Expl"); datatable.addCell("Prod"); datatable.addCell("Proj"); datatable.addCell("Online"); // this is the end of the table header datatable.endHeaders(); datatable.getDefaultCell().setBorderWidth(1); for (int i = 1; i < 30; i++) { datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); datatable.addCell("myUserId"); datatable.addCell( "Somebody with a very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very long long name"); datatable.addCell("No Name Company"); datatable.addCell("D" + i); datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); datatable.addCell("No"); datatable.addCell("Yes"); datatable.addCell("No"); datatable.addCell("Yes"); datatable.addCell("No"); datatable.addCell("Yes"); } document.add(new Paragraph("com.lowagie.text.Table - Cells split")); document.add(datatable); document.newPage(); document.add(new Paragraph("com.lowagie.text.pdf.PdfPTable - Cells split\n\n")); datatable.setConvert2pdfptable(true); document.add(datatable); document.newPage(); document.add(new Paragraph("com.lowagie.text.Table - Cells kept together")); datatable.setConvert2pdfptable(false); datatable.setCellsFitPage(true); document.add(datatable); document.newPage(); document.add(new Paragraph("com.lowagie.text.pdf.PdfPTable - Cells kept together\n\n")); datatable.setConvert2pdfptable(true); document.add(datatable); } catch (Exception e) { e.printStackTrace(); } // we close the document document.close(); }
public void open() throws DocumentException { this.document = new Document(); // pageSize, marginLeft, marginRight, marginTop, marginBottom)); writer = PdfWriter.getInstance(document, out); writer.setLinearPageMode(); version = getVersion(); writer.setPdfVersion(version); writer.setViewerPreferences(getViewerPreferences()); final String encrypt = config.getConfigProperty( "org.pentaho.reporting.engine.classic.core.modules.output.pageable.pdf.Encryption"); if (encrypt != null) { if (encrypt.equals(PdfPageableModule.SECURITY_ENCRYPTION_128BIT) == true || encrypt.equals(PdfPageableModule.SECURITY_ENCRYPTION_40BIT) == true) { final String userpassword = config.getConfigProperty( "org.pentaho.reporting.engine.classic.core.modules.output.pageable.pdf.UserPassword"); final String ownerpassword = config.getConfigProperty( "org.pentaho.reporting.engine.classic.core.modules.output.pageable.pdf.OwnerPassword"); // Log.debug ("UserPassword: "******" - OwnerPassword: "******"org.pentaho.reporting.engine.classic.core.modules.output.pageable.pdf.Title", config.getConfigProperty("org.pentaho.reporting.engine.classic.core.metadata.Title")); final String subject = config.getConfigProperty( "org.pentaho.reporting.engine.classic.core.modules.output.pageable.pdf.Description", config.getConfigProperty( "org.pentaho.reporting.engine.classic.core.metadata.Description")); final String author = config.getConfigProperty( "org.pentaho.reporting.engine.classic.core.modules.output.pageable.pdf.Author", config.getConfigProperty("org.pentaho.reporting.engine.classic.core.metadata.Author")); final String keyWords = config.getConfigProperty( "org.pentaho.reporting.engine.classic.core.modules.output.pageable.pdf.Keywords", config.getConfigProperty( "org.pentaho.reporting.engine.classic.core.metadata.Keywords")); if (title != null) { document.addTitle(title); } if (author != null) { document.addAuthor(author); } if (keyWords != null) { document.addKeywords(keyWords); } if (keyWords != null) { document.addSubject(subject); } document.addCreator(PdfDocumentWriter.CREATOR); document.addCreationDate(); // getDocument().open(); awaitOpenDocument = true; }