Example usage for com.itextpdf.text FontFactory HELVETICA_BOLD

List of usage examples for com.itextpdf.text FontFactory HELVETICA_BOLD

Introduction

In this page you can find the example usage for com.itextpdf.text FontFactory HELVETICA_BOLD.

Prototype

String HELVETICA_BOLD

To view the source code for com.itextpdf.text FontFactory HELVETICA_BOLD.

Click Source Link

Document

This is a possible value of a base 14 type 1 font

Usage

From source file:org.dspace.disseminate.CitationDocument.java

/**
 * Takes a DSpace {@link Bitstream} and uses its associated METADATA to
 * create a cover page.// w  w w .j  a  v a 2 s  .c  om
 *
 * @param cDoc The cover page document to add cited information to.
 * @param writer
 * @param cMeta
 *            METADATA retrieved from the parent collection.
 * @throws IOException
 * @throws DocumentException
 */
private void generateCoverPage(Document cDoc, PdfWriter writer, CitationMeta cMeta) throws DocumentException {
    cDoc.open();
    writer.setCompressionLevel(0);

    Item item = cMeta.getItem();

    //Set up some fonts
    Font helv26 = FontFactory.getFont(FontFactory.HELVETICA, 26f, BaseColor.BLACK);
    Font helv16 = FontFactory.getFont(FontFactory.HELVETICA, 16f, BaseColor.BLACK);
    Font helv12 = FontFactory.getFont(FontFactory.HELVETICA, 12f, BaseColor.BLACK);
    Font helv12_italic = FontFactory.getFont(FontFactory.HELVETICA_OBLIQUE, 12f, BaseColor.BLACK);
    Font helv11_bold = FontFactory.getFont(FontFactory.HELVETICA_BOLD, 11f, BaseColor.BLACK);
    Font helv9 = FontFactory.getFont(FontFactory.HELVETICA, 9f, BaseColor.BLACK);

    // 1 - Header:
    //  University Name
    //  Repository Name                                                        repository.url
    Paragraph university = new Paragraph("The Ohio State University", helv11_bold);
    cDoc.add(university);

    PdfPTable repositoryTable = new PdfPTable(2);
    repositoryTable.setWidthPercentage(100);

    Chunk repositoryName = new Chunk("Knowledge Bank", helv11_bold);
    PdfPCell nameCell = new PdfPCell();
    nameCell.setBorderWidth(0);
    nameCell.addElement(repositoryName);

    Chunk repositoryURL = new Chunk("kb.osu.edu", helv11_bold);
    repositoryURL.setAnchor("http://kb.osu.edu");

    PdfPCell urlCell = new PdfPCell();
    urlCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    urlCell.setBorderWidth(0);
    urlCell.addElement(repositoryURL);

    repositoryTable.addCell(nameCell);
    repositoryTable.addCell(urlCell);

    repositoryTable.setSpacingAfter(5);

    cDoc.add(repositoryTable);

    // Line Separator
    LineSeparator lineSeparator = new LineSeparator();
    cDoc.add(lineSeparator);

    // 2 - Bread Crumbs
    // Community Name                                                          Collection Name
    PdfPTable breadcrumbTable = new PdfPTable(2);
    breadcrumbTable.setWidthPercentage(100);

    Chunk communityName = new Chunk(getOwningCommunity(item), helv9);
    PdfPCell commCell = new PdfPCell();
    commCell.setBorderWidth(0);
    commCell.addElement(communityName);

    Chunk collectionName = new Chunk(getOwningCollection(item), helv9);
    PdfPCell collCell = new PdfPCell();
    collCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    collCell.setBorderWidth(0);
    collCell.addElement(collectionName);

    breadcrumbTable.addCell(commCell);
    breadcrumbTable.addCell(collCell);

    breadcrumbTable.setSpacingBefore(5);
    breadcrumbTable.setSpacingAfter(5);

    cDoc.add(breadcrumbTable);

    // Line Separator
    cDoc.add(lineSeparator);

    // 3 - Metadata
    // date.issued
    // dc.title
    // dc.creator; dc.creator
    Paragraph dateIssued = new Paragraph(getFirstMetadata(item, "dc.date.issued"), helv12);
    dateIssued.setSpacingBefore(20);
    cDoc.add(dateIssued);

    Paragraph title = new Paragraph(item.getName(), helv26);
    title.setSpacingBefore(15);
    cDoc.add(title);

    Paragraph creators = new Paragraph(getAllMetadataSeperated(item, "dc.creator"), helv16);
    creators.setSpacingBefore(30);
    creators.setSpacingAfter(20);
    cDoc.add(creators);

    // Line Separator
    cDoc.add(lineSeparator);

    // 4 - Citation
    // dc.identifier.citation
    // dc.identifier.uri
    Paragraph citation = new Paragraph(getFirstMetadata(item, "dc.identifier.citation"), helv12);

    Chunk identifierChunk = new Chunk(getFirstMetadata(item, "dc.identifier.uri"), helv12);
    identifierChunk.setAnchor(getFirstMetadata(item, "dc.identifier.uri"));

    Paragraph identifier = new Paragraph();
    identifier.add(identifierChunk);

    cDoc.add(citation);
    cDoc.add(identifier);

    // 5 - License
    // Downloaded from the Knowledge Bank, The Ohio State University's institutional repository
    Paragraph license = new Paragraph(
            "Downloaded from the Knowledge Bank, The Ohio State University's institutional repository",
            helv12_italic);
    license.setSpacingBefore(10);
    cDoc.add(license);

    cDoc.close();
}

From source file:org.openlmis.web.view.pdf.requisition.RequisitionCellFactory.java

License:Open Source License

public static PdfPCell categoryRow(Integer visibleColumnsSize, LineItem lineItem) {
    Chunk chunk = new Chunk(lineItem.getCategoryName(), FontFactory.getFont(FontFactory.HELVETICA_BOLD));
    PdfPCell cell = new PdfPCell(new Phrase(chunk));
    cell.setColspan(visibleColumnsSize);
    cell.setBackgroundColor(HEADER_BACKGROUND);
    cell.setPadding(CELL_PADDING);//from w w w . j  a v a 2s  . c  om
    return cell;
}

From source file:org.opentox.ontology.components.Algorithm.java

License:Open Source License

@Override
public PDFObject getPDF() {
    PDFObject pdf = new PDFObject();
    pdf.setPdfTitle(getMeta().identifier);
    pdf.setPdfKeywords(getMeta().subject);
    Paragraph p1 = new Paragraph(
            new Chunk("OpenTox - Algorithm Report\n\n", FontFactory.getFont(FontFactory.HELVETICA_BOLD, 14)));
    pdf.addElement(p1);/* w w  w  . j  av  a  2  s  . c  o  m*/
    try {
        PdfPTable table = new PdfPTable(2);

        table.setWidths(new int[] { 10, 50 });

        PdfPCell cell = new PdfPCell(new Paragraph("Algorithm Presentation - General"));
        cell.setColspan(2);
        cell.setBackgroundColor(new BaseColor(0xC0, 0xC0, 0xC0));
        table.addCell(cell);

        table.addCell("Name");
        table.addCell(getMeta().getName());

        table.addCell("Title");
        table.addCell(getMeta().title);

        table.addCell("Subject");
        table.addCell(getMeta().subject);

        table.addCell("Description");
        table.addCell(getMeta().description);

        table.addCell("Identifier");
        table.addCell(getMeta().identifier);

        pdf.addElement(table);
        pdf.addElement(new Paragraph("\n\n\n"));

        table = new PdfPTable(2);
        table.setWidths(new int[] { 10, 50 });
        cell = new PdfPCell(new Paragraph("General Meta Information"));
        cell.setColspan(2);
        cell.setBackgroundColor(new BaseColor(0xC0, 0xC0, 0xC0));
        table.addCell(cell);

        table.addCell("Type");
        table.addCell(getMeta().type);

        table.addCell("Creator");
        table.addCell(getMeta().creator);

        table.addCell("Publisher");
        table.addCell(getMeta().publisher);

        table.addCell("Relation");
        table.addCell(getMeta().relation);

        table.addCell("Rights");
        table.addCell(getMeta().rights);

        table.addCell("Source");
        table.addCell(getMeta().source);

        table.addCell("Provenance");
        table.addCell(getMeta().provenance);

        table.addCell("Contributor");
        table.addCell(getMeta().contributor);

        table.addCell("Language");
        table.addCell(getMeta().language.getDisplayLanguage());

        table.addCell("Created on");
        table.addCell(getMeta().date.toString());

        table.addCell("Formats");
        ArrayList<MediaType> listMedia = getMeta().format;
        String formatTableEntry = "";
        for (int i = 0; i < listMedia.size(); i++) {
            formatTableEntry += listMedia.get(i).toString();
            if (i < listMedia.size() - 1) {
                formatTableEntry += "\n";
            }
        }
        table.addCell(formatTableEntry);

        table.addCell("Audience");
        ArrayList<Audience> audiences = getMeta().audience;
        String auds = "";
        for (int i = 0; i < audiences.size(); i++) {
            auds += audiences.get(i).getName();
            if (i < audiences.size() - 1) {
                auds += "\n";
            }
        }
        table.addCell(auds);
        pdf.addElement(table);
        pdf.addElement(new Paragraph("\n\n\n"));

        table = new PdfPTable(4);
        table.setWidths(new int[] { 30, 30, 30, 30 });
        cell = new PdfPCell(new Paragraph("Algorithm Parameters"));
        cell.setColspan(4);
        cell.setBackgroundColor(new BaseColor(0xC0, 0xC0, 0xC0));
        table.addCell(cell);

        table.addCell("Parameter Name");
        table.addCell("XSD DataType");
        table.addCell("Default Value");
        table.addCell("Scope");

        Map<String, AlgorithmParameter> algParameters = getMeta().getParameters();
        Set<Entry<String, AlgorithmParameter>> entrySet = algParameters.entrySet();
        for (Entry e : entrySet) {
            String pName = (String) e.getKey();
            AlgorithmParameter ap = (AlgorithmParameter) e.getValue();
            table.addCell(pName);
            table.addCell(ap.dataType.getURI());
            table.addCell(ap.paramValue.toString());
            table.addCell(ap.paramScope.toString());
        }

        pdf.addElement(table);

        pdf.addElement(new Paragraph("\n\n\n"));

        table = new PdfPTable(1);
        cell = new PdfPCell(new Paragraph("Ontologies"));
        cell.setBackgroundColor(new BaseColor(0xC0, 0xC0, 0xC0));
        table.addCell(cell);
        OTAlgorithmTypes type = getMeta().getAlgorithmType();
        table.addCell(type.getURI());

        Set<Resource> superOntologies = type.getSuperEntities();
        Iterator<Resource> it = superOntologies.iterator();

        while (it.hasNext()) {
            table.addCell(it.next().getURI());
        }
        pdf.addElement(table);
    } catch (final DocumentException ex) {
        YaqpLogger.LOG.log(new Warning(getClass(), "XCF316 - Pdf Exception :" + ex.toString()));
    }
    return pdf;
}

From source file:org.opentox.ontology.components.User.java

License:Open Source License

@Override
public PDFObject getPDF() {
    PDFObject pdf = new PDFObject();
    pdf.setPdfTitle(getUserName());/*  w  w  w.j  a v  a 2  s .co m*/
    pdf.setPdfKeywords("User, " + getUserName() + ", Account");
    pdf.setSubject("User Account Information for user " + getUserName());
    Paragraph p1 = new Paragraph(
            new Chunk("OpenTox - User Report\n\n", FontFactory.getFont(FontFactory.HELVETICA_BOLD, 14)));
    pdf.addElement(p1);

    try {
        PdfPTable table = new PdfPTable(2);
        table.setWidths(new int[] { 30, 50 });
        PdfPCell cell = new PdfPCell(new Paragraph("User Account Information"));
        cell.setColspan(2);
        cell.setBackgroundColor(new BaseColor(0xC0, 0xC0, 0xC0));
        table.addCell(cell);

        table.addCell("UserName");
        table.addCell(getUserName());

        table.addCell("First Name");
        table.addCell(getFirstName());

        table.addCell("Last Name");
        table.addCell(getLastName());

        table.addCell("e-mail");
        table.addCell(getEmail());

        table.addCell("UserGroup");
        table.addCell(getUserGroup().getName());

        table.addCell("Authorization Level");
        table.addCell(Integer.toString(getUserGroup().getLevel()));

        table.addCell("Organization");
        table.addCell(getOrganization());

        table.addCell("Country");
        table.addCell(getCountry());

        table.addCell("City");
        table.addCell(getCity());

        table.addCell("Address");
        table.addCell(getAddress());

        table.addCell("Web Page");
        table.addCell(getWebpage());

        table.addCell("Created on");
        table.addCell(getTimeStamp());

        pdf.addElement(table);

    } catch (DocumentException ex) {
        YaqpLogger.LOG.log(
                new Warning(getClass(), "XEI909 - Error while generating " + "PDF representation for User"));
    }

    return pdf;
}

From source file:org.opentox.ontology.components.UserGroup.java

License:Open Source License

@Override
public PDFObject getPDF() {
    PDFObject pdf = new PDFObject();
    Paragraph p1 = new Paragraph(
            new Chunk("OpenTox - UserGroup Report\n\n", FontFactory.getFont(FontFactory.HELVETICA_BOLD, 14)));
    pdf.addElement(p1);//from   ww  w .  j a va 2  s  . c  o  m

    try {
        PdfPTable table = new PdfPTable(2);
        table.setWidths(new int[] { 30, 50 });
        PdfPCell cell = new PdfPCell(new Paragraph("UserGroup General Information"));
        cell.setColspan(2);
        cell.setBackgroundColor(new BaseColor(0xC0, 0xC0, 0xC0));
        table.addCell(cell);

        table.addCell("Name");
        table.addCell(getName());

        table.addCell("Authorization Level");
        table.addCell(Integer.toString(getLevel()));

        pdf.addElement(table);

    } catch (DocumentException ex) {
        YaqpLogger.LOG.log(new Warning(getClass(),
                "XPI908 - Error while generating " + "PDF representation for User Group "));
    }

    return pdf;
}

From source file:servlet.PdfGenerator.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods./*from  ww  w  .ja v  a  2 s  .c o m*/
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    Document report = new Document();
    try {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        PdfWriter.getInstance(report, baos);

        DBManager manager = (DBManager) getServletContext().getAttribute("dbmanager");
        Group groupToReport = manager.getGroup(Integer.parseInt(request.getParameter("id")));
        LinkedList<User> groupUsers = manager.getUsersForGroupAndVisible(groupToReport.getId());
        Timestamp lastPosted = manager.getLatestPost(groupToReport);
        int numberOfPosts = manager.getGroupPosts(groupToReport).size();
        String context = request.getServletContext().getRealPath("/");
        Iterator<User> groupIterator = groupUsers.iterator();

        report.open();
        // INSERTING DOCUMENT CONTENT AREA
        Font title = FontFactory.getFont(FontFactory.HELVETICA_BOLD, 24);
        Font text = FontFactory.getFont(FontFactory.HELVETICA, 12);
        Paragraph documentHead = new Paragraph(groupToReport.getName(), title);
        Paragraph newLine = new Paragraph(Chunk.NEWLINE);
        Paragraph latestPost = new Paragraph("Latest post inserted on: " + lastPosted, text);
        Paragraph postsNumberToReport = new Paragraph("Number of posts: " + numberOfPosts, text);

        //LAYOUT AND FINAL PARAGRAPH EDITING AREA
        report.add(documentHead);
        report.add(newLine);
        report.add(postsNumberToReport);
        report.add(newLine);
        report.add(latestPost);
        report.add(newLine);
        PdfPTable usersTable = new PdfPTable(5);

        // LOOP FOR SETTING TABLE
        while (groupIterator.hasNext()) {
            User u = groupIterator.next();
            String userName = u.getName();
            PdfPCell avatarCell = new PdfPCell(Image.getInstance(context + u.getAvatar(request)));
            avatarCell.setBorder(0);
            avatarCell.setPaddingBottom(10);
            avatarCell.setColspan(1);
            PdfPCell userNameCell = new PdfPCell(new Phrase(userName));
            userNameCell.setColspan(4);
            userNameCell.setBorder(0);
            userNameCell.setPaddingBottom(10);
            userNameCell.setPaddingLeft(10);
            usersTable.addCell(avatarCell);
            usersTable.addCell(userNameCell);
        }
        usersTable.setHorizontalAlignment(PdfPTable.ALIGN_LEFT);
        report.add(usersTable);

        report.close();

        // SETTING SOME RESPONSE HEADER
        response.setHeader("Expires", "0");
        response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
        response.setHeader("Pragma", "public");
        // SETTING THE CONTENT TYPE
        response.setContentType("application/pdf");
        // THE CONTENTLENGHT
        response.setContentLength(baos.size());
        System.out.println("ci sono");
        try (OutputStream os = response.getOutputStream()) {
            baos.writeTo(os);
            os.flush();
            os.close();
        } catch (Exception e) {
            throw new IOException(e.getMessage());
        }
    } catch (DocumentException e) {
        throw new IOException(e.getMessage());
    }
}