private PdfPCell buildPdfPCell(HeaderFooter phf,String text,int type){ PdfPCell cell=new PdfPCell(); cell.setPadding(0); cell.setBorder(Rectangle.NO_BORDER); Font font=FontBuilder.getFont(phf.getFontFamily(), phf.getFontSize(), phf.isBold(), phf.isItalic(),phf.isUnderline()); String fontColor=phf.getForecolor(); if(StringUtils.isNotEmpty(fontColor)){ String[] color=fontColor.split(","); font.setColor(Integer.valueOf(color[0]), Integer.valueOf(color[1]), Integer.valueOf(color[2])); } Paragraph graph=new Paragraph(text,font); cell.setPhrase(graph); switch(type){ case 1: cell.setHorizontalAlignment(Element.ALIGN_LEFT); break; case 2: cell.setHorizontalAlignment(Element.ALIGN_CENTER); break; case 3: cell.setHorizontalAlignment(Element.ALIGN_RIGHT); break; } cell.setVerticalAlignment(Element.ALIGN_MIDDLE); return cell; } }
/** * Constructs a new <CODE>Chapter</CODE>. * * @param title the Chapter title (as a <CODE>String</CODE>) * @param number the Chapter number */ public Chapter(String title, int number) { this(new Paragraph(title), number); }
/** * Constructs a new <CODE>Chapter</CODE>. * * @param title the Chapter title (as a <CODE>String</CODE>) * @param number the Chapter number */ public Chapter(String title, int number) { this(new Paragraph(title), number); }
/** * Adds a <CODE>Section</CODE> to this <CODE>Section</CODE> and returns it. * * @param title the title of the new section * @param numberDepth the numberDepth of the section * @return a new Section object */ public Section addSection(final String title, final int numberDepth) { return addSection(new Paragraph(title), numberDepth); }
/** * Adds a <CODE>Section</CODE> to this <CODE>Section</CODE> and returns it. * * @param indentation the indentation of the new section * @param title the title of the new section * @return a new Section object */ public Section addSection(final float indentation, final String title) { return addSection(indentation, new Paragraph(title)); }
/** * Gets the bookmark title. * @return the bookmark title */ public Paragraph getBookmarkTitle() { if (bookmarkTitle == null) return getTitle(); else return new Paragraph(bookmarkTitle); }
/** * Adds a <CODE>Section</CODE> to this <CODE>Section</CODE> and returns it. * * @param indentation the indentation of the new section * @param title the title of the new section * @param numberDepth the numberDepth of the section * @return a new Section object */ public Section addSection(final float indentation, final String title, final int numberDepth) { return addSection(indentation, new Paragraph(title), numberDepth); }
/** * Creates a shallow clone of the Paragraph. * @return */ public Paragraph cloneShallow(boolean spacingBefore) { Paragraph copy = new Paragraph(); populateProperties(copy, spacingBefore); return copy; }
/** * Stacks the current paragraph, indicating that we're starting * a new span. * @since 5.0.6 */ public void flushContent() { pushToStack(currentParagraph); currentParagraph = new Paragraph(); }
/** * Adds a <CODE>Section</CODE> to this <CODE>Section</CODE> and returns it. * * @param indentation the indentation of the new section * @param title the title of the new section * @return a new Section object */ public Section addSection(final float indentation, final String title) { return addSection(indentation, new Paragraph(title)); }
private void addEmptyLine(Document doc, int number) throws DocumentException { for (int i = 0; i < number; i++) { doc.add(new Paragraph(" ")); } }
/** * Adds a <CODE>Section</CODE> to this <CODE>Section</CODE> and returns it. * * @param indentation the indentation of the new section * @param title the title of the new section * @param numberDepth the numberDepth of the section * @return a new Section object */ public Section addSection(final float indentation, final String title, final int numberDepth) { return addSection(indentation, new Paragraph(title), numberDepth); }
/** * Constructs a new <CODE>Section</CODE>. */ protected Section() { title = new Paragraph(); numberDepth = 1; title.setRole(new PdfName("H" + numberDepth)); }
private void emitUri(FeatureExec feature, ITextContext emitterContext) { Styles styles = emitterContext.keyValues().<Styles>getNullable(Styles.class).get(); Paragraph uri = new Paragraph("Uri: " + feature.uri(), styles.getFontOrDefault(Settings.META_FONT)); emitterContext.append(uri); }
private Element createFooter() { final Paragraph footer = new Paragraph(); footer.add(new Phrase("Generated using ", FONT_FOOTER)); final Anchor a = new Anchor(config.getProperty("app.name"), FONT_FOOTER); a.setReference("http://timurstrekalov.github.com/saga/"); footer.add(a); footer.add(new Phrase(" version " + config.getProperty("app.version"), FONT_FOOTER)); footer.setAlignment(Element.ALIGN_RIGHT); return footer; }
private void addContent(final TestRunCoverageStatistics runStats) throws DocumentException { final Paragraph title = new Paragraph(runStats.title, FONT_H1); title.setIndentationLeft(PADDING_LEFT); document.add(title); document.add(createTable(runStats)); document.add(createFooter()); }
private PdfPCell titleCell(ScenarioExec scenarioExec, Styles styles) { Font font = styles.defaultFont(); Paragraph p = new Paragraph(scenarioExec.name(), font); PdfPCell cell = new PdfPCell(p); cell.setVerticalAlignment(Element.ALIGN_TOP); cell.setHorizontalAlignment(Element.ALIGN_LEFT); if (!debugTable) cell.setBorder(Rectangle.NO_BORDER); return cell; }
private PdfPCell keywordCell(StepExec step, Styles styles) { Font stepKeywordFont = styles.getFontOrDefault(STEP_KEYWORD_FONT); Paragraph pKeyword = new Paragraph(step.keyword(), stepKeywordFont); PdfPCell keywordCell = new PdfPCell(pKeyword); keywordCell.setVerticalAlignment(Element.ALIGN_TOP); keywordCell.setHorizontalAlignment(Element.ALIGN_RIGHT); keywordCell = noBorder(keywordCell); return keywordCell; }
private static void createPDF(String path) throws Exception { Document pdfDoc = new Document(PageSize.A4); PdfWriter.getInstance(pdfDoc, new FileOutputStream(path)).setPdfVersion(PdfWriter.VERSION_1_7); pdfDoc.open(); Font myfont = new Font(); myfont.setStyle(Font.NORMAL); myfont.setSize(11); Paragraph para = new Paragraph("test", myfont); para.setAlignment(Element.ALIGN_JUSTIFIED); pdfDoc.add(para); pdfDoc.close(); }