List of usage examples for com.itextpdf.text Chunk append
public StringBuffer append(final String string)
Chunk
. From source file:com.skatettoo.reportes.Generador.java
private Object getHeader(String texto) { Paragraph p = new Paragraph(); Chunk c = new Chunk(); p.setAlignment(Element.ALIGN_CENTER); c.append(texto); p.add(c);/*ww w. j a v a2 s.c o m*/ return p; }
From source file:com.vectorprint.report.itext.DefaultElementProducer.java
License:Open Source License
/** * Create a piece of text (part of a Phrase), style it and ad the data. * * @param data/*ww w . j a v a 2s.co m*/ * @param stylers * @return * @throws VectorPrintException */ public Chunk createChunk(Object data, Collection<? extends BaseStyler> stylers) throws VectorPrintException { Chunk c = styleHelper.style(new Chunk(), data, stylers); if (data != null) { c.append(formatValue(data)); } if (notDelayedStyle(c, ADV + (++advancedTag), stylers) && debug) { c.setGenericTag(String.valueOf(++genericTag)); } return c; }
From source file:de.extra.xtt.util.pdf.PdfCreatorImpl.java
License:Apache License
/** * Erzeugt das Inhaltsverzeichnis aus den bereits vorhandenen Elementen in * der Liste <code>listEntries</code>. * //from w ww. j a v a 2s .c om * @param docPdf * Zieldokument, falls Inhaltsverzeichnis nicht temporr erzeugt * wird * @param temp * Gibt an, ob das Inhaltsverzeichnis temporr in einer neuen * Datei/Dokument erzeugt werden soll * @return Anzahl der Seiten * @throws DocumentException * @throws IOException */ private int erzeugeInhaltsverzeichnis(Document docPdf, boolean temp) throws DocumentException, IOException { int anzPages = 0; Document docInhalt = docPdf; String filePathTempInhaltString = ""; if (temp) { // temp. Dateinamen bestimmen File fileDokuFile = new File(dateiname); filePathTempInhaltString = fileDokuFile.getParent() + "/tmp_inhalt.pdf"; // Neues Dokument erzeugen docInhalt = initPdfWriterAndDocument(filePathTempInhaltString, false); } // berschrift Chapter currChapter = new Chapter(getParagraphChapter("Inhaltsverzeichnis"), 0); // 0, damit keine Nummerierung currChapter.setNumberDepth(0); docInhalt.add(currChapter); // eine Zeile Abstand docInhalt.add(getEmptyLineTextHalf()); for (ContPdfEntry currEntry : listEntries) { // Eintrag erzeugen inkl. Abstand String strEintrag = currEntry.getBezeichnung() + " "; Chunk chunkBezeichnung; Chunk chunkSeitenzahlChunk; if (currEntry.getParentEntry() == null) { // 1. Ebene => fett, Abstand davor einfgen docInhalt.add(getEmptyLineTextHalf()); chunkBezeichnung = getChunkTextBold(strEintrag); chunkSeitenzahlChunk = getChunkTextBold("" + currEntry.getPageNumber()); } else { // 2. Ebene chunkBezeichnung = getChunkText(strEintrag); chunkSeitenzahlChunk = getChunkText("" + currEntry.getPageNumber()); } // Referenz setzen chunkBezeichnung.setLocalGoto(currEntry.getDestination()); chunkSeitenzahlChunk.setLocalGoto(currEntry.getDestination()); // Abstandzeichen generieren, Breite auffllen float widthAbstand = docInhalt.getPageSize().getWidth() * 0.81f; ; while (chunkBezeichnung.getWidthPoint() <= widthAbstand) { chunkBezeichnung.append("."); } // Tabelle erzeugen und formatieren PdfPTable currTable = new PdfPTable(2); currTable.setWidthPercentage(100f); currTable.setWidths(new int[] { 96, 4 }); // Inhalte einfgen // Zelle Bezeichnung PdfPCell currCellBezeichnung = new PdfPCell(new Phrase(chunkBezeichnung)); currCellBezeichnung.setBorder(0); currCellBezeichnung.setHorizontalAlignment(Element.ALIGN_JUSTIFIED_ALL); // Zelle Seitennummer PdfPCell currCellPageNumberCell = new PdfPCell(new Phrase(chunkSeitenzahlChunk)); currCellPageNumberCell.setBorder(0); currCellPageNumberCell.setHorizontalAlignment(Element.ALIGN_RIGHT); // Zellen zur Tabelle hinzufgen currTable.addCell(currCellBezeichnung); currTable.addCell(currCellPageNumberCell); docInhalt.add(currTable); } if (temp) { // Dokument schlieen docInhalt.close(); // Anzahl der Seitenzahlen bestimmen PdfReader reader = new PdfReader(filePathTempInhaltString); anzPages = reader.getNumberOfPages(); reader.close(); // temp. Datei lschen File currFileInhaltFile = new File(filePathTempInhaltString); currFileInhaltFile.delete(); } return anzPages; }
From source file:facturacion.pdf.FacturaPdf.java
@SuppressWarnings("unused") private Paragraph getHeader(String header) { Paragraph paragraph = new Paragraph(); Chunk chunk = new Chunk(); paragraph.setAlignment(Element.ALIGN_CENTER); chunk.append(header + getCurrentDateTime() + "\n"); chunk.setFont(fontBold);//from w ww.jav a2 s . com paragraph.add(chunk); return paragraph; }
From source file:facturacion.pdf.FacturaPdf.java
private Paragraph getInformation(String informacion) { Paragraph paragraph = new Paragraph(); Chunk chunk = new Chunk(); paragraph.setAlignment(Element.ALIGN_CENTER); chunk.append(informacion); chunk.setFont(fontNormal);/* w w w .j ava 2s. c o m*/ paragraph.add(chunk); return paragraph; }
From source file:facturacion.pdf.FacturaPdf.java
@SuppressWarnings("unused") private Paragraph getInformationFooter(String informacion) { Paragraph paragraph = new Paragraph(); Chunk chunk = new Chunk(); paragraph.setAlignment(Element.ALIGN_CENTER); chunk.append(informacion); chunk.setFont(new Font(Font.FontFamily.COURIER, 8, Font.NORMAL)); paragraph.add(chunk);/*from w w w . ja va2 s. c o m*/ return paragraph; }
From source file:facturacion.pdf.FacturaPdf.java
private PdfPCell getCellBorderTop(String text) throws DocumentException, IOException { Chunk chunk = new Chunk(); chunk.append(text); chunk.setFont(fontNormal);/*from w ww . j a va 2 s . co m*/ PdfPCell cell = new PdfPCell(new Paragraph(chunk)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setBorder(Rectangle.TOP); return cell; }
From source file:facturacion.pdf.FacturaPdf.java
private PdfPCell getCellNoBorder(String text) throws DocumentException, IOException { Chunk chunk = new Chunk(); chunk.append(text); chunk.setFont(fontNormal);/*from w w w . j a v a2 s .c o m*/ PdfPCell cell = new PdfPCell(new Paragraph(chunk)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setBorder(Rectangle.NO_BORDER); return cell; }
From source file:facturacion.pdf.FacturaPdf.java
private PdfPCell getCell(String text) throws DocumentException, IOException { Chunk chunk = new Chunk(); chunk.append(text); chunk.setFont(fontNormal);//from w w w . j ava 2 s . c o m PdfPCell cell = new PdfPCell(new Paragraph(chunk)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setBorder(Rectangle.LEFT); return cell; }
From source file:facturacion.pdf.FacturaPdf.java
private PdfPCell getCellBox(String text) throws DocumentException, IOException { Chunk chunk = new Chunk(); chunk.append(text); chunk.setFont(fontNormal);//from w w w . j a v a 2 s. c om PdfPCell cell = new PdfPCell(new Paragraph(chunk)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setBorder(Rectangle.BOX); return cell; }