List of usage examples for com.lowagie.text Paragraph setIndentationLeft
public void setIndentationLeft(float indentation)
From source file:tufts.vue.PresentationNotes.java
License:Educational Community License
public static void createOutline(File file) { //page size notes: //martin-top,left,right,bottom = 36 //widht :612//from www .j ava 2s. c o m //height : 792 //usable space 540 x 720 // step 1: creation of a document-object Document document = new Document(PageSize.LETTER); try { GUI.activateWaitCursor(); // step 2: // we create a writer that listens to the document // and directs a PDF-stream to a file PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(file)); // writer.setDefaultColorspace(PdfName.DEFAULTRGB, null); // writer.setStrictImageSequence(true); // step 3: we open the document document.open(); Paragraph p1 = new Paragraph(VUE.getActivePathway().getLabel()); p1.setSpacingAfter(15.0f); Font f = p1.getFont(); f.setStyle(Font.BOLD); p1.setFont(f); document.add(p1); /*p1.add("The leading of this paragraph is calculated automagically. "); p1.add("The default leading is 1.5 times the fontsize. "); p1.add(new Chunk("You can add chunks ")); p1.add(new Phrase("or you can add phrases. ")); p1.add(new Phrase( */ int entryCount = 1; int currentIndex = VUE.getActivePathway().getIndex(); VUE.getActivePathway().setIndex(-1); for (LWPathway.Entry entry : VUE.getActivePathway().getEntries()) { String notes = entry.getNotes(); Paragraph p = new Paragraph(entryCount + ". " + entry.getLabel()); f = p.getFont(); f.setStyle(Font.BOLD); p.setFont(f); Paragraph notesP = new Paragraph(notes); notesP.setIndentationLeft(15.0f); notesP.setSpacingAfter(15.0f); document.add(p); document.add(notesP); entryCount++; } VUE.getActivePathway().setIndex(currentIndex); } catch (DocumentException de) { System.err.println(de.getMessage()); } catch (IOException ioe) { System.err.println(ioe.getMessage()); } finally { GUI.clearWaitCursor(); } // step 5: we close the document document.close(); }
From source file:tufts.vue.PresentationNotes.java
License:Educational Community License
public static void createNodeOutline(File file) { //page size notes: //martin-top,left,right,bottom = 36 //widht :612// w ww .j a v a 2 s. c om //height : 792 //usable space 540 x 720 // step 1: creation of a document-object Document document = new Document(PageSize.LETTER); try { GUI.activateWaitCursor(); // step 2: // we create a writer that listens to the document // and directs a PDF-stream to a file PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(file)); // writer.setDefaultColorspace(PdfName.DEFAULTRGB, null); // writer.setStrictImageSequence(true); // step 3: we open the document document.open(); Paragraph p1 = new Paragraph(VUE.getActiveMap().getLabel()); p1.setSpacingAfter(15.0f); Font f = p1.getFont(); f.setStyle(Font.BOLD); f.setSize(18f); p1.setFont(f); document.add(p1); String n2 = VUE.getActiveMap().getNotes(); if (n2 != null && n2.length() > 0) { Paragraph p2 = new Paragraph(n2); p2.setIndentationLeft(30.0f); p2.setSpacingAfter(15.0f); // f = p2.getFont(); //f.setSize(f.getSize()-2); //p2.setFont(f); document.add(p2); } int entryCount = 1; float indentation = 0.0f; Iterator it = VUE.getActiveMap().getAllDescendents(LWComponent.ChildKind.PROPER).iterator(); while (it.hasNext()) { LWComponent c = (LWComponent) it.next(); if (c instanceof LWNode) { LWNode n = (LWNode) c; outlineChildNode(document, indentation, n, entryCount); entryCount++; iterateChildren(document, indentation + 10, n, 1); } } it = VUE.getActiveMap().getAllDescendents(LWComponent.ChildKind.PROPER).iterator(); while (it.hasNext()) { LWComponent c = (LWComponent) it.next(); if (c instanceof LWLink) { LWLink l = (LWLink) c; String notes = l.getNotes(); String linkLabel = l.getLabel(); if ((notes == null || notes.length() == 0) && (linkLabel == null || linkLabel.length() == 0)) continue; if (linkLabel == null || linkLabel.length() == 0) linkLabel = "Link"; Paragraph p = new Paragraph(entryCount + ". " + linkLabel.replaceAll("\\n", "")); f = p.getFont(); f.setStyle(Font.BOLD); f.setSize(14f); p.setFont(f); Paragraph notesP = new Paragraph(notes); // f = notesP.getFont(); // f.setSize(f.getSize()-2); notesP.setIndentationLeft(30.0f); notesP.setSpacingAfter(15.0f); document.add(p); document.add(notesP); entryCount++; } } } catch (DocumentException de) { System.err.println(de.getMessage()); } catch (IOException ioe) { System.err.println(ioe.getMessage()); } finally { GUI.clearWaitCursor(); } // step 5: we close the document document.close(); }
From source file:tufts.vue.PresentationNotes.java
License:Educational Community License
private static void outlineChildNode(Document d, float indentation, LWNode n, int entryCount) { String notes = n.getNotes();//w w w. j a v a 2s. com String nodeLabel = n.getLabel(); if (nodeLabel == null || nodeLabel.length() == 0) nodeLabel = "Node"; Paragraph p = new Paragraph(entryCount + ". " + n.getLabel().replaceAll("\\n", "")); Font f = p.getFont(); f.setStyle(Font.BOLD); f.setSize(14f); p.setFont(f); p.setIndentationLeft(indentation); Paragraph notesP = new Paragraph(notes); notesP.setIndentationLeft(indentation + 20); notesP.setSpacingAfter(15.0f); try { d.add(p); d.add(notesP); } catch (DocumentException e) { e.printStackTrace(); } }
From source file:uk.ac.bbsrc.tgac.miso.core.data.decorator.itext.ITextProjectDecorator.java
License:Open Source License
public void buildReport() throws DocumentException { report = new Document(); PdfWriter writer = PdfWriter.getInstance(report, stream); report.open();/*w ww . jav a 2 s . com*/ report.add(new Paragraph("Project Summary")); PdfContentByte cb = writer.getDirectContent(); cb.setLineWidth(2.0f); // Make a bit thicker than 1.0 default cb.setGrayStroke(0.9f); // 1 = black, 0 = white float x = 72f; float y = 200f; cb.moveTo(x, y); cb.lineTo(x + 72f * 6, y); cb.stroke(); report.add(new Paragraph(project.getAlias())); report.add(new Paragraph(project.getDescription())); PdfPTable t = new PdfPTable(1); t.setHorizontalAlignment(Element.ALIGN_CENTER); t.setWidthPercentage(100f); // this would be the 100 from setHorizontalLine t.setSpacingAfter(5f); t.setSpacingBefore(0f); t.getDefaultCell().setUseVariableBorders(true); t.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE); t.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); t.getDefaultCell().setBorder(Rectangle.BOTTOM); // This generates the line t.getDefaultCell().setBorderWidth(1f); // this would be the 1 from setHorizontalLine t.getDefaultCell().setPadding(0); t.addCell(""); report.add(t); x = 72f; y = 100f; cb.moveTo(x, y); cb.lineTo(x + 72f * 6, y); cb.stroke(); if (project.getSamples().size() > 0) { report.add(new Paragraph("Samples")); for (Sample sample : project.getSamples()) { Paragraph sPara = new Paragraph(sample.getAlias(), FontFactory.getFont("Helvetica", 12, Font.BOLD)); sPara.setIndentationLeft(20); report.add(sPara); report.add(new Paragraph(sample.getDescription())); } } report.close(); }
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 {//from w w w. ja 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."); } }