List of usage examples for com.itextpdf.text FontFactory getFont
public static Font getFont(final String fontname, final float size, final int style)
Font
-object. From source file:de.extra.xtt.util.pdf.PdfCreatorImpl.java
License:Apache License
private Paragraph getParagraphTextBold(String text) { return new Paragraph(text, FontFactory.getFont(fontNameStandard, fontSizeText, Font.BOLD)); }
From source file:de.extra.xtt.util.pdf.PdfCreatorImpl.java
License:Apache License
private Paragraph getParagraphTextItalic(String text) { return new Paragraph(text, FontFactory.getFont(fontNameStandard, fontSizeText, Font.ITALIC)); }
From source file:de.unisiegen.informatik.bs.alvis.export.PdfExport.java
License:Open Source License
/** * adds organized, structured, highlighted source code to new paragraph and * returns it/*from w w w .j a va2 s . com*/ * * @author Sebastian Schmitz & Frank Weiler * @param sourceCode * the source code as string including html tags for highlighting * etc * @return a paragraph including the source code * @throws DocumentException * will be thrown when new paragraph could not have been added */ private Paragraph toParagraph(StyledText sourceCode) throws DocumentException { if (sourceCode == null) return null; String content = highlightStyleTextinHTML(sourceCode); // returnt den // nicht // eingerckten, // aber // gehighlighteten // Code Paragraph paragraph = new Paragraph(); if (content != null) { content = indentCode(content); // rckt den Code ein List<Element> bodyText; StyleSheet styles = new StyleSheet(); styles.loadTagStyle("ol", "leading", "16,0"); try { bodyText = HTMLWorker.parseToList(new StringReader(content), styles); paragraph.setFont(FontFactory.getFont("Courier", 10, Font.NORMAL)); for (Element elem : bodyText) { paragraph.add(elem); } } catch (IOException e) { paragraph.add(Messages.noSourceCodeAdded); } } return paragraph; }
From source file:de.unisiegen.informatik.bs.alvis.export.PdfExport.java
License:Open Source License
/** * adds one line of organized, structured, highlighted source code to new * paragraph and returns it//ww w .j a v a 2s. com * * @author Sebastian Schmitz & Frank Weiler * @param sourceCode * the source code as string including html tags for highlighting * etc * @param wantedLineIndex * the wanted line number * @return a paragraph including the source code line * @throws DocumentException * will be thrown when new paragraph could not have been added */ private Paragraph toParagraph(StyledText sourceCode, int wantedLineIndex) throws DocumentException { if (sourceCode == null) return null; if (wantedLineIndex < 0 || wantedLineIndex >= sourceCode.getLineCount()) return null; String content = highlightStyleTextinHTML(sourceCode, wantedLineIndex); Paragraph paragraph = new Paragraph(); if (content != null) { List<Element> bodyText; StyleSheet styles = new StyleSheet(); styles.loadTagStyle("ol", "leading", "16,0"); try { bodyText = HTMLWorker.parseToList(new StringReader(content), styles); paragraph.setFont(FontFactory.getFont("Courier", 10, Font.NORMAL)); for (Element elem : bodyText) { paragraph.add(elem); } } catch (IOException e) { paragraph.add(Messages.noSourceCodeAdded); } } return paragraph; }
From source file:direccion.GeneradorFormato.java
@Override public void onEndPage(PdfWriter writer, Document document) { Rectangle rect = writer.getBoxSize("art"); Image imghead = null;// w w w .j av a 2 s .co m PdfContentByte cbhead = null; // try { // imghead = Image.getInstance("LogoSapito5.png"); // imghead.setAbsolutePosition(0, 0); // imghead.setAlignment(Image.ALIGN_CENTER); // imghead.scalePercent(10f); // cbhead = writer.getDirectContent(); // PdfTemplate tp = cbhead.createTemplate(100, 150); // tp.addImage(imghead); // cbhead.addTemplate(tp, 100, 715); // } catch (BadElementException e) { // e.printStackTrace(); // } catch (IOException e) { // e.printStackTrace(); // } catch (DocumentException e) { // e.printStackTrace(); // } Phrase headPhraseImg = new Phrase(cbhead + "", FontFactory.getFont(FontFactory.TIMES_ROMAN, 7, Font.NORMAL)); Calendar c1 = Calendar.getInstance(); Calendar c2 = new GregorianCalendar(); String dia, mes, annio; dia = Integer.toString(c1.get(Calendar.DATE)); mes = Integer.toString(c1.get(Calendar.MONTH)); annio = Integer.toString(c1.get(Calendar.YEAR)); Date fecha = new Date(); String fechis = dia + "/" + mes + "/" + annio; Paragraph parrafo5 = new Paragraph(fechis, FontFactory.getFont(FontFactory.TIMES_ROMAN, 11, Font.NORMAL, BaseColor.BLACK)); ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_CENTER, new Phrase(parrafo5), rect.getRight(450), rect.getTop(-80), 0); Paragraph parrafo7 = new Paragraph("Empresa Sapito S.A. de C.V.", FontFactory.getFont(FontFactory.TIMES_ROMAN, 16, Font.BOLD, BaseColor.BLACK)); ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_CENTER, new Phrase(parrafo7), rect.getBottom(250), rect.getTop(-60), 0); Paragraph parrafo8 = new Paragraph("Reporte algoooooo", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.BOLD, BaseColor.BLACK)); ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_CENTER, new Phrase(parrafo8), rect.getBottom(250), rect.getTop(-40), 0); ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_BOTTOM, new Phrase( " _____________________________________________________________________________________ "), rect.getBorder(), rect.getTop(650), 0); ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_BOTTOM, new Phrase( " _____________________________________________________________________________________ "), rect.getBorder(), rect.getTop(-24), 0); ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_BOTTOM, new Phrase( " _____________________________________________________________________________________ "), rect.getBorder(), rect.getTop(-20), 0); Paragraph parrafo6 = new Paragraph(String.format("Pg %d", writer.getPageNumber()), FontFactory.getFont(FontFactory.TIMES_ROMAN, 11, Font.NORMAL, BaseColor.BLACK)); ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_CENTER, new Phrase(parrafo6), rect.getRight(-35), rect.getTop(-80), 0); }
From source file:edu.cornell.mannlib.vitro.webapp.visualization.visutils.PDFDocument.java
License:Open Source License
public PDFDocument(String authorName, Map<String, Integer> yearToPublicationCount, Document document, PdfWriter pdfWriter) {//from w w w . ja v a 2 s . co m // setPreferredSize(new Dimension(600,400)); try { document.addTitle("PDF Pipeline iText Prototype"); document.addAuthor(authorName); document.addSubject("This example tests text, color, image, transparency & table functionality."); document.addKeywords("text, color, image, transparency, table"); document.addCreator("Standalone PDF Renderer using iText"); Paragraph header = new Paragraph(); Font pageHeaderStyle = FontFactory.getFont(FontFactory.TIMES_ROMAN, 15, Font.BOLDITALIC | Font.UNDERLINE); Font featureHeaderStyle = FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, new BaseColor(Color.red)); header.add(new Chunk("PDF Pipeline Prototype v2 using iText\n", pageHeaderStyle)); header.setSpacingAfter(15f); document.add(header); Paragraph content = new Paragraph(); content.add(new Chunk("Publication Count - Author Name - " + authorName, featureHeaderStyle)); content.setSpacingAfter(15f); document.add(content); // step4 PdfPTable publicationCount = createTable(yearToPublicationCount); document.add(publicationCount); content = new Paragraph(); content.add(new Chunk("Transparency of Shapes", featureHeaderStyle)); content.setSpacingAfter(15f); document.add(content); createTransparencyShapes(document, pdfWriter); createImage(document, pdfWriter, featureHeaderStyle); } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:edu.uc.modulocontable.general.GenerarKardexPDF.java
private void totalDetalleDocumento() throws DocumentException { PdfPTable tablePanelInicial = new PdfPTable(11); tablePanelInicial.setWidthPercentage(100); tablePanelInicial.getDefaultCell().setBorder(0); titulo4.setTexto(""); tablePanelInicial.addCell(titulo4.getElemento()); titulo4.setTexto(""); tablePanelInicial.addCell(titulo4.getElemento()); titulo4.setTexto(""); tablePanelInicial.addCell(titulo4.getElemento()); PdfPCell cell = new PdfPCell(new Paragraph("Total", FontFactory.getFont("arial", 9, Font.BOLD))); cell.setHorizontalAlignment(1);//from w w w . j a v a 2 s . c om cell.setBorder(0); tablePanelInicial.addCell(cell); cell = new PdfPCell( new Paragraph(String.valueOf(getCantidadEntrada()), FontFactory.getFont("arial", 8, Font.BOLD))); cell.setHorizontalAlignment(1); cell.setBorder(0); tablePanelInicial.addCell(cell); titulo4.setTexto(""); tablePanelInicial.addCell(titulo4.getElemento()); cell = new PdfPCell( new Paragraph(String.valueOf(getCantidadSalida()), FontFactory.getFont("arial", 8, Font.BOLD))); cell.setHorizontalAlignment(2); cell.setBorder(0); tablePanelInicial.addCell(cell); titulo4.setTexto(""); tablePanelInicial.addCell(titulo4.getElemento()); titulo4.setTexto(""); tablePanelInicial.addCell(titulo4.getElemento()); titulo4.setTexto(String.valueOf(getSaldoCantidad())); tablePanelInicial.addCell(titulo4.getElemento()); cell = new PdfPCell( new Paragraph("$ " + String.valueOf(getSaldoTotal()), FontFactory.getFont("arial", 8, Font.BOLD))); cell.setHorizontalAlignment(1); cell.setBorder(0); tablePanelInicial.addCell(cell); documento.add(tablePanelInicial); documento.add(espacioBlanco.getElemento()); documento.add(lineaNormal.getLinea()); }
From source file:edu.uc.modulocontable.general.GenerarKardexPDF.java
private void cabeceraTabla() throws DocumentException { PdfPTable tablePanelInicial = new PdfPTable(4); tablePanelInicial.setWidthPercentage(100); tablePanelInicial.setWidths(new int[] { 28, 15, 15, 15 }); tablePanelInicial.getDefaultCell().setBorder(5); tablePanelInicial.setHorizontalAlignment(2); PdfPCell cell = new PdfPCell(new Paragraph("", FontFactory.getFont("arial", 10, Font.BOLD))); cell.setHorizontalAlignment(1);/* w w w. j ava 2 s .c om*/ cell.setBorder(0); tablePanelInicial.addCell(cell); cell = new PdfPCell(new Paragraph("Entrada", FontFactory.getFont("arial", 10, Font.BOLD))); cell.setHorizontalAlignment(1); tablePanelInicial.addCell(cell); cell = new PdfPCell(new Paragraph("Salida", FontFactory.getFont("arial", 10, Font.BOLD))); cell.setHorizontalAlignment(1); tablePanelInicial.addCell(cell); cell = new PdfPCell(new Paragraph("Saldo", FontFactory.getFont("arial", 10, Font.BOLD))); cell.setHorizontalAlignment(1); tablePanelInicial.addCell(cell); documento.add(tablePanelInicial); }
From source file:edu.uc.modulocontable.general.GenerarKardexPDF.java
private void comprobarLIFO() throws DocumentException { PdfPTable tablePanelInicial = new PdfPTable(1); tablePanelInicial.setWidthPercentage(100); tablePanelInicial.getDefaultCell().setBorder(0); tablePanelInicial.setHorizontalAlignment(2); PdfPCell cell = new PdfPCell(new Paragraph("Comprobacin", FontFactory.getFont("arial", 10, Font.BOLD))); cell.setHorizontalAlignment(2);// w ww .java2s .c om cell.setBorder(0); tablePanelInicial.addCell(cell); documento.add(espacioBlanco.getElemento()); documento.add(espacioBlanco.getElemento()); documento.add(tablePanelInicial); documento.add(espacioBlanco.getElemento()); tablaVertical.limpiar(); int[] alineamientos = { 0, 2 }; int[] tamanos = { 20, 17 }; Vector datos = new Vector(); Vector<String> titulos = new Vector<String>(); datos.add(0); titulos.add("Inv. inicial"); datos.add(getCantidadEntrada()); titulos.add("(+) U. entrada"); datos.add(getCantidadSalida()); titulos.add("(-) U. salida"); datos.add(getSaldoCantidad()); titulos.add("(=) Stock"); String[] anArray = new String[titulos.size()]; tablaVertical.setTitulos(titulos.toArray(anArray)); tablaVertical.setContenidos(datos.toArray()); tablaVertical.setAlineamientos(alineamientos); tablaVertical.llenarTabla(true); tablaVertical.setPosicion(2); tablaVertical.setAnchoTabla(42); tablaVertical.setTamanos(tamanos); documento.add(tablaVertical.getTabla()); }
From source file:edu.uc.modulocontable.transaccion.GenerarComprobacion.java
private void cabeceraTabla() throws DocumentException { PdfPTable tablePanelInicial = new PdfPTable(5); tablePanelInicial.setWidthPercentage(100); tablePanelInicial.setWidths(new int[] { 10, 5, 5, 5, 5 }); tablePanelInicial.getDefaultCell().setBorder(5); tablePanelInicial.setHorizontalAlignment(2); PdfPCell cell = new PdfPCell(new Paragraph("", FontFactory.getFont("arial", 10, Font.BOLD))); cell.setHorizontalAlignment(1);/*from w w w . j av a 2 s . co m*/ cell.setBorder(0); tablePanelInicial.addCell(cell); cell = new PdfPCell(new Paragraph("Suma", FontFactory.getFont("arial", 10, Font.BOLD))); cell.setHorizontalAlignment(1); tablePanelInicial.addCell(cell); cell = new PdfPCell(new Paragraph("Saldos", FontFactory.getFont("arial", 10, Font.BOLD))); cell.setHorizontalAlignment(1); tablePanelInicial.addCell(cell); documento.add(tablePanelInicial); }