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

项目: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;
}
项目:ureport    文件:PageHeaderFooterEvent.java   
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;
}
项目:CoECI-OPM-Service-Credit-Redeposit-Deposit-Application    文件:ReportServiceHelper.java   
/**
 * Adds the report title for balanced report.
 *
 * @param document
 *         the report document.
 * @param reportName
 *         the report name.
 * @param fiscalYear
 *         the fiscal year.
 * @param quarter
 *         the quarter.
 * @param startDate
 *         the start date.
 * @param endDate
 *         the end date.
 * @throws com.itextpdf.text.DocumentException
 *         if any error occurs.
 */
static void addBalancedReportTitle(com.itextpdf.text.Document document, String reportName, Integer fiscalYear,
                                   Integer quarter, Date startDate, Date endDate)
        throws com.itextpdf.text.DocumentException {
    com.itextpdf.text.Paragraph title = new com.itextpdf.text.Paragraph(reportName,
            new Font(FontFamily.HELVETICA, 16, Font.BOLD));
    title.setAlignment(PDF_ALIGN_CENTER);
    document.add(title);
    if (fiscalYear != null && quarter != null) {
        com.itextpdf.text.Paragraph subTitle1 = new com.itextpdf.text.Paragraph("Fiscal Year " + fiscalYear +
                " - Quarter" + quarter, new Font(FontFamily.HELVETICA, 14, Font.BOLD));
        subTitle1.setAlignment(PDF_ALIGN_CENTER);
        document.add(subTitle1);
    }
    if (startDate != null && endDate != null) {
        com.itextpdf.text.Paragraph subTitle2 = new com.itextpdf.text.Paragraph("Processed between " +
                "" + REPORT_DATE_FORMAT.format(startDate) + " and " +
                "" + REPORT_DATE_FORMAT.format(endDate),
                new Font(FontFamily.HELVETICA, 12, Font.BOLD));
        subTitle2.setAlignment(PDF_ALIGN_CENTER);
        document.add(subTitle2);
    }
}
项目:JavaGraph    文件:ExploreConfigDialog.java   
@Override
public void refresh() {
    ExploreConfig config = extractConfig();
    String commandLine = config.toCommandLine();
    if (commandLine.isEmpty()) {
        setForeground(Color.GRAY);
        setFont(getFont().deriveFont(Font.ITALIC));
        setText("No parameters");
        setEnabled(false);
    } else {
        setForeground(Color.BLACK);
        setFont(getFont().deriveFont(Font.NORMAL));
        setText(commandLine);
        setEnabled(true);
    }
}
项目:NICON    文件:ExporOnlyViagemPdf.java   
private Phrase funcaoTitulo(int i) {
        String txt;
        Font fontcabecatable = new Font(Font.FontFamily.COURIER, 8, Font.BOLD);
       switch (i) 
       {
           case 0:txt="S/N";break;
           case 1:txt="DATA";break;
           case 2:txt="APOLICE";break;
           case 3:txt="DATA INICIO";break;
           case 4:txt="DATA FIM";break;
           case 5:txt="NO. DIAS";break;
           case 6:txt="NOME";break;
           case 7:txt="RECEIPT NO.";break;
           case 8:txt="EA PREM";break;
           case 9:txt="NICON COMISSÃO";break;
           case 10:txt="5% IMPOSTO";break;
           case 11:txt="0.60% SELO";break;
//           case 12:txt="NET OUT OF TAX";break;
           default:txt="TOTAL"/*"NET OUT OF TAX"*/;break;
       }

        Phrase rt = new Phrase(txt,fontcabecatable);
        return rt; 
    }
项目: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; 
}
项目:hotel    文件:ResidenceService.java   
private void addOfferInstances(List<OfferInstance> offerInstances, Document document, BaseFont bf)
        throws DocumentException {

    if(offerInstances.isEmpty()) {
        return;
    }

    document.add(new Paragraph("Wybrane oferty: ", new Font(bf, 12)));

    PdfPTable offerInstancesTable = new PdfPTable(3);
    offerInstancesTable.setWidthPercentage(100);
    offerInstancesTable.setSpacingBefore(18f);
    offerInstancesTable.setSpacingAfter(18f);
    createofferInstancesTableHeaders(offerInstancesTable);
    createofferInstancesTableContent(offerInstances, offerInstancesTable);
    document.add(offerInstancesTable);
}
项目:NICON    文件:ExporOnlyViagemPdf.java   
private Phrase funcaoTitulo(int i) {
        String txt;
        Font fontcabecatable = new Font(Font.FontFamily.COURIER, 8, Font.BOLD);
       switch (i) 
       {
           case 0:txt="S/N";break;
           case 1:txt="DATA";break;
           case 2:txt="APOLICE";break;
           case 3:txt="DATA INICIO";break;
           case 4:txt="DATA FIM";break;
           case 5:txt="NO. DIAS";break;
           case 6:txt="NOME";break;
           case 7:txt="RECEIPT NO.";break;
           case 8:txt="EA PREM";break;
           case 9:txt="NICON COMISSÃO";break;
           case 10:txt="5% IMPOSTO";break;
           case 11:txt="0.60% SELO";break;
//           case 12:txt="NET OUT OF TAX";break;
           default:txt="TOTAL"/*"NET OUT OF TAX"*/;break;
       }

        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; 
}
项目:ArasuiteIta    文件:HeaderFooter.java   
/**
      * Increase the page number.
      * @see com.itextpdf.text.pdf.PdfPageEventHelper#onStartPage(
      *      com.itextpdf.text.pdf.PdfWriter, com.itextpdf.text.Document)
      */
     @Override
public void onStartPage(PdfWriter writer, Document document) {
         pagenumber++;
         System.out.println("ON Start Page PDF");
Rectangle rect = writer.getBoxSize("art");

         /* header     
         ColumnText.showTextAligned(writer.getDirectContent(),                      
                    com.itextpdf.text.Element.ALIGN_RIGHT, header[0],
                     rect.getRight(), rect.getTop(), 0);
          */  
          Font font = new Font();
          font.setSize(8);
         if (G.licensePDF) {
          ColumnText.showTextAligned(writer.getDirectContent(),
                com.itextpdf.text.Element.ALIGN_CENTER, new Phrase(String.format(TLanguage.getString("EXPORT_PDF_LICENCIA")),font),
                  (rect.getLeft() + rect.getRight()) / 2, rect.getBottom() - 18, 0);
          ColumnText.showTextAligned(writer.getDirectContent(),
                    com.itextpdf.text.Element.ALIGN_CENTER, new Phrase(String.format(TLanguage.getString("EXPORT_PDF_LICENCIA2")),font),
                      (rect.getLeft() + rect.getRight()) / 2, rect.getBottom() - 9, 0);
         }


     }
项目:ExcelToBarcode    文件:MainController.java   
private Font findFont(org.apache.poi.ss.usermodel.Cell cell) {
    if(cell == null) return new Font(Font.FontFamily.HELVETICA, 10);
    if(xSSFWorkbook == null)
        throw new NullPointerException("workbook was null!");
    final org.apache.poi.ss.usermodel.Font f = xSSFWorkbook.getFontAt(cell.getCellStyle().getFontIndex());


    final Font.FontFamily family;
    final String fontName = f.getFontName().toLowerCase();
    if(fontName.contains("times")) family = Font.FontFamily.TIMES_ROMAN;
    else if(fontName.contains("courier")) family = Font.FontFamily.COURIER;
    else if(fontName.contains("symbol")) family = Font.FontFamily.SYMBOL;
    else family = Font.FontFamily.HELVETICA;

    //final Font result = new Font(family, size);
    // the font height value is 20 * the font size in points
    final Font result = new Font(family, (float) f.getFontHeight() / 20);

    if(f.getBold()) result.setStyle(Font.BOLD);
    if(f.getItalic()) result.setStyle(Font.ITALIC);
    return result;
}
项目:OpenSongTablet    文件:ExportPreparer.java   
private static void makePDF(Bitmap bmp, File file) {
    Document document = new Document();
    try {
        PdfWriter.getInstance(document, new FileOutputStream(file));
        document.addAuthor(FullscreenActivity.mAuthor.toString());
        document.addTitle(FullscreenActivity.mTitle.toString());
        document.addCreator("OpenSongApp");
        if (bmp!=null && bmp.getWidth()>bmp.getHeight()) {
            document.setPageSize(PageSize.A4.rotate());
        } else {
            document.setPageSize(PageSize.A4);
        }
        document.addTitle(FullscreenActivity.mTitle.toString());
        document.open();//document.add(new Header("Song title",FullscreenActivity.mTitle.toString()));
        BaseFont urName = BaseFont.createFont("assets/fonts/Lato-Reg.ttf", "UTF-8",BaseFont.EMBEDDED);
        Font TitleFontName  = new Font(urName, 14);
        Font AuthorFontName = new Font(urName, 10);
        document.add(new Paragraph(FullscreenActivity.mTitle.toString(),TitleFontName));
        document.add(new Paragraph(FullscreenActivity.mAuthor.toString(),AuthorFontName));
        addImage(document,bmp);
        document.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:testarea-itext5    文件:StampUnicodeText.java   
/**
 * <a href="http://stackoverflow.com/questions/35082653/adobe-reader-cant-display-unicode-font-of-pdf-added-with-itext">
 * Adobe Reader can't display unicode font of pdf added with iText
 * </a>
 * <br/>
 * <a href="https://www.dropbox.com/s/erkv9wot9d460dg/sampleOriginal.pdf?dl=0">
 * sampleOriginal.pdf
 * </a>
 * <p>
 * Indeed, just like in the iTextSharp version of the code, the resulting file has
 * issues in Adobe Reader. With a different starting file, though, it doesn't, cf.
 * {@link #testAddUnicodeStampEg_01()}.
 * </p>
 * <p>
 * As it eventually turns out, Adobe Reader treats PDF files with composite fonts
 * differently if they claim to be PDF-1.2 like the OP's sample file.
 * </p>
 */
@Test
public void testAddUnicodeStampSampleOriginal() throws DocumentException, IOException
{
    try (   InputStream resource = getClass().getResourceAsStream("sampleOriginal.pdf");
            OutputStream result = new FileOutputStream(new File(RESULT_FOLDER, "sampleOriginal-unicodeStamp.pdf"))  )
    {
        PdfReader reader = new PdfReader(resource);
        PdfStamper stamper = new PdfStamper(reader, result);
        BaseFont bf = BaseFont.createFont("c:/windows/fonts/arialuni.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
        PdfContentByte cb = stamper.getOverContent(1);

        Phrase p = new Phrase();
        p.setFont(new Font(bf, 25, Font.NORMAL, BaseColor.BLUE));
        p.add("Sample Text");

        ColumnText.showTextAligned(cb, PdfContentByte.ALIGN_LEFT, p, 200, 200, 0);

        stamper.close();
    }
}
项目:testarea-itext5    文件:StampUnicodeText.java   
/**
 * <a href="http://stackoverflow.com/questions/35082653/adobe-reader-cant-display-unicode-font-of-pdf-added-with-itext">
 * Adobe Reader can't display unicode font of pdf added with iText
 * </a>
 * <br/>
 * <a href="https://www.dropbox.com/s/erkv9wot9d460dg/sampleOriginal.pdf?dl=0">
 * sampleOriginal.pdf
 * </a>
 * <p>
 * Indeed, just like in the iTextSharp version of the code, the resulting file has
 * issues in Adobe Reader, cf. {@link #testAddUnicodeStampSampleOriginal()}. With
 * a different starting file, though, it doesn't as this test shows.
 * </p>
 * <p>
 * As it eventually turns out, Adobe Reader treats PDF files with composite fonts
 * differently if they claim to be PDF-1.2 like the OP's sample file.
 * </p>
 */
@Test
public void testAddUnicodeStampEg_01() throws DocumentException, IOException
{
    try (   InputStream resource = getClass().getResourceAsStream("eg_01.pdf");
            OutputStream result = new FileOutputStream(new File(RESULT_FOLDER, "eg_01-unicodeStamp.pdf"))  )
    {
        PdfReader reader = new PdfReader(resource);
        PdfStamper stamper = new PdfStamper(reader, result);

        BaseFont bf = BaseFont.createFont("c:/windows/fonts/arialuni.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
        PdfContentByte cb = stamper.getOverContent(1);

        Phrase p = new Phrase();
        p.setFont(new Font(bf, 25, Font.NORMAL, BaseColor.BLUE));
        p.add("Sample Text");

        ColumnText.showTextAligned(cb, PdfContentByte.ALIGN_LEFT, p, 200, 200, 0);

        stamper.close();
    }
}
项目:testarea-itext5    文件:StampUnicodeText.java   
/**
 * <a href="http://stackoverflow.com/questions/35082653/adobe-reader-cant-display-unicode-font-of-pdf-added-with-itext">
 * Adobe Reader can't display unicode font of pdf added with iText
 * </a>
 * <p>
 * Indeed, just like in the iTextSharp version of the code, the resulting file has
 * issues in Adobe Reader, cf. {@link #testAddUnicodeStampSampleOriginal()}. With
 * a different starting file, though, it doesn't, cf.
 * {@link #testAddUnicodeStampEg_01()}. This test creates a new PDF with the same
 * font and chunk as stamped by the OP. Adobe Reader has no problem with it either.
 * </p>
 * <p>
 * As it eventually turns out, Adobe Reader treats PDF files with composite fonts
 * differently if they claim to be PDF-1.2 like the OP's sample file.
 * </p>
 */
@Test
public void testCreateUnicodePdf() throws DocumentException, IOException
{
    Document document = new Document();
    try (   OutputStream result  = new FileOutputStream(new File(RESULT_FOLDER, "unicodePdf.pdf")) )
    {
        PdfWriter.getInstance(document, result);
        BaseFont bf = BaseFont.createFont("c:/windows/fonts/arialuni.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);

        document.open();

        Phrase p = new Phrase();
        p.setFont(new Font(bf, 25, Font.NORMAL, BaseColor.BLUE));
        p.add("Sample Text");

        document.add(p);

        document.close();
    }
}
项目:testarea-itext5    文件:UseColumnText.java   
/**
 * <a href="http://stackoverflow.com/questions/32162759/columntext-showtextaligned-vs-columntext-setsimplecolumn-top-alignment">
 * ColumnText.ShowTextAligned vs ColumnText.SetSimpleColumn Top Alignment
 * </a>
 * <p>
 * Indeed, the coordinates do not line up. The y coordinate of 
 * {@link ColumnText#showTextAligned(PdfContentByte, int, Phrase, float, float, float)}
 * denotes the baseline while {@link ColumnText#setSimpleColumn(Rectangle)} surrounds
 * the text to come.
 * </p>
 */
@Test
public void testShowTextAlignedVsSimpleColumnTopAlignment() throws DocumentException, IOException
{
    Document document = new Document(PageSize.A4);

    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(new File(RESULT_FOLDER, "ColumnTextTopAligned.pdf")));
    document.open();

    Font fontQouteItems = new Font(BaseFont.createFont(), 12);
    PdfContentByte canvas = writer.getDirectContent();

    // Item Number
    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("36222-0", fontQouteItems), 60, 450, 0);

    // Estimated Qty
    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("47", fontQouteItems), 143, 450, 0);

    // Item Description
    ColumnText ct = new ColumnText(canvas); // Uses a simple column box to provide proper text wrapping
    ct.setSimpleColumn(new Rectangle(193, 070, 390, 450));
    ct.setText(new Phrase("In-Situ : Poly Cable - 100'\nPoly vented rugged black gable 100ft\nThis is an additional description. It can wrap an extra line if it needs to so this text is long.", fontQouteItems));
    ct.go();

    document.close();
}
项目:testarea-itext5    文件:DoubleSpace.java   
/**
 * <a href="http://stackoverflow.com/questions/35699167/double-space-not-being-preserved-in-pdf">
 * Double space not being preserved in PDF
 * </a>
 * <p>
 * Indeed, the double space collapses into a single one when copying&pasting from the
 * generated PDF displayed in Adobe Reader. On the other hand the gap for the double
 * space is twice as wide as for the single space. So this essentially is a quirk of
 * copy&paste of Adobe Reader (and some other PDF viewers, too).
 * </p>
 */
@Test
public void testDoubleSpace() throws DocumentException, IOException
{
    try (   OutputStream pdfStream = new FileOutputStream(new File(RESULT_FOLDER, "DoubleSpace.pdf")))
    {
        PdfPTable table = new PdfPTable(1);
        table.getDefaultCell().setBorderWidth(0.5f);
        table.getDefaultCell().setBorderColor(BaseColor.LIGHT_GRAY);

        table.addCell(new Phrase("SINGLE SPACED", new Font(BaseFont.createFont(), 36)));
        table.addCell(new Phrase("DOUBLE  SPACED", new Font(BaseFont.createFont(), 36)));
        table.addCell(new Phrase("TRIPLE   SPACED", new Font(BaseFont.createFont(), 36)));

        Document pdfDocument = new Document(PageSize.A4.rotate(), 0, 0, 0, 0);
        PdfWriter.getInstance(pdfDocument, pdfStream);
        pdfDocument.open();
        pdfDocument.add(table);
        pdfDocument.close();
    }
}
项目:testarea-itext5    文件:UseRowspan.java   
/**
 * <a href="http://stackoverflow.com/questions/44005834/changing-rowspans">
 * Changing rowspans
 * </a>
 * <p>
 * Helper method of the OP.
 * </p>
 * @see #testUseRowspanLikeUser7968180()
 * @see #testUseRowspanLikeUser7968180Fixed()
 * @see #createPdf(String)
 * @see #createPdfFixed(String)
 */
private static void addCellToTableCzech(PdfPTable table, int horizontalAlignment,
        int verticalAlignment, String value, int colspan, int rowspan,
        String fontType, float fontSize) {
    BaseFont base = null;
    try {
        base = BaseFont.createFont(fontType, BaseFont.CP1250, BaseFont.EMBEDDED);
    } catch (Exception e) {
        e.printStackTrace();
    }
    Font font = new Font(base, fontSize);
    PdfPCell cell = new PdfPCell(new Phrase(value, font));
    cell.setColspan(colspan);
    cell.setRowspan(rowspan);
    cell.setHorizontalAlignment(horizontalAlignment);
    cell.setVerticalAlignment(verticalAlignment);
    cell.setBorder(PdfPCell.NO_BORDER);
    table.addCell(cell);
}
项目:testarea-itext5    文件:ImportPageWithoutFreeSpace.java   
/**
 * This method creates a PDF with a single styled paragraph.
 */
static byte[] createSimpleTextPdf() throws DocumentException
{
    ByteArrayOutputStream baos = new ByteArrayOutputStream();

    Document document = new Document();
    PdfWriter.getInstance(document, baos);
    document.open();

    Paragraph paragraph = new Paragraph();
    paragraph.add(new Phrase("Beware: ", new Font(FontFamily.HELVETICA, 12, Font.BOLDITALIC)));
    paragraph.add(new Phrase("The implementation of ", new Font(FontFamily.HELVETICA, 12, Font.ITALIC)));
    paragraph.add(new Phrase("MarginFinder", new Font(FontFamily.COURIER, 12, Font.ITALIC)));
    paragraph.add(new Phrase(" is far from optimal. It is not even correct as it includes all curve control points which is too much. Furthermore it ignores stuff like line width or wedge types. It actually merely is a proof-of-concept.", new Font(FontFamily.HELVETICA, 12, Font.ITALIC)));
    document.add(paragraph);

    document.close();

    return baos.toByteArray();
}
项目:testarea-itext5    文件:DynamicFooter.java   
public PdfPTable generateFooter() {
    try {
        BaseFont baseFont = BaseFont.createFont(/*"resources/ARIAL.TTF"*/ "c:/Windows/Fonts/arial.ttf", BaseFont.IDENTITY_H, true);
        footerTable = new PdfPTable(1);
        footerTable.setTotalWidth(440);
        footerTable.setLockedWidth(true);

        Font pageNumberFont = new Font(baseFont, 9, Font.BOLD);
        Paragraph pageNumberP = new Paragraph(titleIndex+"-"+ pageNumber, pageNumberFont);
        PdfPCell pageNumberCell = new PdfPCell(pageNumberP);
        pageNumberCell.setBorder(0);
        pageNumberCell.setPaddingTop(20);
        footerTable.addCell(pageNumberCell);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return footerTable;
}
项目:MountainQuest-PL    文件:TableOfContentsPageGenerator.java   
private void generateSectionTitle(PdfPTable table, Data data) throws IOException, DocumentException {
    if (!this.currentSection.equals(data.mountains)) {
        currentSection = data.mountains;
        currentBackgroundColor = backgroundColorGenerator.generate(data);

        PdfPCell cellSeparator = new PdfPCell(PhraseUtil.phrase(" "));
        cellSeparator.setBorder(0);
        cellSeparator.setPadding(10);
        cellSeparator.setColspan(4);
        table.addCell(cellSeparator);

        PdfPCell cell = new PdfPCell(PhraseUtil.phrase(currentSection, 14, Font.BOLD));
        cell.setBorder(0);
        cell.setPadding(10);
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell.setColspan(4);
        cell.setBackgroundColor(currentBackgroundColor);
        table.addCell(cell);
    }
}
项目:weplantaforest    文件:PdfHelper.java   
public static void createCircleAndText(PdfContentByte cb, String text, float xCoord, float yCoord, float radius, Font textFont, int circleColorRed, int circleColorGreen, int circleColorBlue)
        throws DocumentException, IOException {
    cb.saveState();
    cb.setRGBColorFill(circleColorRed, circleColorGreen, circleColorBlue);
    cb.circle(xCoord, yCoord, radius);
    cb.fill();
    cb.stroke();
    cb.restoreState();

    PdfPTable table = new PdfPTable(1);
    float[] rows = { 595f };
    table.setTotalWidth(rows);
    table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    table.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.getDefaultCell().setFixedHeight(radius * 2);
    table.addCell(new Phrase(new Chunk(text, textFont)));
    table.writeSelectedRows(0, 1, 0, yCoord + radius, cb);
}
项目:OLE-INST    文件:OlePrintSlip.java   
public void populateFontMap() {

        fontMap.put("COURIER", new Font(FontFactory.getFont("Times-Roman", Font.BOLD).getBaseFont()));
        fontMap.put("COURIER", new Font(FontFactory.getFont("Times-Roman", Font.BOLDITALIC).getBaseFont()));
        fontMap.put("COURIER", new Font(FontFactory.getFont("Times-Roman", Font.DEFAULTSIZE).getBaseFont()));
        fontMap.put("COURIER", new Font(FontFactory.getFont("Times-Roman", Font.STRIKETHRU).getBaseFont()));
        fontMap.put("COURIER", new Font(FontFactory.getFont("Times-Roman", Font.NORMAL).getBaseFont()));
        fontMap.put("COURIER", new Font(FontFactory.getFont("Times-Roman", Font.UNDEFINED).getBaseFont()));
        fontMap.put("COURIER", new Font(FontFactory.getFont("Times-Roman", Font.UNDERLINE).getBaseFont()));

       /* fontMap.put("COURIER", new Font(Font.COURIER));
        fontMap.put("BOLD", new Font(Font.BOLD));
        fontMap.put("BOLDITALIC", new Font(Font.BOLDITALIC));
        fontMap.put("DEFAULTSIZE", new Font(Font.DEFAULTSIZE));
        fontMap.put("HELVETICA", new Font(Font.HELVETICA));
        fontMap.put("ITALIC", new Font(Font.ITALIC));
        fontMap.put("NORMAL", new Font(Font.NORMAL));
        fontMap.put("STRIKETHRU", new Font(Font.STRIKETHRU));
        fontMap.put("SYMBOL", new Font(Font.SYMBOL));
        fontMap.put("TIMES_ROMAN", new Font(Font.TIMES_ROMAN));
        fontMap.put("UNDEFINED", new Font(Font.UNDEFINED));
        fontMap.put("UNDERLINE", new Font(Font.UNDERLINE));
        fontMap.put("ZAPFDINGBATS", new Font(Font.ZAPFDINGBATS));*/

    }
项目:rolp    文件:PdfFormatHelper.java   
public static PdfPTable buildHeaderNameLine(String schuelername, Font headerFont) throws DocumentException {
    PdfPCell labelCell = new PdfPCell(new Phrase("Name", headerFont));
    labelCell.setBorder(Rectangle.BOTTOM);
    labelCell.setBorderWidth(1f);

    PdfPCell nameCell = new PdfPCell(new Phrase(schuelername, headerFont));
    nameCell.setBorder(Rectangle.BOTTOM);
    nameCell.setBorderWidth(1f);
    nameCell.setColspan(5);

    PdfPTable table = prebuildHeaderTable();
    table.addCell(labelCell);
    table.addCell(nameCell);

    return table;
}
项目:rolp    文件:PdfFormatHelper.java   
public static PdfPTable buildFooterVersetzungsvermerkLine(String versetzungsvermerk, Font footerFont) throws DocumentException {
    PdfPCell labelCell = new PdfPCell(new Phrase("Versetzungsvermerk", footerFont));
    labelCell.setBorder(Rectangle.BOTTOM);
    labelCell.setBorderWidth(1f);

    PdfPCell nameCell = new PdfPCell(new Phrase(versetzungsvermerk, footerFont));
    nameCell.setBorder(Rectangle.BOTTOM);
    nameCell.setBorderWidth(1f);

    PdfPTable table = new PdfPTable(2);
    table.setHorizontalAlignment(Element.ALIGN_LEFT);
    table.setWidthPercentage(100f);
    table.addCell(labelCell);
    table.addCell(nameCell);
    table.setWidths(new float[] {0.3f, 0.7f});
    return table;
}
项目:rolp    文件:PdfFormatHelper.java   
public static PdfPTable buildFooterDatumLine(String datumString, Font footerFont) throws DocumentException {
    PdfPCell labelCell = new PdfPCell(new Phrase("Datum", footerFont));
    labelCell.setBorder(Rectangle.BOTTOM);
    labelCell.setBorderWidth(1f);

    PdfPCell nameCell = new PdfPCell(new Phrase(datumString, footerFont));
    nameCell.setBorder(Rectangle.BOTTOM);
    nameCell.setBorderWidth(1f);

    PdfPTable table = new PdfPTable(2);
    table.setHorizontalAlignment(Element.ALIGN_LEFT);
    table.setWidthPercentage(100f);
    table.addCell(labelCell);
    table.addCell(nameCell);
    table.setWidths(new float[] {0.3f, 0.7f});
    return table;
}
项目:rolp    文件:PdfFormatHelper.java   
public static PdfPTable buildFooterDienstsiegelLine(Font footerFont) throws DocumentException {
    PdfPCell leftCell = new PdfPCell(new Phrase("", footerFont));
    leftCell.setBorder(Rectangle.NO_BORDER);
    leftCell.setBorderWidth(1f);

    PdfPCell centerCell = new PdfPCell(new Phrase("Dienstsiegel der Schule", footerFont));
    centerCell.setBorder(Rectangle.NO_BORDER);
    centerCell.setBorderWidth(1f);
    centerCell.setHorizontalAlignment(Element.ALIGN_CENTER);

    PdfPCell rightCell = new PdfPCell(new Phrase("", footerFont));
    rightCell.setBorder(Rectangle.NO_BORDER);
    rightCell.setBorderWidth(1f);

    PdfPTable table = new PdfPTable(3);
    table.setHorizontalAlignment(Element.ALIGN_MIDDLE);
    table.setWidthPercentage(100f);
    table.addCell(leftCell);
    table.addCell(centerCell);
    table.addCell(rightCell);
    table.setWidths(new float[] {0.3f, 0.3f, 0.3f});
    return table;
}
项目:rolp    文件:PdfFormatHelper.java   
public static PdfPTable buildFooterUnterschriftenLine(Font footerFont) throws DocumentException {
    PdfPCell leftCell = new PdfPCell(new Phrase("Schulleiter(in)", footerFont));
    leftCell.setBorder(Rectangle.TOP);
    leftCell.setBorderWidth(1f);
    leftCell.setHorizontalAlignment(Element.ALIGN_CENTER);

    PdfPCell centerCell = new PdfPCell(new Phrase("", footerFont));
    centerCell.setBorder(Rectangle.TOP);
    centerCell.setBorderWidth(1f);
    centerCell.setHorizontalAlignment(Element.ALIGN_CENTER);

    PdfPCell rightCell = new PdfPCell(new Phrase("Klassenleiter(in)", footerFont));
    rightCell.setBorder(Rectangle.TOP);
    rightCell.setBorderWidth(1f);
    rightCell.setHorizontalAlignment(Element.ALIGN_CENTER);

    PdfPTable table = new PdfPTable(3);
    table.setWidthPercentage(100f);
    table.addCell(leftCell);
    table.addCell(centerCell);
    table.addCell(rightCell);
    table.setWidths(new float[] {0.3f, 0.3f, 0.3f});
    return table;
}
项目:rolp    文件:PdfFormatHelper.java   
public static PdfPTable buildFooterHalbjahrDatumLine(String datumString, Font footerFont) throws DocumentException {
    PdfPCell leftCell = new PdfPCell(new Phrase(datumString, footerFont));
    leftCell.setBorder(Rectangle.NO_BORDER);
    leftCell.setHorizontalAlignment(Element.ALIGN_CENTER);

    PdfPCell centerCell = new PdfPCell(new Phrase("", footerFont));
    centerCell.setBorder(Rectangle.NO_BORDER);
    centerCell.setHorizontalAlignment(Element.ALIGN_CENTER);

    PdfPCell rightCell = new PdfPCell(new Phrase("", footerFont));
    rightCell.setBorder(Rectangle.NO_BORDER);
    rightCell.setHorizontalAlignment(Element.ALIGN_CENTER);

    PdfPTable table = new PdfPTable(3);
    table.setWidthPercentage(100f);
    table.addCell(leftCell);
    table.addCell(centerCell);
    table.addCell(rightCell);
    table.setWidths(new float[] {0.3f, 0.3f, 0.3f});
    return table;
}
项目:rolp    文件:PdfFormatHelper.java   
public static PdfPTable buildFooterHalbjahrDatumKlassenleiterLine(Font footerFont) throws DocumentException {
    PdfPCell leftCell = new PdfPCell(new Phrase("Datum", footerFont));
    leftCell.setBorder(Rectangle.TOP);
    leftCell.setBorderWidth(1f);
    leftCell.setHorizontalAlignment(Element.ALIGN_CENTER);

    PdfPCell centerCell = new PdfPCell(new Phrase("", footerFont));
    centerCell.setBorder(Rectangle.TOP);
    centerCell.setBorderWidth(1f);
    centerCell.setHorizontalAlignment(Element.ALIGN_CENTER);

    PdfPCell rightCell = new PdfPCell(new Phrase("Klassenleiter(in)", footerFont));
    rightCell.setBorder(Rectangle.TOP);
    rightCell.setBorderWidth(1f);
    rightCell.setHorizontalAlignment(Element.ALIGN_CENTER);

    PdfPTable table = new PdfPTable(3);
    table.setWidthPercentage(100f);
    table.addCell(leftCell);
    table.addCell(centerCell);
    table.addCell(rightCell);
    table.setWidths(new float[] {0.3f, 0.3f, 0.3f});
    return table;
}
项目:gutenberg    文件:Styles.java   
public Styles initDefaults() {
    FontDescriptor defaultFont = fontDescriptor(defaultFontName(), defaultFontSize(), Font.NORMAL, BaseColor.BLACK);

    registeredColors.put(DEFAULT_COLOR, BaseColor.BLACK);
    registeredFonts.put(DEFAULT_FONT, defaultFont);

    registeredFonts.put(CODE_FONT, fontDescriptor(verbatimBaseFont(), defaultFontSize(), Font.NORMAL, BaseColor.BLACK));
    registeredFonts.put(INLINE_CODE_FONT, fontDescriptor(verbatimBaseFont(), defaultFontSize(), Font.NORMAL, BaseColor.BLACK));
    registeredColors.put(INLINE_CODE_BACKGROUND, Colors.VERY2_LIGHT_GRAY);

    registeredFonts.put(H1_FONT, fontDescriptor(defaultFontName(), 18.0f, Font.BOLD, BaseColor.BLACK));
    registeredFonts.put(H2_FONT, fontDescriptor(defaultFontName(), 16.0f, Font.BOLD, BaseColor.DARK_GRAY));
    registeredFonts.put(H3_FONT, fontDescriptor(defaultFontName(), 14.0f, Font.BOLD, BaseColor.DARK_GRAY));
    registeredFonts.put(H4_FONT, fontDescriptor(defaultFontName(), 14.0f, Font.ITALIC, BaseColor.DARK_GRAY));

    registeredColors.put(TABLE_ALTERNATE_BACKGROUND, Colors.VERY2_LIGHT_GRAY);
    registeredFonts.put(TABLE_HEADER_FONT, fontDescriptor(defaultFontName(), 14.0f, Font.ITALIC, BaseColor.WHITE));
    registeredColors.put(TABLE_HEADER_BACKGROUD, BaseColor.BLACK);
    registeredFonts.put(TABLE_BODY_FONT, defaultFont);
    registeredColors.put(TABLE_BODY_CELL_BORDER_COLOR, Colors.LIGHT_GRAY);

    registeredColors.put(BLOCKQUOTE_COLOR, Colors.LIGHT_GRAY);

    return this;
}
项目:gutenberg    文件:PygmentsAdapter.java   
private int calculateStyle(Style style) {
    int s = Font.NORMAL;
    if (style.isBold()) {
        s |= Font.BOLD;
    }
    if (style.isItalic()) {
        s |= Font.ITALIC;
    }
    if (style.isStrikethrough()) {
        s |= Font.STRIKETHRU;
    }
    if (style.isUnderline()) {
        s |= Font.UNDERLINE;
    }
    return s;
}
项目:gutenberg    文件:HeaderFooter.java   
public void drawFooter(PdfContentByte canvas, PageInfos pageInfos) {
    if (pageInfos.getRawPageNumber() == 1 && !footerOnFirstPage)
        return;

    if (drawLine) {
        BaseColor lineColor = styles.getColorOrDefault(HEADER_LINE_COLOR);
        canvas.saveState();
        canvas.setColorStroke(lineColor);
        canvas.setLineWidth(1.2f);
        canvas.moveTo(rect.getLeft(), rect.getBottom() - 6);
        canvas.lineTo(rect.getRight(), rect.getBottom() - 6);
        canvas.stroke();
        canvas.restoreState();
    }

    float bottom = rect.getBottom() - 20;
    Phrase footer = footerText(pageInfos);
    if (footer != null) {
        showTextAligned(canvas, Element.ALIGN_LEFT, footer, rect.getLeft(), bottom, 0);
    }

    Font footerFont = styles.getFontOrDefault(FOOTER_FONT);

    Phrase page = new Phrase(pageInfos.getFormattedPageNumber(), footerFont);
    showTextAligned(canvas, Element.ALIGN_RIGHT, page, rect.getRight(), bottom, 0);
}
项目:gutenberg    文件:ExpLinkNodeProcessor.java   
@Override
public void process(int level, Node node, InvocationContext context) {
    ExpLinkNode linkNode = (ExpLinkNode) node;
    String url = context.variableResolver().resolve(linkNode.url);

    Font anchorFont = new FontCopier(context.peekFont())
            .style(Font.UNDERLINE)
            .color(Colors.DARK_RED)
            .get();

    context.pushFont(anchorFont);
    List<Element> subs = context.collectChildren(level, node);
    context.popFont();

    Phrase p = new Phrase();
    p.addAll(subs);

    Anchor anchor = new Anchor(p);
    anchor.setReference(url);
    context.append(anchor);
}
项目:gutenberg    文件:HeaderNodeProcessor.java   
@Override
public void process(int level, Node node, InvocationContext context) {
    HeaderNode hNode = (HeaderNode) node;
    int hLevel = hNode.getLevel();

    Sections sections = context.iTextContext().sections();

    Font font = sections.sectionTitlePrimaryFont(hLevel);
    context.pushFont(font);
    List<Element> subs = context.collectChildren(level, node);
    context.popFont();

    Paragraph p = new Paragraph();
    p.setFont(font);
    p.addAll(subs);

    Element element = sections.newSection(p, hLevel);
    context.append(element);
}
项目:gutenberg    文件:RichTextEmitter.java   
@Override
public void emit(RichText text, ITextContext context) {
    StringBuilder b = new StringBuilder();
    Font font = text.getFont();
    BaseFont baseFont = font.getBaseFont();

    for (char c : text.getText().toCharArray()) {
        if (!baseFont.charExists(c)) {
            emitText(context, b, font);
            reset(b);
            emitSymbol(context, String.valueOf(c));
        } else {
            b.append(c);
        }
    }
    emitText(context, b, font);
}
项目:gutenberg    文件:FontawesomePdfTest.java   
private File generateAwesomeFontPdf() throws DocumentException, IOException {
    File fileOut = openDocument("awesomeFont");

    BaseFont bf = BaseFont.createFont("font/FontAwesome.otf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
    Font font = new Font(bf, 12);
    FontAwesome awesome = FontAwesome.getInstance();

    PdfPTable table = new PdfPTable(2);
    table.setWidthPercentage(288 / 5.23f);
    table.setWidths(new int[]{2, 1});
    for (String key : awesome.keys().toSortedList(stringComparator())) {
        table.addCell(new PdfPCell(new Phrase(key)));
        table.addCell(new PdfPCell(new Phrase(awesome.get(key), font)));
    }
    document.add(table);
    closeDocument();
    return fileOut;
}
项目:gutenberg    文件:InconsolataFontPdfTest.java   
private void emit(String fontName, String encoding) throws DocumentException, IOException {
    String text = "" +
            "(defn year-end-evaluation\n" +
            "  []\n" +
            "  (if (> (rand) 0.5)\n" +
            "    \"You get a raise!\"\n" +
            "    \"Better luck next year!\"))";


    BaseFont bf = BaseFont.createFont(fontName, encoding, BaseFont.EMBEDDED);
    document.add(new Paragraph(String.format("Font file: %s with encoding %s", fontName, encoding)));
    document.add(new Paragraph(String.format("iText class: %s", bf.getClass().getName())));
    Font font = new Font(bf, 12);
    document.add(new Paragraph(text, font));
    document.add(new LineSeparator(0.5f, 100, null, 0, -5));
}
项目: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(""));
    }
}