List of usage examples for com.lowagie.text Chunk Chunk
public Chunk(DrawInterface separator, float tabPosition)
From source file:org.tellervo.desktop.print.BasicBoxLabel.java
License:Open Source License
public void generateBoxLabel(OutputStream output) { try {/*from www.j ava 2 s. c o m*/ PdfWriter writer = PdfWriter.getInstance(document, output); document.setPageSize(PageSize.LETTER); document.open(); cb = writer.getDirectContent(); // Set basic metadata document.addAuthor("Tellervo"); document.addSubject("Tellervo Box Labels"); PdfPTable table = new PdfPTable(2); table.setTotalWidth(495f); table.setLockedWidth(true); for (WSIBox b : boxlist) { Paragraph p = new Paragraph(); p.add(new Chunk(b.getTitle() + Chunk.NEWLINE, labelTitleFont)); p.add(new Chunk(Chunk.NEWLINE + b.getComments() + Chunk.NEWLINE, bodyFont)); p.add(new Chunk(App.getLabName() + Chunk.NEWLINE + Chunk.NEWLINE, bodyFont)); p.add(new Chunk(this.getBarCode(b), 0, 0, true)); PdfPCell cell = new PdfPCell(p); cell.setPaddingLeft(15f); cell.setPaddingRight(15f); cell.setBorderColor(Color.LIGHT_GRAY); table.addCell(cell); } PdfPCell cell = new PdfPCell(new Paragraph()); cell.setBorderColor(Color.LIGHT_GRAY); table.addCell(cell); document.add(table); document.close(); /*float top = document.top(15); int row = 1; for(int i = 0; i< boxlist.size(); i = i+2) { log.debug("Document left : "+document.left()); log.debug("Document right: "+document.right()); log.debug("Top : "+top); // Column 1 ColumnText ct1a = new ColumnText(cb); ct1a.setSimpleColumn(document.left(), top-210, 368, top, 20, Element.ALIGN_LEFT); ColumnText ct1b = new ColumnText(cb); ct1b.setSimpleColumn(document.left(), top-70, document.left()+206, top-150, 20, Element.ALIGN_LEFT); try{ WSIBox b1 = boxlist.get(i); ct1a.addText(getTitlePDF(b1)); ct1a.go(); ct1b.addElement(getBarCode(b1)); ct1b.go(); } catch (Exception e) { log.debug("Failed writing box label in left column where i="+i); } // Column 2 ColumnText ct2a = new ColumnText(cb); ct2a.setSimpleColumn(306, top-210, document.right(), top, 20, Element.ALIGN_LEFT); ColumnText ct2b = new ColumnText(cb); ct2b.setSimpleColumn(306, top-70, 512, top-80, 20, Element.ALIGN_LEFT); try{ WSIBox b2 = boxlist.get(i+1); ct2a.addText(getTitlePDF(b2)); ct2a.go(); ct2b.addElement(getBarCode(b2)); ct2b.go(); } catch (Exception e) { log.debug("Failed writing box label in right column where i="+i); //e.printStackTrace(); } // Column 2 /* ColumnText ct2 = new ColumnText(cb); ct2.setSimpleColumn(370, //llx top-100, //lly document.right(0), //urx top+15, //ury 20, //leading Element.ALIGN_RIGHT //alignment ); try{ WSIBox b2 = boxlist.get(i+1); ct2.addText(getTitlePDF(b2)); ct2.addElement(getBarCode(b2)); ct2.go(); } catch (Exception e) { log.debug("Failed writing box label where i="+i+1); } */ /* top = top-160; if(row==5) { top = document.top(15); document.newPage(); row=1; } else { row++; } }*/ } catch (DocumentException de) { System.err.println(de.getMessage()); } // Close the document document.close(); }
From source file:org.tellervo.desktop.print.BasicBoxLabel.java
License:Open Source License
/** * iText paragraph containing created and lastmodified timestamps * //from w ww .j a v a 2s. c o m * @return Paragraph */ private Paragraph getTimestampPDF(WSIBox b) { // Set up calendar Date createdTimestamp = b.getCreatedTimestamp().getValue().toGregorianCalendar().getTime(); Date nowTimestamp = new Date(); DateFormat df1 = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.SHORT); Paragraph p = new Paragraph(); p.add(new Chunk("Created: ", subSubSectionFont)); p.add(new Chunk(df1.format(createdTimestamp), bodyFont)); //p.add(new Chunk("\nLast Modified: ", subSubSectionFont)); //p.add(new Chunk(df1.format(lastModifiedTimestamp), bodyFontLarge)); p.add(new Chunk("\nLabel updated: ", subSubSectionFont)); p.add(new Chunk(df1.format(nowTimestamp), bodyFont)); return p; }
From source file:org.tellervo.desktop.print.BasicBoxLabel.java
License:Open Source License
private Paragraph getComments(WSIBox b) throws DocumentException { Paragraph p = new Paragraph(); p.setLeading(0, 1.2f);/*ww w. ja va 2 s.c o m*/ p.add(new Chunk("Comments: \n", subSubSectionFont)); if (b.getComments() != null) { p.add(new Chunk(b.getComments(), bodyFont)); } else { p.add(new Chunk("No comments recorded", bodyFont)); } return (p); }
From source file:org.tellervo.desktop.print.CompleteBoxLabel.java
License:Open Source License
public void generateBoxLabel(OutputStream output) { try {/* w ww . j av a 2 s. co m*/ PdfWriter writer = PdfWriter.getInstance(document, output); document.setPageSize(PageSize.LETTER); document.open(); cb = writer.getDirectContent(); // Set basic metadata document.addAuthor("Peter Brewer"); document.addSubject("Box Label"); for (WSIBox b : this.boxlist) { // Title Left ColumnText ct = new ColumnText(cb); ct.setSimpleColumn(document.left(), document.top(15) - 210, 368, document.top(15), 20, Element.ALIGN_LEFT); ct.addText(getTitlePDF(b)); ct.go(); // Barcode ColumnText ct2 = new ColumnText(cb); ct2.setSimpleColumn(370, document.top(15) - 100, document.right(0), document.top(0), 20, Element.ALIGN_RIGHT); ct2.addElement(getBarCode(b)); ct2.go(); // Timestamp ColumnText ct3 = new ColumnText(cb); ct3.setSimpleColumn(document.left(), document.top(15) - 223, 350, document.top(15) - 60, 20, Element.ALIGN_LEFT); ct3.setLeading(0, 1.2f); ct3.addText(getTimestampPDF(b)); ct3.go(); // Pad text document.add(new Paragraph(" ")); Paragraph p2 = new Paragraph(); p2.setSpacingBefore(70); p2.setSpacingAfter(10); p2.add(new Chunk(" ", bodyFontLarge)); document.add(new Paragraph(p2)); // Ring samples table addTable(b); document.add(getParagraphSpace()); document.add(getComments(b)); document.newPage(); } } catch (DocumentException de) { System.err.println(de.getMessage()); } // Close the document document.close(); }
From source file:org.tellervo.desktop.print.CompleteBoxLabel.java
License:Open Source License
/** * Get an iText Paragraph for the Title * /* ww w .ja v a 2 s. co m*/ * @return Paragraph */ private Paragraph getTitlePDF(WSIBox b) { Paragraph p = new Paragraph(); p.add(new Chunk(b.getTitle() + "\n", monsterFont)); p.add(new Chunk(App.getLabName(), subTitleFont)); //p.add(new Chunk(b.getCurationLocation(), bodyFontLarge)); return p; }
From source file:org.tellervo.desktop.print.ProSheet.java
License:Open Source License
private void generateProSheet(OutputStream output) { Paragraph spacingPara = new Paragraph(); spacingPara.setSpacingBefore(10);//from w w w . j a v a 2s . c o m spacingPara.add(new Chunk(" ", bodyFont)); try { PdfWriter writer = PdfWriter.getInstance(document, output); document.setPageSize(PageSize.LETTER); // Set basic metadata document.addAuthor("Peter Brewer"); document.addSubject("Corina Provenience Sheet for " + o.getTitle()); HeaderFooter footer = new HeaderFooter(new Phrase(""), new Phrase("")); footer.setAlignment(Element.ALIGN_RIGHT); footer.setBorder(0); document.setFooter(footer); HeaderFooter header = new HeaderFooter(new Phrase(o.getLabCode() + " - " + o.getTitle(), bodyFont), false); header.setAlignment(Element.ALIGN_RIGHT); header.setBorder(0); document.setHeader(header); document.open(); cb = writer.getDirectContent(); // Title Left ColumnText ct = new ColumnText(cb); ct.setSimpleColumn(document.left(), document.top() - 193, document.right(), document.top() - 20, 20, Element.ALIGN_LEFT); ct.addText(getTitlePDF()); ct.go(); // Timestamp ColumnText ct3 = new ColumnText(cb); ct3.setSimpleColumn(document.left(), document.top() - 223, 283, document.top() - 60, 20, Element.ALIGN_LEFT); ct3.setLeading(0, 1.2f); ct3.addText(getTimestampPDF()); ct3.go(); // Pad text document.add(spacingPara); document.add(getObjectDescription()); document.add(getObjectComments()); document.add(spacingPara); getElementTable(); } catch (DocumentException de) { System.err.println(de.getMessage()); } // Close the document document.close(); }
From source file:org.tellervo.desktop.print.ProSheet.java
License:Open Source License
/** * iText paragraph containing created and lastmodified timestamps * //from w ww. j av a 2 s.c om * @return Paragraph */ private Paragraph getTimestampPDF() { Date now = new Date(); DateFormat df1 = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.SHORT); Paragraph p = new Paragraph(); p.add(new Chunk("Printed: ", subSubSectionFont)); p.add(new Chunk(df1.format(now), bodyFont)); return p; }
From source file:org.tellervo.desktop.print.ProSheet.java
License:Open Source License
/** * Get an iText Paragraph for the Title * //from w w w .jav a 2 s . c o m * @return Paragraph */ private Paragraph getTitlePDF() { Paragraph p = new Paragraph(); p.add(new Chunk(o.getLabCode() + " - " + o.getTitle() + "\n", titleFont)); //p.add(new Chunk(i.getCode(), subTitleFont)); return p; }
From source file:org.tellervo.desktop.print.ProSheet.java
License:Open Source License
private Paragraph getObjectDescription() { Paragraph p = new Paragraph(); p.setLeading(0, 1.2f);//from www.ja va 2 s. c o m p.setAlignment(Element.ALIGN_JUSTIFIED); p.setSpacingAfter(10); p.setSpacingBefore(50); if (o.getDescription() != null) { p.add(new Chunk(o.getDescription(), bodyFont)); } else { p.add(new Chunk("No description recorded", bodyFont)); } return p; }
From source file:org.tellervo.desktop.print.ProSheet.java
License:Open Source License
private Paragraph getObjectComments() { Paragraph p = new Paragraph(); p.setLeading(0, 1.2f);/*from www. ja va2 s . c om*/ p.setAlignment(Element.ALIGN_JUSTIFIED); p.setSpacingAfter(10); if (o.getComments() != null) { p.add(new Chunk("Notes: ", commentFont)); p.add(new Chunk(o.getComments(), commentFont)); } return p; }