List of usage examples for com.lowagie.text Paragraph setIndentationRight
public void setIndentationRight(float indentation)
From source file:com.amphisoft.epub2pdf.content.XhtmlHandler.java
License:Open Source License
@Override public void startElement(String uri, String localName, String qName, Attributes attributes) { /*//from ww w . j a v a 2s. c om if("ol".equals(qName) || "ul".equals(qName) || "li".equals(qName)) { System.err.print(qName + " "); } */ currentSaxElemId = saxElemIdCounter; Map<String, String> attrMap = new HashMap<String, String>(); // parse attributes for (int ai = 0; ai < attributes.getLength(); ai++) { attrMap.put(attributes.getQName(ai), attributes.getValue(ai)); } String idAttr = attrMap.get("id"); if (idAttr == null) { idAttr = ""; } String className = attrMap.get("class"); if (className == null) { className = ""; } SaxElement sE = new SaxElement(qName, saxElemIdCounter++, className, idAttr, currentITextStyle); //printlnerr("startElement: " + sE.toString()); saxElementStack.push(sE); try { if (attrMap.get("class") != null) { String[] elemClasses = attrMap.get("class").split(" "); for (String eClass : elemClasses) { StyleSpecText classTextStyles = styleMap.getTextStyleSpecFor(qName, eClass); if (classTextStyles != null) { sE.applyTextStyles(classTextStyles); } } } if (attrMap.get("style") != null) { // TODO this needs more thought, and careful tracking of which tags are still open, etc. //String styleSource = attrMap.get("style"); //CssStyleMap styleTagStyles = cssParser.getStylesFromStyleTag(styleSource); // ... } if (sE.textStyles == null) { try { int stackSize = saxElementStack.size(); if (stackSize > 1) { SaxElement enclosingElement = saxElementStack.elementAt(stackSize - 2); StyleSpecText enclosingSST = enclosingElement.textStyles; if (enclosingSST != null) sE.applyTextStyles(enclosingSST); } } catch (Exception e) { } } StyleSpecText currentTextStyles = sE.textStyles; if (currentTextStyles != null) { if (currentTextStyles.isBold()) { currentITextStyle |= Font.BOLD; } if (currentTextStyles.isItalic()) { currentITextStyle |= Font.ITALIC; } } //System.err.println("PUSH -> " + saxElementStack); previousTag = currentTag; currentTag = qName; if (document.isOpen()) { if (XhtmlTags.NEWLINE.equals(qName)) { if (stack.size() > 0) { TextElementArray currentTEA = (TextElementArray) stack.peek(); currentTEA.add(Chunk.NEWLINE); } else if (specialParagraph != null) { specialParagraph.add(Chunk.NEWLINE); } } updateStack(); String xmlElementId = attrMap.get("id"); if (XhtmlTags.ANCHOR.equals(qName)) { //concession to nonconformists... if (xmlElementId == null) { xmlElementId = attrMap.get("name"); } Anchor anchor = textFactory.newAnchor(); String ref = attrMap.get(XhtmlTags.REFERENCE); if (ref != null) { int aNameStartIdx = ref.lastIndexOf("#") + 1; ref = ref.substring(aNameStartIdx); anchor.setReference(ref); } if (xmlElementId != null) { anchor.setName(xmlElementId); } pushToStack(anchor); } else { if (xmlElementId != null) { //flushStack(); Anchor dest = textFactory.newAnchor(); dest.setName(xmlElementId); pushToStack(dest); //flushStack(); } for (int i = 0; i < 6; i++) { if (XhtmlTags.H[i].equals(qName)) { flushStack(); freshParagraph = true; currentITextStyle |= Font.BOLD; specialParagraph = textFactory.newHeadline(i + 1); return; } } if ("blockquote".equals(qName)) { flushStack(); freshParagraph = true; Paragraph p = textFactory.newParagraph(); p.setIndentationLeft(50); p.setIndentationRight(20); p.setAlignment(defaultAlignment); pushToStack(p); } else if (XhtmlTags.PARAGRAPH.equals(qName)) { flushStack(); freshParagraph = true; Paragraph p = textFactory.newParagraph(); pushToStack(p); } else if (XhtmlTags.DIV.equals(qName)) { if (stack.size() > 0 && stack.peek().getChunks().size() > 0) { flushStack(); } if (stack.size() == 0) { Paragraph brandNewParagraph = textFactory.newParagraph(); pushToStack(brandNewParagraph); freshParagraph = true; } } else if (XhtmlTags.PRE.equals(qName)) { flushStack(); freshParagraph = true; Paragraph p = textFactory.newParagraphPre(); pushToStack(p); } else if (XhtmlTags.ORDEREDLIST.equals(qName)) { flushStack(); List oList = new List(List.ORDERED, 10); pushToStack(oList); } else if (XhtmlTags.UNORDEREDLIST.equals(qName)) { flushStack(); List uList = new List(List.UNORDERED, 10); pushToStack(uList); } else if (XhtmlTags.LISTITEM.equals(qName)) { freshParagraph = true; ListItem listItem = new ListItem(); pushToStack(listItem); } else if (XhtmlTags.IMAGE.equals(qName)) { handleImage(attributes); } else if (qName != null && qName.endsWith("image")) { handleSvgImage(attributes); } else if (XhtmlTags.LINK.equals(qName)) { // if it's a stylesheet, parse it & update current-style if ("stylesheet".equals(attrMap.get("rel")) && "text/css".equals(attrMap.get("type")) && attrMap.get("href") != null) { String cssHref = xhtmlDir.getAbsoluteFile().toURI().toString() + attrMap.get("href"); CssStyleMap stylesFromLink = cssParser.getStylesFromFileURI(cssHref); if (stylesFromLink != null) { styleMap.updateWith(stylesFromLink); } } } else if (XhtmlTags.STYLE.equals(qName)) { inStyleTag = true; } else if (XhtmlTags.EM.equals(qName) || "I".equals(qName.toUpperCase())) { currentITextStyle |= Font.ITALIC; } else if (XhtmlTags.STRONG.equals(currentTag) || "B".equals(qName.toUpperCase())) { currentITextStyle |= Font.BOLD; } } } else if (XhtmlTags.BODY.equals(qName)) { document.open(); freshParagraph = true; } } catch (Exception e) { e.printStackTrace(); } //printlnerr("leaving startElement " + localName + "; stack: " + stackStatus()); }
From source file:Controleur.CtrlImprimerOrdonnance.java
public void RemplirOrdonnance() { ResultSet res;// w w w . java2 s. c o m String nomEtablissement = ""; String adresseEtablissement = ""; int telEtablissement = 0; String nomPatient = ""; String prenomPatient = ""; String dateNaissPatient = null; String traitement = ""; Etablissement etab = new Etablissement(); try { res = etab.getEtablissement(); nomEtablissement = res.getString("nomEtab"); adresseEtablissement = res.getString("adresseEtab"); telEtablissement = res.getInt("telEtab"); } catch (SQLException e) { JOptionPane.showMessageDialog(null, "erreur \n" + e.getMessage()); } Medecin med1 = new Medecin(); Medecin med2 = med1.getMedecinById(Fen.getIdm()); String nomMedecin = med2.getNomMedecin(); String prenomMedecin = med2.getPrenomMedecin(); String specialiteMedecin = med2.getSpecialite(); Patient patient = new Patient(); res = patient.getPatient(Fen.getIdp()); try { res.next(); nomPatient = res.getString("nomPatient"); prenomPatient = res.getString("prenomPatient"); dateNaissPatient = res.getString("dateNaissance"); } catch (SQLException e) { JOptionPane.showMessageDialog(null, "erreur \n" + e.getMessage()); } traitement = Fen.getTxtTraitement().getText(); Document document = new Document(PageSize.A4); try { PdfWriter.getInstance(document, new FileOutputStream("./ordonnance.pdf")); document.open(); Date d = new Date(); Paragraph paragraph = new Paragraph(d.toLocaleString(), FontFactory.getFont(FontFactory.COURIER, 20, Font.BOLD)); paragraph.setAlignment(Element.ALIGN_RIGHT); paragraph.setIndentationRight(50f); document.add(paragraph); paragraph = new Paragraph("Dr " + nomMedecin + " " + prenomMedecin, FontFactory.getFont(FontFactory.COURIER, 20, Font.BOLD)); paragraph.setIndentationLeft(50f); document.add(paragraph); paragraph = new Paragraph("SPECIALISTE EN " + specialiteMedecin); paragraph.setIndentationLeft(50f); document.add(paragraph); paragraph = new Paragraph(nomEtablissement); paragraph.setIndentationLeft(50f); document.add(paragraph); paragraph = new Paragraph(adresseEtablissement); paragraph.setIndentationLeft(50f); document.add(paragraph); paragraph = new Paragraph("Tl : " + telEtablissement); paragraph.setIndentationLeft(50f); document.add(paragraph); paragraph = new Paragraph(" "); paragraph.setIndentationLeft(50f); document.add(paragraph); paragraph = new Paragraph("nom & prenom :" + nomPatient + " " + prenomPatient, FontFactory.getFont(FontFactory.COURIER, 20, Font.BOLD)); paragraph.setIndentationLeft(50f); document.add(paragraph); paragraph = new Paragraph("Ne(e) le :" + dateNaissPatient); paragraph.setIndentationLeft(50f); document.add(paragraph); paragraph = new Paragraph(" "); paragraph.setIndentationLeft(50f); document.add(paragraph); Chunk chunk = new Chunk("Ordonnance", FontFactory.getFont(FontFactory.COURIER, 30, Font.BOLD)); chunk.setUnderline(Color.BLACK, 3.0f, 0.0f, 0.0f, -0.2f, PdfContentByte.LINE_CAP_BUTT); paragraph = new Paragraph(); paragraph.setAlignment(Element.ALIGN_CENTER); paragraph.add(chunk); document.add(paragraph); paragraph = new Paragraph(" "); paragraph.setIndentationLeft(50f); document.add(paragraph); paragraph = new Paragraph(traitement); paragraph.setIndentationLeft(50f); document.add(paragraph); Runtime r = Runtime.getRuntime(); r.exec("cmd /C ./ordonnance.pdf"); } catch (DocumentException de) { de.printStackTrace(); } catch (IOException ioe) { ioe.printStackTrace(); } document.close(); }
From source file:net.bull.javamelody.internal.web.pdf.PdfRequestAndGraphDetailReport.java
License:Apache License
@Override void toPdf() throws DocumentException, IOException { if (request != null) { if (request.getRumData() != null && request.getRumData().getHits() != 0) { writeRequestRumData();/* w w w .ja v a 2s . com*/ } writeHeader(); writeRequests(); addTableToDocument(); if (JdbcWrapper.SINGLETON.getSqlCounter().isRequestIdFromThisCounter(request.getId()) && !request.getName().toLowerCase(Locale.ENGLISH).startsWith("alter ")) { // inutile d'essayer d'avoir le plan d'excution des requtes sql // telles que "alter session set ..." (cf issue 152) writeSqlRequestExplainPlan(); } } if (isGraphDisplayed()) { writeGraph(); } if (request != null && request.getStackTrace() != null) { final Paragraph paragraph = new Paragraph("\n", cellFont); paragraph.setIndentationLeft(20); paragraph.setIndentationRight(20); paragraph.add(new Phrase("Stack-trace\n", boldFont)); paragraph.add(new Phrase(request.getStackTrace().replace("\t", " "), cellFont)); addToDocument(paragraph); } }
From source file:net.bull.javamelody.PdfRequestAndGraphDetailReport.java
License:Apache License
@Override void toPdf() throws DocumentException, IOException { if (request != null) { writeHeader();//from www .ja va2 s .c om writeRequests(); addTableToDocument(); if (JdbcWrapper.SINGLETON.getSqlCounter().isRequestIdFromThisCounter(request.getId()) && !request.getName().toLowerCase(Locale.ENGLISH).startsWith("alter ")) { // inutile d'essayer d'avoir le plan d'excution des requtes sql // telles que "alter session set ..." (cf issue 152) writeSqlRequestExplainPlan(); } } if (isGraphDisplayed()) { writeGraph(); } if (request != null && request.getStackTrace() != null) { final Paragraph paragraph = new Paragraph("\n", cellFont); paragraph.setIndentationLeft(20); paragraph.setIndentationRight(20); paragraph.add(new Phrase("Stack-trace\n", boldFont)); paragraph.add(new Phrase(request.getStackTrace().replace("\t", " "), cellFont)); addToDocument(paragraph); } }
From source file:org.apache.poi.xwpf.converter.internal.itext.XWPFParagraphUtils.java
License:Open Source License
public static void processLayout(XWPFParagraph paragraph, Paragraph pdfParagraph, XWPFStyle style, CTDocDefaults defaults) {//from www .ja va 2 s . co m float indentationLeft = -1; float indentationRight = -1; float firstLineIndent = -1; float spacingBefore = -1; float spacingAfter = -1; // 1) From style CTPPr ppr = getPPr(style); if (ppr != null) { // Indentation CTInd ind = ppr.getInd(); if (ind != null) { // Left Indentation BigInteger left = ind.getLeft(); if (left != null) { indentationLeft = dxa2points(left); } // Right Indentation BigInteger right = ind.getRight(); if (right != null) { indentationRight = dxa2points(right); } // First line Indentation BigInteger firstLine = ind.getFirstLine(); if (firstLine != null) { firstLineIndent = dxa2points(firstLine); } } // Spacing CTSpacing spacing = ppr.getSpacing(); if (spacing != null) { // Spacing before BigInteger before = spacing.getBefore(); if (before != null) { spacingBefore = dxa2points(before); } // Spacing after BigInteger after = spacing.getAfter(); if (after != null) { spacingAfter = dxa2points(after); } } // Text aligment CTTextAlignment textAligment = ppr.getTextAlignment(); if (textAligment != null) { // TODO } } // 2) From paragraph if (indentationLeft == -1 && paragraph.getIndentationLeft() != -1) { indentationLeft = dxa2points(paragraph.getIndentationLeft()); } if (indentationRight == -1 && paragraph.getIndentationRight() != -1) { indentationRight = dxa2points(paragraph.getIndentationRight()); } if (firstLineIndent == -1 && paragraph.getIndentationFirstLine() != -1) { firstLineIndent = dxa2points(paragraph.getIndentationFirstLine()); } if (spacingBefore == -1 && paragraph.getSpacingBefore() != -1) { spacingBefore = dxa2points(paragraph.getSpacingBefore()); } if (spacingAfter == -1 && paragraph.getSpacingAfter() != -1) { spacingAfter = dxa2points(paragraph.getSpacingAfter()); } // 3) From default // TODO // Apply if (indentationLeft != -1) { pdfParagraph.setIndentationLeft(indentationLeft); } if (indentationRight != -1) { pdfParagraph.setIndentationRight(indentationRight); } if (firstLineIndent != -1) { pdfParagraph.setFirstLineIndent(firstLineIndent); } if (spacingBefore != -1) { pdfParagraph.setSpacingBefore(spacingBefore); } if (spacingAfter != -1) { pdfParagraph.setSpacingAfter(spacingAfter); } // Aligment ParagraphAlignment alignment = paragraph.getAlignment(); switch (alignment) { case LEFT: pdfParagraph.setAlignment(Paragraph.ALIGN_LEFT); break; case RIGHT: pdfParagraph.setAlignment(Paragraph.ALIGN_RIGHT); break; case CENTER: pdfParagraph.setAlignment(Paragraph.ALIGN_CENTER); break; case BOTH: pdfParagraph.setAlignment(Paragraph.ALIGN_JUSTIFIED); break; } }
From source file:org.gtdfree.addons.PDFExportAddOn.java
License:Open Source License
@Override public void export(GTDModel model, ActionsCollection collection, OutputStream out, ExportAddOn.ExportOrder order, FileFilter ff, boolean compact) throws Exception { fontSelector = new FontSelector(); fontSelectorB = new FontSelector(); fontSelectorB2 = new FontSelector(); fontSelectorB4 = new FontSelector(); baseFont = fontModel.getBaseFont();//from w w w.j av a2s.co m for (BaseFont bf : fontModel.getFonts()) { fontSelector.addFont(new Font(bf, baseFontSize)); fontSelectorB.addFont(new Font(bf, baseFontSize, Font.BOLD)); fontSelectorB2.addFont(new Font(bf, baseFontSize + 2, Font.BOLD)); fontSelectorB4.addFont(new Font(bf, baseFontSize + 4, Font.BOLD)); } boolean emptyH2 = false; boolean emptyH3 = false; PdfPTable actionTable = null; Document doc = new Document(); if (sizeSet) { doc.setPageSize(pageSize); } if (marginSet) { doc.setMargins(marginLeft, marginRight, marginTop, marginBottom); } //System.out.println("PDF size "+doc.getPageSize().toString()); //System.out.println("PDF m "+marginLeft+" "+marginRight+" "+marginTop+" "+marginBottom); @SuppressWarnings("unused") PdfWriter pw = PdfWriter.getInstance(doc, out); doc.addCreationDate(); doc.addTitle("GTD-Free PDF"); doc.addSubject("GTD-Free data exported as PDF"); HeaderFooter footer = new HeaderFooter(newParagraph(), true); footer.setAlignment(HeaderFooter.ALIGN_CENTER); footer.setBorder(HeaderFooter.TOP); doc.setFooter(footer); doc.open(); Phrase ch = newTitle("GTD-Free Data"); Paragraph p = new Paragraph(ch); p.setAlignment(Paragraph.ALIGN_CENTER); PdfPTable t = new PdfPTable(1); t.setWidthPercentage(100f); PdfPCell c = newCell(p); c.setBorder(Table.BOTTOM); c.setBorderWidth(2.5f); c.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); c.setPadding(5f); t.addCell(c); doc.add(t); Iterator<Object> it = collection.iterator(order); while (it.hasNext()) { Object o = it.next(); if (o == ActionsCollection.ACTIONS_WITHOUT_PROJECT) { if (order == ExportAddOn.ExportOrder.FoldersProjectsActions) { doc.add(newSubSection(ActionsCollection.ACTIONS_WITHOUT_PROJECT)); emptyH2 = false; emptyH3 = true; } else { doc.add(newSection(ActionsCollection.ACTIONS_WITHOUT_PROJECT)); emptyH2 = true; emptyH3 = false; } continue; } if (o instanceof Folder) { Folder f = (Folder) o; if (actionTable != null) { doc.add(actionTable); actionTable = null; } if (f.isProject()) { if (order == ExportAddOn.ExportOrder.ProjectsActions || order == ExportAddOn.ExportOrder.ProjectsFoldersActions) { if (emptyH2 || emptyH3) { p = newParagraph(NONE_DOT); doc.add(p); } doc.add(newSection(f.getName())); if (compact) { if (f.getDescription() != null && f.getDescription().length() > 0) { p = newParagraph(f.getDescription()); p.setIndentationLeft(10f); p.setIndentationRight(10f); doc.add(p); } } else { t = new PdfPTable(2); t.setKeepTogether(true); t.setSpacingBefore(5f); t.setWidthPercentage(66f); t.setWidths(new float[] { 0.33f, 0.66f }); c = newCell("ID"); t.addCell(c); c = newCell(newStrongParagraph(String.valueOf(f.getId()))); t.addCell(c); c = newCell("Type"); t.addCell(c); c = newCell(newStrongParagraph("Project")); t.addCell(c); c = newCell("Open"); t.addCell(c); c = newCell(newStrongParagraph(String.valueOf(f.getOpenCount()))); t.addCell(c); c = newCell("All"); t.addCell(c); c = newCell(newStrongParagraph(String.valueOf(f.size()))); t.addCell(c); c = newCell("Description"); t.addCell(c); c = newDescriptionCell(f.getDescription()); t.addCell(c); doc.add(t); } emptyH2 = true; emptyH3 = false; } else { if (emptyH3) { p = newParagraph(NONE_DOT); doc.add(p); } doc.add(newSubSection("Project:" + " " + f.getName())); emptyH2 = false; emptyH3 = true; } continue; } if (order == ExportAddOn.ExportOrder.FoldersActions || order == ExportAddOn.ExportOrder.FoldersProjectsActions) { if (emptyH2 || emptyH3) { p = newParagraph(NONE_DOT); doc.add(p); } doc.add(newSection(f.getName())); if (compact) { if (f.getDescription() != null && f.getDescription().length() > 0) { p = newParagraph(f.getDescription()); p.setIndentationLeft(10f); p.setIndentationRight(10f); doc.add(p); } } else { t = new PdfPTable(2); t.setKeepTogether(true); t.setSpacingBefore(5f); t.setWidthPercentage(66f); t.setWidths(new float[] { 0.33f, 0.66f }); c = newCell("ID"); t.addCell(c); c = newCell(newStrongParagraph(String.valueOf(f.getId()))); t.addCell(c); String type = ""; if (f.isAction()) { type = "Action list"; } else if (f.isInBucket()) { type = "In-Bucket"; } else if (f.isQueue()) { type = "Next action queue"; } else if (f.isReference()) { type = "Reference list"; } else if (f.isSomeday()) { type = "Someday/Maybe list"; } else if (f.isBuildIn()) { type = "Default list"; } c = newCell("Type"); t.addCell(c); c = newCell(newStrongParagraph(type)); t.addCell(c); c = newCell("Open"); t.addCell(c); c = newCell(newStrongParagraph(String.valueOf(f.getOpenCount()))); t.addCell(c); c = newCell("All"); t.addCell(c); c = newCell(newStrongParagraph(String.valueOf(f.size()))); t.addCell(c); c = newCell("Description"); t.addCell(c); c = newDescriptionCell(f.getDescription()); t.addCell(c); doc.add(t); } emptyH2 = true; emptyH3 = false; } else { if (emptyH3) { p = newParagraph(NONE_DOT); doc.add(p); } doc.add(newSubSection("List:" + " " + f.getName())); emptyH2 = false; emptyH3 = true; } continue; } if (o instanceof Action) { emptyH2 = false; emptyH3 = false; Action a = (Action) o; if (compact) { if (actionTable == null) { actionTable = new PdfPTable(5); actionTable.setWidthPercentage(100f); actionTable.setHeaderRows(1); actionTable.setSpacingBefore(5f); c = newHeaderCell("ID"); actionTable.addCell(c); c = newHeaderCell("Pri."); actionTable.addCell(c); c = newHeaderCell("Description"); actionTable.addCell(c); c = newHeaderCell("Reminder"); actionTable.addCell(c); c = newHeaderCell(CHECK_RESOLVED); actionTable.addCell(c); float width = doc.getPageSize().getWidth() - doc.getPageSize().getBorderWidthLeft() - doc.getPageSize().getBorderWidthRight(); int i = model.getLastActionID(); float step = baseFontSize - 1; int steps = (int) Math.floor(Math.log10(i)) + 1; // ID column float col1 = 8 + steps * step; // Priority column float col2 = 4 + 3 * (baseFontSize + 4); // Reminder column float col4 = 10 + step * 11; // Resolved column float col5 = 8 + baseFontSize; // Description column float col3 = width - col1 - col2 - col4 - col5; actionTable.setWidths(new float[] { col1, col2, col3, col4, col5 }); } addSingleActionRow(a, actionTable); } else { addSingleActionTable(model, doc, a); } } } if (actionTable != null) { doc.add(actionTable); actionTable = null; } if (emptyH2 || emptyH3) { p = newParagraph(NONE_DOT); doc.add(p); } //w.writeCharacters("Exported: "+ApplicationHelper.toISODateTimeString(new Date())); doc.close(); }
From source file:org.pz.platypus.plugin.pdf.PdfOutfile.java
License:Open Source License
/** * Handles indenting the entire paragraph. Indent occurs from the right margin. * * @param para paragraph//w w w. j av a 2 s .co m * @param pData PDF data containing the amount of indent (in points) * @return the amount of indent in points. */ float doParagraphIndentRight(final Paragraph para, final PdfData pData) { assert (para != null); assert (pData != null); float indent = pData.getParagraphIndentRight(); para.setIndentationRight(indent); return (indent); }
From source file:uk.ac.ox.oucs.vle.resources.PDFWriter.java
License:Educational Community License
public void writeHead(Collection<CourseGroup> courseGroups, CourseComponent courseComponent) throws IOException { try {/*w w w . j a va2 s . c o m*/ Paragraph paragraph; Phrase phrase; // Title paragraph = new Paragraph(); for (CourseGroup courseGroup : courseGroups) { phrase = new Phrase("\n" + courseGroup.getTitle(), titleFont); paragraph.add(phrase); } paragraph.setAlignment(Element.ALIGN_CENTER); document.add(paragraph); // Component paragraph = new Paragraph(); phrase = new Phrase("\nComponent: " + courseComponent.getTitle(), authorFont); paragraph.add(phrase); paragraph.setIndentationLeft(25); paragraph.setIndentationRight(25); paragraph.setAlignment(Element.ALIGN_LEFT); document.add(paragraph); // Presenter paragraph = new Paragraph(); Person presenter = courseComponent.getPresenter(); phrase = new Phrase("\nPresenter: " + ((presenter == null) ? "" : presenter.getName()), authorFont); paragraph.add(phrase); paragraph.setIndentationLeft(25); paragraph.setIndentationRight(25); paragraph.setAlignment(Element.ALIGN_LEFT); document.add(paragraph); // Date paragraph = new Paragraph(); phrase = new Phrase("Date/Time: ...........................................", infoFont); paragraph.add(phrase); paragraph.setIndentationLeft(25); paragraph.setIndentationRight(25); document.add(paragraph); // info paragraph = new Paragraph(); phrase = new Phrase("Please sign to confirm that you have attended this session", infoFont); paragraph.add(phrase); paragraph.setIndentationLeft(25); paragraph.setIndentationRight(25); paragraph.setAlignment(Element.ALIGN_LEFT); document.add(paragraph); } catch (DocumentException e) { throw new IOException("Unable to write Document Header."); } }