Java 类com.itextpdf.text.FontFactory 实例源码

项目:NICON    文件:ExporOnlyViagemPdf.java   
private PdfPTable cellRodape(String value, boolean l,boolean r,int align)
{
    Font fontCorpoTableO= FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED ,7.5f);
    PdfPTable pTable = new PdfPTable(1);
    pTable.setWidthPercentage(100f);
    PdfPCell cellValue = new PdfPCell(new Phrase(value,fontCorpoTableO));
    if(l){cellValue.setBorderWidthLeft(0);}
    if(r){cellValue.setBorderWidthRight(0);}
   switch (align) 
   {
       case Element.ALIGN_RIGHT:cellValue.setHorizontalAlignment(Element.ALIGN_RIGHT);break;
       case Element.ALIGN_LEFT:cellValue.setHorizontalAlignment(Element.ALIGN_LEFT);break;
       case Element.ALIGN_CENTER:cellValue.setHorizontalAlignment(Element.ALIGN_CENTER);break;
       default:break;
   }
    pTable.addCell(cellValue);
    return pTable;
}
项目:NICON    文件:ExportMapaProducao__.java   
private Phrase funcaoTitulo(int i) {
    String txt;
    Font fontcabecatable =  FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED ,10f );
    switch (i)
    {
        case 0:txt="Nr. Factura";break;
        case 1:txt="Nome do Segurado"; break;
        case 2:txt="Prémio";break;
        case 3:txt="Imposto 6%";break;
        case 4:txt="Imposto 5%";break;
        case 5:txt="FGA 2.6%";break;
        default:txt="TOTAL";break;
    }

    a=com.itextpdf.text.Element.ALIGN_CENTER;
    Phrase rt = new Phrase(txt,fontcabecatable);
    return rt; 
}
项目:NICON    文件:ExporOnlyViagemPdf.java   
private PdfPTable cellRodape(String value, boolean l,boolean r,int align)
{
    Font fontCorpoTableO= FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED ,7.5f);
    PdfPTable pTable = new PdfPTable(1);
    pTable.setWidthPercentage(100f);
    PdfPCell cellValue = new PdfPCell(new Phrase(value,fontCorpoTableO));
    if(l){cellValue.setBorderWidthLeft(0);}
    if(r){cellValue.setBorderWidthRight(0);}
   switch (align) 
   {
       case Element.ALIGN_RIGHT:cellValue.setHorizontalAlignment(Element.ALIGN_RIGHT);break;
       case Element.ALIGN_LEFT:cellValue.setHorizontalAlignment(Element.ALIGN_LEFT);break;
       case Element.ALIGN_CENTER:cellValue.setHorizontalAlignment(Element.ALIGN_CENTER);break;
       default:break;
   }
    pTable.addCell(cellValue);
    return pTable;
}
项目:NICON    文件:ExportMapaProducao__.java   
private Phrase funcaoTitulo(int i) {
    String txt;
    Font fontcabecatable =  FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED ,10f );
    switch (i)
    {
        case 0:txt="Nr. Factura";break;
        case 1:txt="Nome do Segurado"; break;
        case 2:txt="Prémio";break;
        case 3:txt="Imposto 6%";break;
        case 4:txt="Imposto 5%";break;
        case 5:txt="FGA 2.6%";break;
        default:txt="TOTAL";break;
    }

    a=com.itextpdf.text.Element.ALIGN_CENTER;
    Phrase rt = new Phrase(txt,fontcabecatable);
    return rt; 
}
项目:displaytag    文件:ItextTotalWrapper.java   
/**
 * Writes a total line.
 * @param value Total message.
 * @param total Total number.
 */
private void writeTotal(String value, double total)
{
    if (assertRequiredState())
    {
        this.font = FontFactory.getFont(
            this.font.getFamilyname(),
            this.font.getSize(),
            Font.BOLD,
            this.font.getColor());
        table.addCell(this.getCell(""));
        table.addCell(this.getCell(""));
        table.addCell(this.getCell("-------------"));
        table.addCell(this.getCell(""));
        // new row
        table.addCell(this.getCell(""));
        table.addCell(this.getCell(value + " Total:"));
        table.addCell(this.getCell(total + ""));
        table.addCell(this.getCell(""));
    }
}
项目:cucumber-contrib    文件:GrammarPdfReport.java   
private void emitMethodSummary(final PdfPTable summaryTable, MethodEntry methodEntry) {
    log.debug("Emitting summary for method {}", methodEntry.signature());

    methodEntry.patterns().forEach(new Consumer<String>() {
        @Override
        public void accept(String pattern) {
            Phrase phrase = new Phrase(pattern, FontFactory.getFont("Arial", 10, BLACK));
            PdfPCell patternCell = new PdfPCell(phrase);
            patternCell.setColspan(SUMMARY_NB_COLS - 2);
            patternCell.setBorder(Rectangle.BOTTOM);
            patternCell.setBorderColor(BaseColor.LIGHT_GRAY);

            summaryTable.addCell(emptyCell(2));
            summaryTable.addCell(patternCell);
        }
    });
}
项目:DWSurvey    文件:ItextpdfTest.java   
public static void writeSimplePdf() throws Exception{
            //1.新建document对象
            //第一个参数是页面大小。接下来的参数分别是左、右、上和下页边距。
            Document document = new Document(PageSize.A4, 50, 50, 50, 50);
            //2.建立一个书写器(Writer)与document对象关联,通过书写器(Writer)可以将文档写入到磁盘中。
            //创建 PdfWriter 对象 第一个参数是对文档对象的引用,第二个参数是文件的实际名称,在该名称中还会给出其输出路径。
            PdfWriter writer = PdfWriter.getInstance(document,  new FileOutputStream("D:\\Documents\\ITextTest.pdf"));
            //3.打开文档
            document.open();        
            //4.向文档中添加内容
            //通过 com.lowagie.text.Paragraph 来添加文本。可以用文本及其默认的字体、颜色、大小等等设置来创建一个默认段落
            BaseFont bfChinese = BaseFont.createFont("STSong-Light","UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
            Font fontChinese = new Font(bfChinese, 22, Font.BOLD, BaseColor.BLACK);

            document.add(new Paragraph("sdfsdfsd全是中文显示了没.fsdfsfs",fontChinese));
            document.add(new Paragraph("Some more text on the   first page with different color and font type.",
                    FontFactory.getFont(FontFactory.COURIER, 14, Font.BOLD, new BaseColor(255, 150, 200))));
            Paragraph pragraph=new Paragraph("你这里有中亠好", fontChinese);
            document.add(pragraph);

            //图像支持格式 GIF, Jpeg, PNG, wmf
            Image gif = Image.getInstance("F:/keyworkspace/survey/WebRoot/images/logo/snlogo.png");
            gif.setBorder(5);
            gif.scaleAbsolute(30,30);
            gif.setAlignment(Image.RIGHT|Image.TEXTWRAP);
            document.add(gif);
            Paragraph pragraph11=new Paragraph("你这里有中亠好你这里有中亠好你这里有中亠好你这里有中亠好你这里有中亠好你这里有中亠好你这里有中亠好你这里有中亠好你这里有中亠好你这里有中亠好", fontChinese);
            document.add(pragraph11);

            Image gif15 = Image.getInstance("F:/keyworkspace/survey/WebRoot/images/logo/snlogo.png");
//          gif15.setBorder(50);
            gif15.setBorder(Image.BOX);
            gif15.setBorderColor(BaseColor.RED);
//          gif15.setBorderColorBottom(borderColorBottom)
            gif15.setBorderWidth(1);
            gif15.scalePercent(50);
            document.add(gif15);
            //5.关闭文档
            document.close();
        }
项目:java_pdf_demo    文件:JavaToPdfCN.java   
public static void main(String[] args) throws FileNotFoundException, DocumentException {
    Document document = new Document();
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(DEST));
    document.open();
    Font font = FontFactory.getFont(FONT, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
    document.add(new Paragraph("hello world,我是rainbowhorse。", font));
    document.close();
    writer.close();
}
项目:TuxGuitar-1.3.1-fork    文件:PDFController.java   
public void configureStyles(TGLayoutStyles styles) {
    TGConfigManager config = TuxGuitar.getInstance().getConfig();

    styles.setBufferEnabled(false);
    styles.setFirstMeasureSpacing(DEFAULT_HORIZONTAL_SPACING);
    styles.setMinBufferSeparator(DEFAULT_MIN_BUFFER_SEPARATOR);
    styles.setMinTopSpacing(DEFAULT_MIN_TOP_SPACING);
    styles.setMinScoreTabSpacing(MIN_SCORE_TAB_SPACING);
    styles.setScoreLineSpacing(DEFAULT_SCORE_LINE_SPACING);
    styles.setFirstTrackSpacing(DEFAULT_FIRST_TRACK_SPACING);
    styles.setTrackSpacing(DEFAULT_TRACK_SPACING);
    styles.setStringSpacing(DEFAULT_STRING_SPACING);
    styles.setChordFretIndexSpacing(CHORD_FRET_INDEX_SPACING);
    styles.setChordStringSpacing(CHORD_STRING_SPACING);
    styles.setChordFretSpacing(CHORD_FRET_SPACING);
    styles.setChordNoteSize(3);
    styles.setChordLineWidth(1);
    styles.setRepeatEndingSpacing(20);
    styles.setTextSpacing(15);
    styles.setMarkerSpacing(15);
    styles.setDivisionTypeSpacing(10);
    styles.setEffectSpacing(8);
    styles.setDefaultFont(new TGFontModel(FontFactory.TIMES_ROMAN, 8, false, false));
    styles.setNoteFont(new TGFontModel(FontFactory.TIMES_BOLD, 9, true, false));
    styles.setTimeSignatureFont(new TGFontModel(FontFactory.TIMES_BOLD, 15, true, false));
    styles.setLyricFont(new TGFontModel(FontFactory.TIMES_ROMAN, 8, false, false));
    styles.setTextFont(new TGFontModel(FontFactory.TIMES_ROMAN, 8, false, false));
    styles.setGraceFont(new TGFontModel(FontFactory.TIMES_ROMAN, 8, false, false));
    styles.setChordFont(new TGFontModel(FontFactory.TIMES_ROMAN, 8, false, false));
    styles.setChordFretFont(new TGFontModel(FontFactory.TIMES_ROMAN, 8, false, false));
    styles.setMarkerFont(new TGFontModel(FontFactory.TIMES_ROMAN, 8, false, false));
    styles.setBackgroundColor(config.getColorModelConfigValue(TGConfigKeys.COLOR_BACKGROUND));
    styles.setLineColor(config.getColorModelConfigValue(TGConfigKeys.COLOR_LINE));
    styles.setScoreNoteColor(config.getColorModelConfigValue(TGConfigKeys.COLOR_SCORE_NOTE));
    styles.setTabNoteColor(config.getColorModelConfigValue(TGConfigKeys.COLOR_TAB_NOTE));
    styles.setPlayNoteColor(config.getColorModelConfigValue(TGConfigKeys.COLOR_PLAY_NOTE));
    styles.setLoopSMarkerColor(config.getColorModelConfigValue(TGConfigKeys.COLOR_LOOP_S_MARKER));
    styles.setLoopEMarkerColor(config.getColorModelConfigValue(TGConfigKeys.COLOR_LOOP_E_MARKER));
}
项目:BudgetMaster    文件:HeaderFooterPageEvent.java   
public void onEndPage(PdfWriter writer, Document document)
{
    Font font = FontFactory.getFont(Fonts.OPEN_SANS, BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 8, Font.NORMAL, BaseColor.BLACK);

    ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_CENTER, new Phrase(Localization.getString(Strings.REPORT_FOOTER_LEFT), font), 100, 25, 0);
    ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_CENTER, new Phrase(Localization.getString(Strings.REPORT_FOOTER_CENTER, document.getPageNumber()), font), 300, 25, 0);
    ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_CENTER, new Phrase(DateTime.now().toString("dd.MM.YYYY"), font), 500, 25, 0);
}
项目:BudgetMaster    文件:ReportGenerator.java   
private Chapter generateHeader()
{   
    Font font = FontFactory.getFont(FONT, BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 16, Font.BOLDITALIC, BaseColor.BLACK);
    Chunk chunk = new Chunk(Localization.getString(Strings.REPORT_HEADLINE, date.toString("MMMM yyyy")), font);
    Chapter chapter = new Chapter(new Paragraph(chunk), 1);
    chapter.setNumberDepth(0);
    chapter.add(Chunk.NEWLINE);
    return chapter;
}
项目:BudgetMaster    文件:ReportGenerator.java   
private PdfPTable generateCategoryBudgets()
{
    PdfPTable table = new PdfPTable(2);
    table.setWidthPercentage(100);
    Font font = FontFactory.getFont(FONT, BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 8, Font.NORMAL, BaseColor.BLACK);

    //header cells
    PdfPCell cellHeaderCategory = new PdfPCell(new Phrase(Localization.getString(Strings.TITLE_CATEGORY), font));
    cellHeaderCategory.setBackgroundColor(GrayColor.LIGHT_GRAY);
    cellHeaderCategory.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(cellHeaderCategory);
    PdfPCell cellHeaderAmount = new PdfPCell(new Phrase(Localization.getString(Strings.TITLE_AMOUNT), font));
    cellHeaderAmount.setBackgroundColor(GrayColor.LIGHT_GRAY);
    cellHeaderAmount.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(cellHeaderAmount);        

    for(CategoryBudget budget : categoryBudgets)
    {               
        PdfPCell cellName = new PdfPCell(new Phrase(budget.getCategory().getName(), font));
        cellName.setBackgroundColor(new BaseColor(Color.WHITE));
        cellName.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellName.setVerticalAlignment(Element.ALIGN_MIDDLE);
        table.addCell(cellName);

        PdfPCell cellAmount = new PdfPCell(new Phrase(Helpers.getCurrencyString(budget.getBudget() / 100.0, currency), font));
        cellAmount.setBackgroundColor(new BaseColor(Color.WHITE));
        cellAmount.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellAmount.setVerticalAlignment(Element.ALIGN_MIDDLE);
        table.addCell(cellAmount);
    }

    return table;
}
项目:bamboobsc    文件:PersonalReportPdfCommand.java   
private Font getFont(String color, boolean bold) throws Exception {
    Font font = FontFactory.getFont(BscConstants.PDF_ITEXT_FONT, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
    int rgb[] = SimpleUtils.getColorRGB2(color);
    BaseColor baseColor = new BaseColor(rgb[0], rgb[1], rgb[2]);
    font.setSize(9);
    font.setColor(baseColor);
    return font;
}
项目:bamboobsc    文件:KpiReportPdfCommand.java   
private Font getFont(String color, boolean bold) throws Exception {
    Font font = FontFactory.getFont(BscConstants.PDF_ITEXT_FONT, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
    int rgb[] = SimpleUtils.getColorRGB2(color);
    BaseColor baseColor = new BaseColor(rgb[0], rgb[1], rgb[2]);
    font.setSize(9);
    if (bold) {
        font.setSize(14);
        font.setStyle(Font.BOLD);
    }       
    font.setColor(baseColor);
    return font;
}
项目:bamboobsc    文件:OrganizationReportPdfCommand.java   
private Font getFont(String color, boolean bold) throws Exception {
    Font font = FontFactory.getFont(BscConstants.PDF_ITEXT_FONT, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
    int rgb[] = SimpleUtils.getColorRGB2(color);
    BaseColor baseColor = new BaseColor(rgb[0], rgb[1], rgb[2]);
    font.setSize(9);
    font.setColor(baseColor);
    return font;
}
项目:ephesoft    文件:MultiPageExecutor.java   
/**
 * The <code>addImageToPdf</code> method is used to add image to pdf and make it searchable by adding image text in invisible mode
 * w.r.t parameter 'isPdfSearchable' passed.
 * 
 * @param pdfWriter {@link PdfWriter} writer of pdf in which image has to be added
 * @param htmlUrl {@link HocrPage} corresponding html file for fetching text and coordinates
 * @param imageUrl {@link String} url of image to be added in pdf
 * @param isPdfSearchable true for searchable pdf else otherwise
 * @param widthOfLine
 */
private void addImageToPdf(PdfWriter pdfWriter, HocrPage hocrPage, String imageUrl, boolean isPdfSearchable, final int widthOfLine) {
    if (null != pdfWriter && null != imageUrl && imageUrl.length() > 0) {
        try {
            LOGGER.info("Adding image" + imageUrl + " to pdf using iText");
            Image pageImage = Image.getInstance(imageUrl);
            float dotsPerPointX = pageImage.getDpiX() / PDF_RESOLUTION;
            float dotsPerPointY = pageImage.getDpiY() / PDF_RESOLUTION;
            PdfContentByte pdfContentByte = pdfWriter.getDirectContent();

            pageImage.scaleToFit(pageImage.getWidth() / dotsPerPointX, pageImage.getHeight() / dotsPerPointY);

            pageImage.setAbsolutePosition(0, 0);

            // Add image to pdf
            pdfWriter.getDirectContentUnder().addImage(pageImage);
            pdfWriter.getDirectContentUnder().add(pdfContentByte);

            // If pdf is to be made searchable
            if (isPdfSearchable) {
                LOGGER.info("Adding invisible text for image: " + imageUrl);
                float pageImagePixelHeight = pageImage.getHeight();
                Font defaultFont = FontFactory.getFont(FontFactory.HELVETICA, 8, Font.BOLD, CMYKColor.BLACK);

                // Fetch text and coordinates for image to be added
                Map<String, int[]> textCoordinatesMap = getTextWithCoordinatesMap(hocrPage, widthOfLine);
                Set<String> ketSet = textCoordinatesMap.keySet();

                // Add text at specific location
                for (String key : ketSet) {
                    int[] coordinates = textCoordinatesMap.get(key);
                    float bboxWidthPt = (coordinates[2] - coordinates[0]) / dotsPerPointX;
                    float bboxHeightPt = (coordinates[3] - coordinates[1]) / dotsPerPointY;
                    pdfContentByte.beginText();

                    // To make text added as invisible
                    pdfContentByte.setTextRenderingMode(PdfContentByte.TEXT_RENDER_MODE_INVISIBLE);
                    pdfContentByte.setLineWidth(Math.round(bboxWidthPt));

                    // Ceil is used so that minimum font of any text is 1
                    // For exception of unbalanced beginText() and endText()
                    if (bboxHeightPt > 0.0) {
                        pdfContentByte.setFontAndSize(defaultFont.getBaseFont(), (float) Math.ceil(bboxHeightPt));
                    } else {
                        pdfContentByte.setFontAndSize(defaultFont.getBaseFont(), 1);
                    }
                    float xCoordinate = (float) (coordinates[0] / dotsPerPointX);
                    float yCoordinate = (float) ((pageImagePixelHeight - coordinates[3]) / dotsPerPointY);
                    pdfContentByte.moveText(xCoordinate, yCoordinate);
                    pdfContentByte.showText(key);
                    pdfContentByte.endText();
                }
            }
            pdfContentByte.closePath();
        } catch (BadElementException badElementException) {
            LOGGER
                    .error("Error occurred while adding image" + imageUrl + " to pdf using Itext: "
                            + badElementException.toString());
        } catch (DocumentException documentException) {
            LOGGER.error("Error occurred while adding image" + imageUrl + " to pdf using Itext: " + documentException.toString());
        } catch (MalformedURLException malformedURLException) {
            LOGGER.error("Error occurred while adding image" + imageUrl + " to pdf using Itext: "
                    + malformedURLException.toString());
        } catch (IOException ioException) {
            LOGGER.error("Error occurred while adding image" + imageUrl + " to pdf using Itext: " + ioException.toString());
        }
    }
}
项目:FOXopen    文件:FontManager.java   
/**
 * Get a font with the provided font family and font attributes applied
 * @param pFontFamily The font family
 * @param pFontAttributes The font attributes to be applied
 * @return A font of the provided font family with font attributes applied
 * @throws ExInternal If the font family provided is not registered
 */
private Font getFont(String pFontFamily, FontAttributes pFontAttributes) throws ExInternal {
  Font lFont = FontFactory.getFont(pFontFamily, BaseFont.IDENTITY_H, BaseFont.EMBEDDED, pFontAttributes.getSize(),
                                   pFontAttributes.getStyle(), pFontAttributes.getColor());

  if (lFont.getBaseFont() == null) {
    throw new ExInternal("Could not create a font using font family '" + pFontFamily + "' as it could not be found in the registered fonts");
  }

  return lFont;
}
项目:iText-GUI    文件:StylesheetTester.java   
private void printExplanation(String txt) throws DocumentException {
   Font f = FontFactory.getFont(FontFactory.COURIER, 10, BaseColor.MAGENTA);
   Paragraph paragraph = new Paragraph(txt, f);
   float padding = ItextHelper.mmToPts(2);
   for (Chunk c : paragraph.getChunks()) {
      c.setBackground(new BaseColor(230, 230, 230), padding, padding, padding, padding);
   }
   getDocument().add(paragraph);
   newLine();
}
项目:ds4p    文件:ConsentRevokationPdfGenerator.java   
/**
 * Creates the table.
 *
 * @param consent the consent
 * @return the pdf p table
 */
private PdfPTable createTable(Consent consent) {
    Font fontbold = FontFactory.getFont("Helvetica", 15, Font.BOLD);

    PdfPTable table = new PdfPTable(new float[]{0.2f,0.8f});
    table.setWidthPercentage(100f);
    table.getDefaultCell().setBorder(0);


    Chunk chunk2=new Chunk("NO EXCEPT",fontbold);
    Chunk chunk3=new Chunk("NO NEVER",fontbold);
    if(consent.getConsentRevokationType().equals("EMERGENCY ONLY")){
        chunk2.append("\n(This is the option you chose.)");
    }
    else if(consent.getConsentRevokationType().equals("NO NEVER")){
        chunk3.append("\n(This is the option you chose.)");
    }

    table.addCell(new PdfPCell(new Phrase(chunk2)));
       table.addCell(new PdfPCell(new Phrase("I Deny Consent for all Participants to access " +
            "my electronic health information through Consent 2 Share for any purpose, EXCEPT " +
            "in a medical emergency. By checking this box you agree, \"No, none of the Participants" +
            " may be given access to my medical records through Consent 2 Share unless it is a medical emergency.\"")));
       table.addCell(new PdfPCell(new Phrase(chunk3)));
       table.addCell(new PdfPCell(new Phrase("I Deny Consent for all Participants to access my electronic health information" +
            " through Consent 2 Share for any purpose, INCLUDING in a medical emergency.")));

       return table;
}
项目:Introspect-Framework    文件:PdfReportFactory.java   
public void addInvisibleChapterForHeader(Document document, Section section) {
    try {
        Paragraph paragraph=new Paragraph(section.getSectionName(), FontFactory.getFont(FontFactory.COURIER,1f,BaseColor.WHITE));//hide chapter
        Chapter chapter = new Chapter(paragraph,0);
        document.add(chapter);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
项目:gutenberg    文件:CodeNodeProcessor.java   
private Supplier<? extends Font> inlineCodeFont(final Styles styles) {
    return new Supplier<Font>() {
        @Override
        public Font get() {
            try {
                return new Font(ITextUtils.inconsolata(), styles.defaultFontSize());
            } catch (Exception e) {
                log.warn("Fail to retrieve font", e);
                return FontFactory.getFont(FontFactory.COURIER, styles.defaultFontSize());
            }
        }
    };
}
项目:displaytag    文件:PdfView.java   
/**
 * Initialize the main info holder table.
 */
protected void initTable()
{
    tablePDF = new PdfPTable(this.model.getNumberOfColumns());
    tablePDF.getDefaultCell().setVerticalAlignment(Element.ALIGN_TOP);
    tablePDF.setWidthPercentage(100);

    smallFont = FontFactory.getFont(FontFactory.HELVETICA, 7, Font.NORMAL, new BaseColor(0, 0, 0));

}
项目:cucumber-contrib    文件:GrammarPdfReport.java   
private void emitPackageSummary(PdfPTable summaryTable, PackageEntry packageEntry) {
    log.debug("Emitting summary for package {}", packageEntry.name());

    if (packageEntry.hasClassEntries()) {
        Phrase phrase = new Phrase(packageEntry.name(), FontFactory.getFont("Arial", 8, WHITE));
        PdfPCell packageCell = new PdfPCell(phrase);
        packageCell.setBackgroundColor(BLACK);
        packageCell.setColspan(SUMMARY_NB_COLS);
        summaryTable.addCell(packageCell);

        packageEntry.classes().forEach(emitClassSummary(summaryTable));
    }

    packageEntry.subPackages().forEach(emitPackageSummary(summaryTable));
}
项目:cucumber-contrib    文件:GrammarPdfReport.java   
private void emitClassSummary(PdfPTable summaryTable, ClassEntry classEntry) {
    log.debug("Emitting summary for class {}", classEntry.name());

    Phrase phrase = new Phrase(classEntry.name(), FontFactory.getFont("Arial", 12, WHITE));
    PdfPCell classCell = new PdfPCell(phrase);
    classCell.setColspan(SUMMARY_NB_COLS - 1);
    classCell.setBackgroundColor(BaseColor.DARK_GRAY);
    classCell.setBorder(Rectangle.NO_BORDER);

    summaryTable.addCell(emptyCell());
    summaryTable.addCell(classCell);

    classEntry.methods().forEach(emitMethodSummary(summaryTable));
}
项目:Spring-MVC-Blueprints    文件:HRPDFBuilderImpl.java   
@SuppressWarnings("unchecked")
@Override
protected void buildPdfDocument(Map<String, Object> model, Document doc,
        PdfWriter writer, HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    // get data model which is passed by the Spring container
    List<HrmsLogin> users = (List<HrmsLogin>) model.get("allUsers");

    doc.add(new Paragraph("Master List of Users"));

    PdfPTable table = new PdfPTable(4);
    table.setWidthPercentage(100.0f);
    table.setWidths(new float[] {3.0f, 2.0f, 2.0f, 2.0f});
    table.setSpacingBefore(10);

    // define font for table header row
    Font font = FontFactory.getFont(FontFactory.HELVETICA);
    font.setColor(BaseColor.WHITE);

    // define table header cell
    PdfPCell cell = new PdfPCell();
    cell.setBackgroundColor(BaseColor.BLUE);
    cell.setPadding(5);

    // write table header
    cell.setPhrase(new Phrase("Employee ID", font));
    table.addCell(cell);

    cell.setPhrase(new Phrase("Username", font));
    table.addCell(cell);

    cell.setPhrase(new Phrase("Password", font));
    table.addCell(cell);

    cell.setPhrase(new Phrase("Role", font));
    table.addCell(cell);



    // write table row data
    for (HrmsLogin user : users) {
        table.addCell(user.getHrmsEmployeeDetails().getEmpId()+"");
        table.addCell(user.getUsername());
        table.addCell(user.getPassword());
        table.addCell(user.getRole());

    }

    doc.add(table);

}
项目:OSCAR-ConCert    文件:GenerateEnvelopesAction.java   
Paragraph getEnvelopeLabel(String text){
  Paragraph p = new Paragraph(text,FontFactory.getFont(FontFactory.HELVETICA, 18));
  p.setLeading(22);
  return p;
}
项目:bamboobsc    文件:PersonalReportPdfCommand.java   
private String createPdf(Context context) throws Exception {
    BscReportPropertyUtils.loadData();
    String visionOid = (String)context.get("visionOid");
    VisionVO vision = null;
    BscStructTreeObj treeObj = (BscStructTreeObj)this.getResult(context);
    for (VisionVO visionObj : treeObj.getVisions()) {
        if (visionObj.getOid().equals(visionOid)) {
            vision = visionObj;
        }
    }       
    FontFactory.register(BscConstants.PDF_ITEXT_FONT);
    String fileName = SimpleUtils.getUUIDStr() + ".pdf";
    String fileFullPath = Constants.getWorkTmpDir() + "/" + fileName;
    OutputStream os = new FileOutputStream(fileFullPath);
    Document document = new Document(PageSize.A4.rotate(), 10, 10, 10, 10); 
    document.left(100f);
    document.top(150f);
    PdfWriter writer = PdfWriter.getInstance(document, os);
    document.open();  

    PdfPTable table = new PdfPTable(MAX_COLSPAN);
    table.setWidthPercentage(100f); 
    PdfPTable signTable = new PdfPTable( 1 );
    signTable.setWidthPercentage(100f);

    this.createHead(table, vision, context);
    this.createBody(table, vision);
    this.createFoot(table, context);
    this.putSignature(signTable, context);

    document.add(table);
    document.add(signTable);
    document.close();
    writer.close();         

    os.flush();
    os.close();
    os = null;

    File file = new File(fileFullPath);
    String oid = UploadSupportUtils.create(
            Constants.getSystem(), UploadTypes.IS_TEMP, false, file, "personal-report.pdf");
    file = null;
    return oid;
}
项目:bamboobsc    文件:KpiReportPdfCommand.java   
private String createPdf(Context context) throws Exception {
    BscReportPropertyUtils.loadData();
    BscReportSupportUtils.loadExpression(); // 2015-04-18 add
    String visionOid = (String)context.get("visionOid");
    VisionVO vision = null;
    BscStructTreeObj treeObj = (BscStructTreeObj)this.getResult(context);
    for (VisionVO visionObj : treeObj.getVisions()) {
        if (visionObj.getOid().equals(visionOid)) {
            vision = visionObj;
        }
    }       
    FontFactory.register(BscConstants.PDF_ITEXT_FONT);
    String fileName = SimpleUtils.getUUIDStr() + ".pdf";
    String fileFullPath = Constants.getWorkTmpDir() + "/" + fileName;
    OutputStream os = new FileOutputStream(fileFullPath);
    //Document document = new Document(PageSize.A4.rotate(), 10, 10, 10, 10);
    Document document = new Document(PageSize.A4, 10, 10, 10, 10);      
    document.left(100f);
    document.top(150f);
    PdfWriter writer = PdfWriter.getInstance(document, os);
    document.open();  

    int dateRangeRows = 4 + vision.getPerspectives().get(0).getObjectives().get(0).getKpis().get(0).getDateRangeScores().size();
    PdfPTable table = new PdfPTable(MAX_COLSPAN);
    PdfPTable dateRangeTable = new PdfPTable( dateRangeRows );
    PdfPTable chartsTable = new PdfPTable( 2 );
    PdfPTable signTable = new PdfPTable( 1 );
    table.setWidthPercentage(100f); 
    dateRangeTable.setWidthPercentage(100f);
    chartsTable.setWidthPercentage(100f);
    signTable.setWidthPercentage(100f);

    this.createHead(table, vision);
    this.createBody(table, vision);
    this.createDateRange(dateRangeTable, vision, context, dateRangeRows);       
    this.putCharts(chartsTable, context);
    this.putSignature(signTable, context);

    document.add(chartsTable);
    document.add(table);  
    document.add(dateRangeTable);  
    document.add(signTable);
    document.close();
    writer.close();         

    os.flush();
    os.close();
    os = null;

    File file = new File(fileFullPath);
    String oid = UploadSupportUtils.create(
            Constants.getSystem(), UploadTypes.IS_TEMP, false, file, "kpi-report.pdf");
    file = null;
    return oid;
}
项目:bamboobsc    文件:OrganizationReportPdfCommand.java   
private String createPdf(Context context) throws Exception {
    BscReportPropertyUtils.loadData();
    String visionOid = (String)context.get("visionOid");
    VisionVO vision = null;
    BscStructTreeObj treeObj = (BscStructTreeObj)this.getResult(context);
    for (VisionVO visionObj : treeObj.getVisions()) {
        if (visionObj.getOid().equals(visionOid)) {
            vision = visionObj;
        }
    }       
    FontFactory.register(BscConstants.PDF_ITEXT_FONT);
    String fileName = SimpleUtils.getUUIDStr() + ".pdf";
    String fileFullPath = Constants.getWorkTmpDir() + "/" + fileName;
    OutputStream os = new FileOutputStream(fileFullPath);
    Document document = new Document(PageSize.A4.rotate(), 10, 10, 10, 10); 
    document.left(100f);
    document.top(150f);
    PdfWriter writer = PdfWriter.getInstance(document, os);
    document.open();  

    PdfPTable table = new PdfPTable(MAX_COLSPAN);
    table.setWidthPercentage(100f); 
    PdfPTable signTable = new PdfPTable( 1 );
    signTable.setWidthPercentage(100f);     

    this.createHead(table, vision, context);
    this.createBody(table, vision);

    this.putSignature(signTable, context);      

    document.add(table); 
    document.add(signTable);
    document.close();
    writer.close();         

    os.flush();
    os.close();
    os = null;

    File file = new File(fileFullPath);
    String oid = UploadSupportUtils.create(
            Constants.getSystem(), UploadTypes.IS_TEMP, false, file, "department-report.pdf");
    file = null;
    return oid;     
}
项目:gutenberg    文件:Styles.java   
public Font defaultFont() {
    return FontFactory.getFont(defaultFontName(), defaultFontSize(), Font.NORMAL);
}
项目:displaytag    文件:ItextTableWriter.java   
/**
 * Obtain the font used to render text in the table; Meant to be overriden if a different font is desired.
 * @return The font used to render text in the table.
 */
protected Font getTableFont()
{
    return FontFactory.getFont(FontFactory.HELVETICA, 10, Font.NORMAL, new BaseColor(0x00, 0x00, 0x00));
}
项目:displaytag    文件:ItextTableWriter.java   
/**
 * Obtain the caption font; Meant to be overriden if a different style is desired.
 * @return The caption font.
 */
protected Font getCaptionFont()
{
    return FontFactory.getFont(FontFactory.HELVETICA, 17, Font.BOLD, new BaseColor(0x00, 0x00, 0x00));
}
项目:displaytag    文件:ItextTableWriter.java   
/**
 * Obtain the footer font; Meant to be overriden if a different style is desired.
 * @return The footer font.
 */
protected Font getFooterFont()
{
    return FontFactory.getFont(FontFactory.HELVETICA, 10);
}
项目:displaytag    文件:ItextTableWriter.java   
/**
 * Makes chunk content bold.
 * @param chunk The chunk whose content is to be rendered bold.
 * @param color The font color desired.
 */
private void setBoldStyle(Chunk chunk, BaseColor color)
{
    Font font = chunk.getFont();
    chunk.setFont(FontFactory.getFont(font.getFamilyname(), font.getSize(), Font.BOLD, color));
}
项目:BIS-BDT-Citizen    文件:PdfView.java   
@SuppressWarnings("unchecked")
@Override
   protected void buildPdfDocument(Map<String, Object> model, Document doc,
           PdfWriter writer, HttpServletRequest request, HttpServletResponse response)
           throws Exception {
       // get data model which is passed by the Spring container
       List<Answer> listAnswers = (List<Answer>) model.get("listAnswers");

       doc.add(new Paragraph("Here's your Answers"));

       PdfPTable table = new PdfPTable(4);
       table.setWidthPercentage(100.0f);
       table.setWidths(new float[] {3.0f, 2.0f, 2.0f, 2.0f});
       table.setSpacingBefore(10);

       // define font for table header row
       Font font = FontFactory.getFont(FontFactory.HELVETICA);
       font.setColor(BaseColor.WHITE);

       // define table header cell
       PdfPCell cell = new PdfPCell();
       cell.setBackgroundColor(BaseColor.BLUE);
       cell.setPadding(5);

       // write table header
       cell.setPhrase(new Phrase("Answer 1", font));
       table.addCell(cell);

       cell.setPhrase(new Phrase("Answer 2", font));
       table.addCell(cell);

       cell.setPhrase(new Phrase("Answer 3", font));
       table.addCell(cell);

       cell.setPhrase(new Phrase("Published Date", font));
       table.addCell(cell);

       // write table row data
       for (Answer answer : listAnswers) {
           table.addCell(answer.getAnswer1());
           table.addCell(answer.getAnswer2());
           table.addCell(answer.getAnswer3());
           table.addCell(answer.getAnsweredDate());
           //table.addCell(String.valueOf(answer.getPrice()));
       }

       doc.add(table);

   }
项目:digilib    文件:PDFTitlePage.java   
/**
 * generate iText-PDF-Contents for the title page
 * 
 * @return
 * @throws ImageOpException 
 * @throws IOException 
 */
public Element getPageContents() throws IOException, ImageOpException{
    Paragraph content = new Paragraph();
    content.setAlignment(Element.ALIGN_CENTER);

    // add vertical whitespace
    for(int i=0; i<8; i++){
        content.add(Chunk.NEWLINE);
    }

    // add logo
    content.add(getLogo());
    content.add(Chunk.NEWLINE);
    content.add(Chunk.NEWLINE);

    // add title
    Anchor title = new Anchor(new Paragraph(getTitle(),FontFactory.getFont(FontFactory.HELVETICA,16)));
    String burl = job_info.getImageJobInformation().getAsString("base.url");

    title.setReference(burl+"digilib.html?fn="+job_info.getImageJobInformation().getAsString("fn"));
    content.add(title);     
    content.add(Chunk.NEWLINE);

    // add author
    if(getDate()!=" ")
        content.add(new Paragraph(getAuthor()+" ("+getDate()+")",FontFactory.getFont(FontFactory.HELVETICA,14)));
    else
        content.add(new Paragraph(getAuthor(),FontFactory.getFont(FontFactory.HELVETICA,14)));

    content.add(Chunk.NEWLINE);

    // add page numbers
    content.add(new Paragraph(getPages(), FontFactory.getFont(FontFactory.HELVETICA, 12)));


    content.add(Chunk.NEWLINE);
    content.add(Chunk.NEWLINE);
    content.add(Chunk.NEWLINE);

    // add digilib version
    content.add(new Paragraph(getDigilibVersion(),FontFactory.getFont(FontFactory.HELVETICA,10)));

    for(int i=0; i<8; i++){
        content.add(Chunk.NEWLINE);
    }
    Anchor address = new Anchor(
            new Paragraph(burl+"digilib.jsp?fn="+job_info.getImageJobInformation().getAsString("fn"), FontFactory.getFont(FontFactory.COURIER, 9))
                                );
    address.setReference(burl+"digilib.jsp?fn="+job_info.getImageJobInformation().getAsString("fn"));

    content.add(address);


    return content;
}
项目:cvbuilder_lib    文件:PDFConfigRegister.java   
public static void init(){
    FontFactory.register(FONT_PATH.concat("/Florsn01.ttf"), "FLORSN");
    FontFactory.register(FONT_PATH.concat("/Florsn33.ttf"), "FLORSN_BOLD");
    FontFactory.register(FONT_PATH.concat("/Florsn03.ttf"), "FLORSN_ITALIC");
}
项目:FOXopen    文件:FontManager.java   
/**
 * Register all fonts within a directory
 * @param pRelativePath The relative path to the font directory
 * @return The number of fonts registered within the directory
 */
private int registerDirectory(String pRelativePath) {
  String lFullPath = FoxGlobals.getInstance().getServletContext().getRealPath(pRelativePath);
  return FontFactory.registerDirectory(lFullPath);
}