List of usage examples for com.itextpdf.text Font setStyle
public void setStyle(final String style)
String
containing one or more of the following values: normal, bold, italic, oblique, underline, line-through From source file:se.billes.pdf.renderer.model.text.Phrase.java
License:Open Source License
public void onRender(com.itextpdf.text.Paragraph paragraph) { Font font = new Font(getBaseFont(), getFontSize()); font.setColor(getBaseColor());//from ww w.j av a 2 s .com if (getStyle() != null) font.setStyle(getStyle()); String text = getText(); if (text.length() == 0) text = " "; text = text.replace(">", ">"); text = text.replace("<", "<"); Chunk chunk = new Chunk(text, font); if (getParagraph().getHyphenationAuto() != null) { chunk.setHyphenation(getParagraph().getHyphenationAuto()); } chunk.setTextRise(getTextRise()); chunk.setSkew(getSkewAlpha(), getSkewBeta()); paragraph.add(chunk); }
From source file:Servicios.GeneradorPDF.java
public void addTitulo(String texto) { try {//from www . ja va2s. com Font fuente = new Font(); fuente.setSize(this.tamTitulo); fuente.setStyle(1); Paragraph obj = new Paragraph(texto, fuente); obj.setAlignment(Element.ALIGN_CENTER); this.doc.add(obj); } catch (Exception e) { JOptionPane.showMessageDialog(null, "Error" + e.getMessage()); } }
From source file:storehausimport.SaveToPdf.java
public boolean save(String inputFilePath, String outputFilePath) throws Exception { if (outputFilePath.isEmpty()) { throw new Exception("Trkst parametrs outputFilePath"); }/* ww w .j a va2 s .c o m*/ if (inputFilePath.isEmpty()) { throw new Exception("Trkst parametrs inputFilePath"); } File inputFile = new File(inputFilePath); Document pdfDoc = new Document(); try { PdfWriter writer = PdfWriter.getInstance(pdfDoc, new FileOutputStream(outputFilePath)); pdfDoc.open(); pdfDoc.setMarginMirroring(true); pdfDoc.setMargins(36, 72, 108, 180); pdfDoc.topMargin(); BaseFont helvetica = BaseFont.createFont("Helvetica", BaseFont.CP1257, BaseFont.NOT_EMBEDDED); Font normal_font = new Font(helvetica, 10, Font.NORMAL); Font bold_font = new Font(); bold_font.setStyle(Font.BOLD); bold_font.setSize(10); pdfDoc.add(new Paragraph("\n")); if (inputFile.exists()) { iStream = new FileInputStream(inputFile); in = new DataInputStream(iStream); is = new InputStreamReader(in); br = new BufferedReader(is); String strLine; while ((strLine = br.readLine()) != null) { Paragraph para = new Paragraph(strLine + "\n", normal_font); para.setAlignment(Element.ALIGN_LEFT); pdfDoc.add(para); } } else { pdfDoc.close(); throw new Exception("Trkst parametrs inputFilePath"); } pdfDoc.close(); } catch (Exception ex) { throw new Exception(ex); } return true; }
From source file:utils.PrintUtils.java
public static Font setUpFont(final float size, final int style, final BaseColor color) { Font font = new Font(); font.setStyle(style); font.setSize(size);/*from w w w .ja va 2 s.c o m*/ font.setColor(color); return font; }