Example usage for com.itextpdf.text Paragraph setSpacingBefore

List of usage examples for com.itextpdf.text Paragraph setSpacingBefore

Introduction

In this page you can find the example usage for com.itextpdf.text Paragraph setSpacingBefore.

Prototype

public void setSpacingBefore(float spacing) 

Source Link

Usage

From source file:gov.utah.dts.det.ccl.actions.trackingrecordscreening.letters.reports.MultiStateOffenderLetterTX.java

private static void writePdf(TrackingRecordScreeningLetter screeningLetter, OutputStream ba,
        HttpServletRequest request) throws DocumentException, BadElementException, IOException {
    Document document = null;/*  w  ww .j  a  v a 2 s .  c o  m*/
    Paragraph paragraph = null;
    ListItem item = null;
    document = new Document(PageSize.LETTER, 50, 50, 125, 0);
    PdfWriter writer = PdfWriter.getInstance(document, ba);
    StringBuilder sb = null;
    SimpleDateFormat df = new SimpleDateFormat("MMMM d, yyyy");

    document.open();

    LetterheadStamper.stampLetter(writer, request);

    paragraph = getParagraph(10.0f);
    paragraph.add(new Phrase("MSO TX", smallfont));
    paragraph.setIndentationLeft(415);
    document.add(paragraph);
    paragraph.clear();
    paragraph.add(new Phrase("Rev 3/12", smallfont));
    paragraph.setSpacingAfter(50);
    document.add(paragraph);

    // Add report date
    paragraph = getParagraph();
    paragraph.add(new Phrase(df.format(screeningLetter.getLetterDate()), mediumfont));
    paragraph.setIndentationLeft(350);
    document.add(paragraph);

    // Add facility name and address information
    paragraph = getParagraph();
    paragraph.add(new Phrase(screeningLetter.getTrackingRecordScreening().getFacility().getName().toUpperCase(),
            mediumfont));
    paragraph.setSpacingBefore(5);
    document.add(paragraph);
    if (screeningLetter.getTrackingRecordScreening().getFacility().getCbsAddress() != null) {
        if (StringUtils.isNotBlank(
                screeningLetter.getTrackingRecordScreening().getFacility().getCbsAddress().getAddressOne())) {
            paragraph = getParagraph();
            paragraph.add(new Phrase(screeningLetter.getTrackingRecordScreening().getFacility().getCbsAddress()
                    .getAddressOne().toUpperCase(), mediumfont));
            document.add(paragraph);
        }
        if (StringUtils.isNotBlank(
                screeningLetter.getTrackingRecordScreening().getFacility().getCbsAddress().getAddressTwo())) {
            // Add facility location address two
            paragraph = getParagraph();
            paragraph.add(new Phrase(screeningLetter.getTrackingRecordScreening().getFacility().getCbsAddress()
                    .getAddressTwo().toUpperCase(), mediumfont));
            document.add(paragraph);
        }
        if (StringUtils.isNotBlank(
                screeningLetter.getTrackingRecordScreening().getFacility().getCbsAddress().getCityStateZip())) {
            paragraph = getParagraph();
            paragraph.add(new Phrase(screeningLetter.getTrackingRecordScreening().getFacility().getCbsAddress()
                    .getCityStateZip().toUpperCase(), mediumfont));
            document.add(paragraph);
        }
    }

    // Add subject information
    paragraph = getParagraph();
    paragraph.add(new Phrase("RE: Notice of additional Criminal Background Screening information needed:",
            mediumfont));
    paragraph.setSpacingBefore(10);
    document.add(paragraph);

    // Add Screening Person's Name/ID
    sb = new StringBuilder();
    paragraph = getParagraph(16.0f);
    paragraph.add(new Phrase(screeningLetter.getTrackingRecordScreening().getFirstAndLastName() + " ("
            + screeningLetter.getTrackingRecordScreening().getPersonIdentifier() + ")", mediumfont));
    // Indent this line to line up with 'Notice' in subject line
    paragraph.setIndentationLeft(22);
    document.add(paragraph);

    // Add salutation
    paragraph = getParagraph();
    paragraph.add(new Phrase("Dear Director:", mediumfont));
    paragraph.setSpacingBefore(18);
    document.add(paragraph);

    // Start letter detail
    sb = new StringBuilder();
    sb.append(
            "As a follow-up to the request for background screening by the Department of Human Services, Office of Licensing, ");
    sb.append("this is to notify you that additional criminal background screening information is needed.");
    paragraph = getParagraph();
    paragraph.add(new Phrase(sb.toString(), mediumfont));
    paragraph.setSpacingBefore(10);
    document.add(paragraph);

    paragraph = getParagraph();
    paragraph.add(new Phrase(
            "Enclosed are two fingerprint cards for the applicant to provide complete, accurate and legible identifying information. ",
            mediumfont));
    paragraph.add(new Phrase("Return the completed fingerprint cards with a $36.50 fee in the form of a ",
            mediumfont));
    paragraph.add(new Phrase("cashier's check or money order ", mediumfontI));
    paragraph.add(new Phrase("(no personal checks) payable to the ", mediumfont));
    paragraph.add(new Phrase("Department of Human Resources, ", mediumfontI));
    paragraph.add(new Phrase(
            "to the Office of Licensing within 15 calendar days of your receipt of this notice. Do not put multiple fingerprints ",
            mediumfont));
    paragraph.add(new Phrase("with one payment, unless for a couple with the same last name.", mediumfont));
    paragraph.setSpacingBefore(10);
    paragraph.setSpacingAfter(10);
    document.add(paragraph);

    // Add the fingerprint card procedures as an indented bullet list
    List procedure = new List(false, 10);
    procedure.setIndentationLeft(22);
    item = getListItem();
    item.add(new Phrase(
            "Prints should be taken by a local law enforcement office, or an agency approved by law enforcement.",
            mediumfont));
    procedure.add(item);
    item = getListItem();
    item.add(new Phrase("The FBI will reject a card with any highlighting.", mediumfont));
    procedure.add(item);
    item = getListItem();
    item.add(new Phrase(
            "Use only these cards showing identification from the Office of Licensing. We will be glad to give you replacement cards if requested.",
            mediumfont));
    procedure.add(item);
    item = getListItem();
    item.add(new Phrase(
            "If mailing the cards back to us, return by regular mail (please do not fold the cards).",
            mediumfont));
    procedure.add(item);
    item = getListItem();
    item.add(new Phrase(
            "Fingerprint cards must be completely filled out or they will be returned for completion.",
            mediumfont));
    procedure.add(item);
    document.add(procedure);

    sb = new StringBuilder();
    sb.append(
            "Failure to return the completed fingerprint cards and fee within 15 calendar days will result in the background screening ");
    sb.append(
            "application being denied, and the applicant will not be eligible to be associated with the licensed program in any capacity ");
    sb.append(
            "or will not be eligible to proceed with foster care or adoption until all clearance procedures are completed.");
    paragraph = getParagraph();
    paragraph.add(new Phrase(sb.toString(), mediumfont));
    paragraph.setSpacingBefore(10);
    document.add(paragraph);

    sb = new StringBuilder();
    sb.append(
            "Please allow up to 12 weeks for the completion of the clearance process. For assistance or inquiries, please contact the Office of Licensing ");
    sb.append("at (801) 538-4242.");
    paragraph = getParagraph();
    paragraph.add(new Phrase(sb.toString(), mediumfont));
    paragraph.setSpacingBefore(10);
    document.add(paragraph);

    paragraph = new Paragraph();
    paragraph.add(new Phrase("Sincerely,", mediumfont));
    paragraph.setSpacingBefore(10);
    document.add(paragraph);

    paragraph = new Paragraph();
    paragraph.add(new Phrase(screeningLetter.getCreatedBy().getFirstAndLastName(), mediumfont));
    paragraph.setSpacingBefore(25);
    document.add(paragraph);

    paragraph = new Paragraph();
    paragraph.add(new Phrase("Background Screening Unit", mediumfont));
    document.add(paragraph);

    document.close();
}

From source file:gov.va.cem.eoas.business.FaxArchivesPDF.java

public InputStream generatePDF(FaxRecord data) {
    SimpleDateFormat newFormat = new SimpleDateFormat("MM/dd/yyyy");

    Date curDate = new Date();
    String caseIdData = (data.getCaseId() != null) ? data.getCaseId() : "";
    String currentDate = new String(newFormat.format(curDate));
    String sepDocs = (data.getSepDocs()) ? "X" : "";
    String marLicense = (data.getMarLicense()) ? "X" : "";
    String adminDecision = (data.getAdminDecision()) ? "X" : "";
    String deathCert = (data.getDeathCert()) ? "X" : "";
    String divorceDecree = (data.getDivorceDecree()) ? "X" : "";
    String otherCheck = (data.getOtherCheck()) ? "X" : "";
    String transDate = (data.getTransDate() != null) ? new String(newFormat.format(data.getTransDate())) : "";
    String priorLoc = (data.getPriorLoc() != null) ? data.getPriorLoc() : "";
    String otherComments = (data.getOtherComments() != null) ? data.getOtherComments() : "";
    String remarks = (data.getRemarks() != null) ? data.getRemarks() : "";
    String to = data.getTo().getDisplayName();
    String fileNo = (data.getFileNo() != null) ? data.getFileNo() : "";
    String vetName = (data.getVetName() != null) ? data.getVetName() : "";
    String ssnData = (data.getSSN() != null) ? data.getSSN() : "";
    String snData = (data.getSN() != null) ? data.getSN() : "";
    String farcNo = (data.getFarcNo() != null) ? data.getFarcNo() : "";
    String boxNoData = (data.getBoxNo() != null) ? data.getBoxNo() : "";
    String faxPages = (data.getFaxPages() != null) ? data.getFaxPages() : "";

    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    Document document = new Document(PageSize.A4, 50, 50, 50, 50);
    try {//w w  w. j  a  v  a 2s.c  o  m
        PdfWriter.getInstance(document, outputStream);
        //Font font1 = new Font(Font.FontFamily.TIMES_ROMAN, 9);
        Font font2 = new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD);
        Font font3 = new Font(Font.FontFamily.TIMES_ROMAN, 11);
        Font fontBold = new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.BOLD);
        //Font fontUnderline = new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.UNDERLINE);
        Font fontHeader = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD);

        document.open();

        String dirPath = FacesContext.getCurrentInstance().getExternalContext()
                .getInitParameter("image_file_path");
        // Check servlet context for invalid character
        if (dirPath.contains(".."))
            throw new IllegalArgumentException(
                    "Servlet context contains invalid character(s).  Security may have been compromised.");
        File dir = new File(dirPath);

        Image image = Image.getInstance(dir + "/ArchiveFaxHeader.jpg");
        image.scalePercent(69, 66);
        document.add(image);

        // Create first table
        float[] colsWidthTo = { .3f, 2f, .4f, 2f };
        PdfPTable addressTable = new PdfPTable(colsWidthTo);
        addressTable.setWidthPercentage(100);
        PdfPCell toLabel = new PdfPCell(new Phrase("TO:", fontBold));
        toLabel.setRowspan(3);
        toLabel.setBorderWidthRight(0);
        addressTable.addCell(toLabel);
        PdfPCell toName = new PdfPCell(new Phrase(to, fontBold));
        toName.setBorderWidthLeft(0);
        toName.setBorderWidthBottom(0);
        addressTable.addCell(toName);
        PdfPCell fromLabel = new PdfPCell(new Phrase("FROM:", fontBold));
        fromLabel.setBorderWidthRight(0);
        fromLabel.setBorderWidthBottom(0);
        addressTable.addCell(fromLabel);
        PdfPCell fromName = new PdfPCell(new Phrase("Eligibility Case Manager", fontBold));
        fromName.setBorderWidthBottom(0);
        fromName.setBorderWidthLeft(0);
        addressTable.addCell(fromName);
        PdfPCell toAddress = new PdfPCell(new Phrase("", fontBold));
        toAddress.setBorderWidthLeft(0);
        toAddress.setBorderWidthTop(0);
        addressTable.addCell(toAddress);
        PdfPCell fromDateLabel = new PdfPCell(new Phrase("DATE:", fontBold));
        fromDateLabel.setBorderWidthRight(0);
        fromDateLabel.setBorderWidthTop(0);
        //toLabel.setRowspan(2);
        addressTable.addCell(fromDateLabel);
        PdfPCell dateFrom = new PdfPCell(new Phrase(currentDate, fontBold));
        dateFrom.setBorderWidthTop(0);
        dateFrom.setBorderWidthLeft(0);
        addressTable.addCell(dateFrom);
        addressTable.setSpacingBefore(15);
        addressTable.setSpacingAfter(15);
        document.add(addressTable);

        float[] colsWidthCaseId = { .7f, 3f };
        PdfPTable caseTable = new PdfPTable(colsWidthCaseId);
        caseTable.setWidthPercentage(100);
        PdfPCell caseIdLabel = new PdfPCell(new Phrase("Eligibility Case Id:", font3));
        caseIdLabel.setBorderWidth(0);
        caseTable.addCell(caseIdLabel);
        PdfPCell caseIdInput = new PdfPCell(new Phrase(caseIdData, font3));
        caseIdInput.setBorderWidth(0);
        caseTable.addCell(caseIdInput);
        caseTable.setSpacingAfter(8);
        document.add(caseTable);

        float[] colsWidthFolder = { .5f, 3f };
        PdfPTable folderTable = new PdfPTable(colsWidthFolder);
        folderTable.setWidthPercentage(100);
        PdfPCell folderLabel = new PdfPCell(new Phrase("VA file No:", font3));
        folderLabel.setBorderWidth(0);
        folderTable.addCell(folderLabel);
        PdfPCell folder = new PdfPCell(new Phrase(fileNo, font3));
        folder.setBorderWidth(0);
        folderTable.addCell(folder);
        folderTable.setSpacingAfter(8);
        document.add(folderTable);

        float[] colsWidthRef = { .7f, 3f };
        PdfPTable refTable = new PdfPTable(colsWidthRef);
        refTable.setWidthPercentage(100);
        PdfPCell ref = new PdfPCell(new Phrase("Veteran's Name:", font3));
        ref.setBorderWidth(0);
        refTable.addCell(ref);
        PdfPCell refName = new PdfPCell(new Phrase(vetName, font3));
        refName.setBorderWidth(0);
        refTable.addCell(refName);
        refTable.setSpacingAfter(8);
        document.add(refTable);

        float[] colsWidthSSN = { .3f, 2f, .25f, 2f };
        PdfPTable ssnTable = new PdfPTable(colsWidthSSN);
        ssnTable.setWidthPercentage(100);
        PdfPCell ssnLabel = new PdfPCell(new Phrase("SSN:", font3));
        ssnLabel.setBorderWidth(0);
        ssnTable.addCell(ssnLabel);
        PdfPCell ssn = new PdfPCell(new Phrase(ssnData, font3));
        ssn.setBorderWidth(0);
        ssnTable.addCell(ssn);
        PdfPCell snLabel = new PdfPCell(new Phrase("SN:", font3));
        snLabel.setBorderWidth(0);
        ssnTable.addCell(snLabel);
        PdfPCell sn = new PdfPCell(new Phrase(snData, font3));
        sn.setBorderWidth(0);
        ssnTable.addCell(sn);
        ssnTable.setSpacingAfter(8);
        document.add(ssnTable);

        float[] colsWidthFARC = { .6f, 2f, .8f, 2f };
        PdfPTable farcTable = new PdfPTable(colsWidthFARC);
        farcTable.setWidthPercentage(100);
        PdfPCell farcLabel = new PdfPCell(new Phrase("FARC No:", font3));
        farcLabel.setBorderWidth(0);
        farcTable.addCell(farcLabel);
        PdfPCell farc = new PdfPCell(new Phrase(farcNo, font3));
        farc.setBorderWidth(0);
        farcTable.addCell(farc);
        PdfPCell farcDateLabel = new PdfPCell(new Phrase("Transfer Date:", font3));
        farcDateLabel.setBorderWidth(0);
        farcTable.addCell(farcDateLabel);
        PdfPCell farcDate = new PdfPCell(new Phrase(transDate, font3));
        farcDate.setBorderWidth(0);
        farcTable.addCell(farcDate);
        farcTable.setSpacingAfter(8);
        document.add(farcTable);

        float[] colsWidthLoc = { .8f, 2f, .6f, 2f };
        PdfPTable locTable = new PdfPTable(colsWidthLoc);
        locTable.setWidthPercentage(100);
        PdfPCell locLabel = new PdfPCell(new Phrase("Prior Location:", font3));
        locLabel.setBorderWidth(0);
        locTable.addCell(locLabel);
        PdfPCell location = new PdfPCell(new Phrase(priorLoc, font3));
        location.setBorderWidth(0);
        locTable.addCell(location);
        PdfPCell boxNoLabel = new PdfPCell(new Phrase("Box No:", font3));
        boxNoLabel.setBorderWidth(0);
        locTable.addCell(boxNoLabel);
        PdfPCell boxNo = new PdfPCell(new Phrase(boxNoData, font3));
        boxNo.setBorderWidth(0);
        locTable.addCell(boxNo);
        locTable.setSpacingAfter(8);
        document.add(locTable);

        float[] colsWidthRemarks = { .6f, 5f };
        PdfPTable remarks1Table = new PdfPTable(colsWidthRemarks);
        remarks1Table.setWidthPercentage(100);
        PdfPCell remark1Label = new PdfPCell(new Phrase("Remarks:", font3));
        remark1Label.setBorderWidth(0);
        remarks1Table.addCell(remark1Label);
        PdfPCell remarks1Input = new PdfPCell(new Phrase(
                "Please provide copy(ies) of the following document(s) to establish eligibility for burial in a national cemetery.",
                font3));
        remarks1Input.setBorderWidth(0);
        remarks1Table.addCell(remarks1Input);
        remarks1Table.setSpacingAfter(8);
        document.add(remarks1Table);

        float[] colsWidthDocs = { .4f, 2f, .4f, 2f };
        PdfPTable docsTable = new PdfPTable(colsWidthDocs);
        docsTable.setWidthPercentage(100);
        PdfPCell docsLabel = new PdfPCell(new Phrase(sepDocs, font3));
        docsLabel.setHorizontalAlignment(Element.ALIGN_CENTER);
        docsLabel.setBorderWidth(0);
        docsLabel.setBorderWidthBottom(1);
        docsTable.addCell(docsLabel);
        PdfPCell docs1 = new PdfPCell(new Phrase("Separation Document(s)", font3));
        docs1.setBorderWidth(0);
        docsTable.addCell(docs1);
        PdfPCell docs2 = new PdfPCell(new Phrase(deathCert, font3));
        docs2.setHorizontalAlignment(Element.ALIGN_CENTER);
        docs2.setBorderWidth(0);
        docs2.setBorderWidthBottom(1);
        docsTable.addCell(docs2);
        PdfPCell docs3 = new PdfPCell(new Phrase("Death Certificate", font3));
        docs3.setBorderWidth(0);
        docsTable.addCell(docs3);
        PdfPCell docs4 = new PdfPCell(new Phrase(marLicense, font3));
        docs4.setHorizontalAlignment(Element.ALIGN_CENTER);
        docs4.setBorderWidth(0);
        docs4.setBorderWidthBottom(1);
        docsTable.addCell(docs4);
        PdfPCell docs5 = new PdfPCell(new Phrase("Marriage License", font3));
        docs5.setBorderWidth(0);
        docsTable.addCell(docs5);
        PdfPCell docs6 = new PdfPCell(new Phrase(divorceDecree, font3));
        docs6.setHorizontalAlignment(Element.ALIGN_CENTER);
        docs6.setBorderWidth(0);
        docs6.setBorderWidthBottom(1);
        docsTable.addCell(docs6);
        PdfPCell docs7 = new PdfPCell(new Phrase("Divorce Decree", font3));
        docs7.setBorderWidth(0);
        docsTable.addCell(docs7);
        PdfPCell docs8 = new PdfPCell(new Phrase(adminDecision, font3));
        docs8.setHorizontalAlignment(Element.ALIGN_CENTER);
        docs8.setBorderWidth(0);
        docs8.setBorderWidthBottom(1);
        docsTable.addCell(docs8);
        PdfPCell docs9 = new PdfPCell(new Phrase("VA Admin Decision", font3));
        docs9.setBorderWidth(0);
        docsTable.addCell(docs9);
        PdfPCell docs10 = new PdfPCell(new Phrase("", font3));
        docs10.setBorderWidth(0);
        docsTable.addCell(docs10);
        PdfPCell docs11 = new PdfPCell(new Phrase("", font3));
        docs11.setBorderWidth(0);
        docsTable.addCell(docs11);
        document.add(docsTable);

        float[] colsWidthOther = { .4f, .4f, 4f };
        PdfPTable otherDocTable = new PdfPTable(colsWidthOther);
        otherDocTable.setWidthPercentage(100);
        PdfPCell otherDoc1 = new PdfPCell(new Phrase(otherCheck, font3));
        otherDoc1.setHorizontalAlignment(Element.ALIGN_CENTER);
        otherDoc1.setBorderWidth(0);
        otherDoc1.setBorderWidthBottom(1);
        otherDocTable.addCell(otherDoc1);
        PdfPCell otherDoc2 = new PdfPCell(new Phrase("Other", font3));
        otherDoc2.setBorderWidth(0);
        otherDocTable.addCell(otherDoc2);
        PdfPCell otherDoc3 = new PdfPCell(new Phrase("", font3));
        otherDoc3.setBorderWidth(0);
        otherDocTable.addCell(otherDoc3);
        otherDocTable.setSpacingAfter(8);
        document.add(otherDocTable);

        if (!otherComments.equals("")) {
            float[] colsWidthOtherComments = { 1.1f, 5f };
            PdfPTable otherCommentsTable = new PdfPTable(colsWidthOtherComments);
            otherCommentsTable.setWidthPercentage(100);
            PdfPCell otherCommentLabel = new PdfPCell(new Phrase("Other Comments:", font3));
            otherCommentLabel.setBorderWidth(0);
            otherCommentsTable.addCell(otherCommentLabel);
            PdfPCell otherCommentsInput = new PdfPCell(new Phrase(otherComments, font3));
            otherCommentsInput.setBorderWidth(0);
            otherCommentsTable.addCell(otherCommentsInput);
            otherCommentsTable.setSpacingAfter(8);
            document.add(otherCommentsTable);
        }

        PdfPTable remarksTable = new PdfPTable(colsWidthRemarks);
        remarksTable.setWidthPercentage(100);
        PdfPCell remarkLabel = new PdfPCell(new Phrase("Remarks:", font3));
        remarkLabel.setBorderWidth(0);
        remarksTable.addCell(remarkLabel);
        PdfPCell remarksInput = new PdfPCell(new Phrase(remarks, font3));
        remarksInput.setBorderWidth(0);
        remarksTable.addCell(remarksInput);
        remarksTable.setSpacingAfter(8);
        document.add(remarksTable);

        Paragraph expediteOne = new Paragraph("-- PLEASE EXPEDITE --", font3);
        expediteOne.setSpacingBefore(5);
        expediteOne.setSpacingAfter(10);
        document.add(expediteOne);

        Paragraph disclosure = new Paragraph(
                "This fax is intended only for the use of the person or office to which it is addressed and may contain information that is privileged, confidential, or protected by law.  All others are hereby notified that the receipt of this fax does not waive any applicable privilege or exemption for disclosure and that any dissemination, distribution, or copying of this communication is prohibited.  If you have received this fax in error, please notify this office immediately at the telephone number listed above.",
                font2);
        disclosure.setAlignment(Element.ALIGN_JUSTIFIED);
        disclosure.setSpacingBefore(5);
        disclosure.setSpacingAfter(10);
        document.add(disclosure);

        float[] colsWidthPages = { 5f, .5f, 2f };
        PdfPTable pagesTable = new PdfPTable(colsWidthPages);
        pagesTable.setWidthPercentage(71);
        PdfPCell pageOneLabel = new PdfPCell(
                new Phrase("This fax sheet consists of the cover page and ", fontHeader));
        pageOneLabel.setBorderWidth(0);
        pageOneLabel.setHorizontalAlignment(Element.ALIGN_RIGHT);
        pagesTable.addCell(pageOneLabel);
        PdfPCell pages = new PdfPCell(new Phrase(faxPages, fontHeader));
        pages.setBorderWidth(0);
        pages.setHorizontalAlignment(Element.ALIGN_CENTER);
        pages.setBorderWidthBottom(1);
        pagesTable.addCell(pages);
        PdfPCell pageTwoLabel = new PdfPCell(new Phrase(" additional pages", fontHeader));
        pageTwoLabel.setBorderWidth(0);
        pagesTable.addCell(pageTwoLabel);
        pagesTable.setSpacingAfter(8);
        document.add(pagesTable);

        Paragraph expediteTwo = new Paragraph("FAX:  816-268-8163  ***** BURIAL  PLEASE EXPEDITE   *****",
                fontBold);
        expediteTwo.setSpacingBefore(5);
        expediteTwo.setSpacingAfter(10);
        document.add(expediteTwo);

        document.close();
    } catch (Exception ex) {
        System.err.println(ex.getMessage());
    }
    return new ByteArrayInputStream(outputStream.toByteArray());

}

From source file:GUI.GestionProjects.java

private void button1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button1ActionPerformed
    String IMAGE1 = lblPathImage.getText();
    Font red = new Font(Font.FontFamily.HELVETICA, 12, Font.BOLD, BaseColor.RED);
    Chunk redText = new Chunk("Les information relatif au Projet : ", red);
    Font blue = new Font(Font.FontFamily.HELVETICA, 12, Font.BOLD, BaseColor.BLUE);

    Document document = new Document();
    java.util.Date utilStartDate = jdateDeadLine.getDate();
    java.sql.Date sqlStartDate = new java.sql.Date(utilStartDate.getTime());
    try {/*from w w w . j  ava  2  s  .co m*/
        PdfWriter.getInstance(document, new FileOutputStream("Report.pdf"));
        document.open();

        Paragraph p1 = new Paragraph();
        p1.add(redText);
        p1.add(txtTitreProjet.getText());

        Chunk txtdesc = new Chunk("Decription du Projet: ", red);
        Paragraph p2 = new Paragraph();
        p2.add(txtdesc);
        p2.add(txtDescriptionProjet.getText());

        Chunk txtcat = new Chunk("Catgorie du Projet: ", red);
        Paragraph p3 = new Paragraph();
        p3.add(txtcat);
        p3.add(combo_Cat.getSelectedItem().toString());

        Chunk txtfin = new Chunk("Mode de finnancement du Projet: ", red);
        Paragraph p4 = new Paragraph();
        p4.add(txtfin);
        p4.add(ComboFinnancementProjet.getSelectedItem().toString());

        Chunk txtdate = new Chunk("Date DeadLine Projet: ", red);
        Paragraph p5 = new Paragraph();
        p5.add(txtdate);
        p5.add(sqlStartDate.toString());

        p1.setSpacingAfter(25);
        p1.setSpacingBefore(25);
        p1.setAlignment(Element.ALIGN_CENTER);
        p1.setIndentationLeft(50);
        p1.setIndentationRight(50);

        document.add(p1);
        document.add(p2);
        document.add(p3);
        document.add(p4);
        document.add(p5);

        if (Desktop.isDesktopSupported()) {
            try {
                File myFile = new File("Report.pdf");
                Desktop.getDesktop().open(myFile);
            } catch (IOException ex) {
                // no application registered for PDFs
            }
        }
    } catch (Exception e) {
        System.out.println(e);
    }
    document.close();
    // TODO add your handling code here:
}

From source file:net.sf.timecult.export.pdf.PdfTaskListExporter.java

License:Open Source License

private static void createTaskList(Document doc, TaskStatus taskStatus, Class<Task> taskSubtype)
        throws DocumentException, IOException {
    String tag = "tasklist." + taskStatus.toString();
    if (taskStatus.getId() == TaskStatus.FLAGGED) {
        tag = taskStatus.getFlagColor().toString().toLowerCase() + "Flag";
    }//from  w w w.j ava  2s .  c  o  m
    String titleText = ResourceHelper.getString("button." + tag + ".tooltip");
    Paragraph subTitle = new Paragraph(titleText, sectionFont);
    subTitle.setSpacingAfter(10);
    subTitle.setSpacingBefore(10);
    doc.add(subTitle);
    Task filteredTasks[] = TimeTracker.getInstance().getWorkspace().getTasksByStatus(taskStatus);
    TreeMap<String, Task> sortedItems = new TreeMap<String, Task>();
    for (int i = 0; i < filteredTasks.length; i++) {
        sortedItems.put(filteredTasks[i].toString(), filteredTasks[i]);
    }
    Collection<Task> tasks = sortedItems.values();
    com.itextpdf.text.List taskList = new List();
    for (Task task : tasks) {
        //
        // Add flagged items regardless of their subtype (task or activity)
        //
        if ((taskStatus.getId() == TaskStatus.FLAGGED && task.getStatus().getId() == TaskStatus.FLAGGED)
                || task.getClass().equals(taskSubtype)) {

            Paragraph namePar = new Paragraph(task.getName(), textFont);
            ListItem taskItem = new ListItem();
            taskItem.add(namePar);
            if (taskStatus.getId() == TaskStatus.WAITING) {
                Paragraph reasonPar = new Paragraph(task.getWaitReason().getText(), commentFont);
                taskItem.add(reasonPar);
            }
            taskList.add(taskItem);
        }
    }
    doc.add(taskList);
}

From source file:nl.ctmm.trait.proteomics.qcviewer.utils.ReportPDFExporter.java

License:Apache License

/**
 * Export a report to a pdf file./*from   ww w  .j  a v  a2s. c o  m*/
 *
 * @param allMetricsMap         map of all QC metrics - keys and description.
 * @param selectedReports       the report units to be exported in PDF format.
 * @param preferredPDFDirectory the directory the pdf document should be exported to.
 * @return Path of the created PDF document if it is successfully created - otherwise return empty string.
 */
public static String exportReportUnitInPDFFormat(final Map<String, String> allMetricsMap,
        final ArrayList<ReportUnit> selectedReports, final String preferredPDFDirectory) {
    //Obtain current timestamp. 
    final java.util.Date date = new java.util.Date();
    final String timestampString = CREATION_DATE_TIME_FORMAT.format(date);
    //Replace all occurrences of special character ':' from time stamp since ':' is not allowed in filename. 
    final String filenameTimestamp = timestampString.replace(':', '-');
    //Instantiation of document object - landscape format using the rotate() method
    final Document document = new Document(PageSize.A4.rotate(), PDF_PAGE_MARGIN, PDF_PAGE_MARGIN,
            PDF_PAGE_MARGIN, PDF_PAGE_MARGIN);
    final String pdfFileName = preferredPDFDirectory + "\\QCReports-" + filenameTimestamp + FILE_TYPE_EXTENSION;
    try {
        //Creation of PdfWriter object
        //            PdfWriter writer;
        //            writer = PdfWriter.getInstance(document, new FileOutputStream(pdfFileName));
        document.open();
        for (ReportUnit reportUnit : selectedReports) {
            //New page for each report. 
            document.newPage();
            //Creation of chapter object
            final Paragraph pageTitle = new Paragraph(
                    String.format(PDF_PAGE_TITLE, reportUnit.getMsrunName(), timestampString),
                    Constants.PDF_TITLE_FONT);
            pageTitle.setAlignment(Element.ALIGN_CENTER);
            final Chapter chapter1 = new Chapter(pageTitle, 1);
            chapter1.setNumberDepth(0);
            //Creation of TIC graph section object
            final String graphTitle = String.format(TIC_GRAPH_SECTION_TITLE, reportUnit.getMsrunName());
            final Paragraph ticGraphSection = new Paragraph(graphTitle, Constants.PDF_SECTION_FONT);
            ticGraphSection.setSpacingBefore(PDF_PARAGRAPH_SPACING);
            ticGraphSection.add(Chunk.NEWLINE);
            //Insert TIC Graph in ticGraphSection.
            ticGraphSection.add(createTICChartImage(reportUnit));
            chapter1.addSection(ticGraphSection);
            final String metricsTitle = String.format(METRICS_VALUES_SECTION_TITLE, reportUnit.getMsrunName());
            final Paragraph metricsValuesSection = new Paragraph(metricsTitle, Constants.PDF_SECTION_FONT);
            metricsValuesSection.setSpacingBefore(PDF_PARAGRAPH_SPACING);
            //Reference: http://www.java-connect.com/itext/add-table-in-PDF-document-using-java-iText-library.html
            //TODO: Insert metrics values table in metricsValuesSection
            metricsValuesSection.add(createMetricsValuesTable(allMetricsMap, reportUnit));
            chapter1.addSection(metricsValuesSection);
            //Addition of a chapter to the main document
            document.add(chapter1);
        }
        document.close();
        return pdfFileName;
    } catch (final DocumentException e) {
        // TODO Explain when these exception can occur.
        /* FileNotFoundException will be thrown by the FileInputStream, FileOutputStream, and 
         * RandomAccessFile constructors when a file with the specified path name does not exist.
         * It will also be thrown by these constructors if the file does exist but for some reason 
         * is inaccessible, for example when an attempt is made to open a read-only file for writing.
         * DocumentException Signals that an error has occurred in a Document.
         */
        logger.log(Level.SEVERE, PDF_EXPORT_EXCEPTION_MESSAGE, e);
        return "";
    }
}

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

/**
 * Takes a DSpace {@link Bitstream} and uses its associated METADATA to
 * create a cover page.//from   w  w  w .ja v  a  2 s  . c o  m
 *
 * @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.ganttproject.impex.htmlpdf.itext.ThemeImpl.java

License:GNU General Public License

private PdfPTable createColontitleTable(String topLeft, String topRight, String bottomLeft,
        String bottomRight) {//from  w  ww  .  j ava  2 s  .  co  m
    PdfPTable head = new PdfPTable(2);
    {
        PdfPCell cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        Paragraph p = new Paragraph(topLeft, getSansRegularBold(18));
        p.setAlignment(Paragraph.ALIGN_LEFT);
        // colontitle.setLeading(0);
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell.setVerticalAlignment(Element.ALIGN_BOTTOM);
        // cell.setPaddingLeft(2);
        cell.setPaddingBottom(6);
        cell.setPhrase(p);
        head.addCell(cell);
    }
    {
        PdfPCell cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        Paragraph p = new Paragraph(topRight, getSansRegularBold(10));
        p.setAlignment(Paragraph.ALIGN_RIGHT);
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setVerticalAlignment(Element.ALIGN_BOTTOM);
        cell.setPaddingBottom(6);
        cell.setPhrase(p);
        head.addCell(cell);
    }
    {
        PdfPCell cell = new PdfPCell();
        cell.setVerticalAlignment(Element.ALIGN_TOP);
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell.setPaddingLeft(3);
        cell.setPaddingTop(2);
        cell.setPaddingBottom(6);
        cell.setBorder(Rectangle.TOP);
        cell.setBorderWidthTop(2);
        cell.setBorderColor(SORTAVALA_GREEN);
        Paragraph p = new Paragraph(bottomLeft, getSansRegularBold(18));
        p.setAlignment(Paragraph.ALIGN_LEFT);
        p.setExtraParagraphSpace(0);
        p.setIndentationLeft(0);
        p.setSpacingBefore(0);
        cell.setPhrase(p);
        // cell.addElement(p);
        head.addCell(cell);
    }
    {
        PdfPCell cell = new PdfPCell();
        cell.setVerticalAlignment(Element.ALIGN_TOP);
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setPaddingTop(2);
        cell.setPaddingBottom(6);
        cell.setBorder(Rectangle.TOP);
        cell.setBorderWidthTop(2);
        cell.setBorderColor(SORTAVALA_GREEN);
        Paragraph p = new Paragraph(bottomRight, getSansRegularBold(10));
        p.setAlignment(Paragraph.ALIGN_RIGHT);
        cell.setPhrase(p);
        head.addCell(cell);
    }
    final Document document = myDoc;
    Rectangle page = document.getPageSize();
    head.setTotalWidth(page.getWidth() - document.leftMargin() - document.rightMargin());
    return head;
}

From source file:org.inspira.condominio.pdf.DocumentoEgresos.java

public void exportarPdf(String destino) throws IOException, DocumentException {
    File file = new File(destino);
    file.getParentFile().mkdirs();/*  w  ww . j a  va 2s .  co  m*/
    PdfWriter.getInstance(documento, new FileOutputStream(file));
    documento.open();
    documento.add(new Paragraph(
            "Periodo: ".concat(
                    DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault()).format(new Date())),
            F_NORMAL));
    documento.add(new Paragraph(admin, F_NORMAL));
    Paragraph heading = new Paragraph("Gastos ".concat(tipoDeGasto),
            new Font(Font.FontFamily.HELVETICA, 18, Font.BOLD, new BaseColor(0x000000)));
    heading.setSpacingBefore(16f);
    heading.setSpacingAfter(16f);
    Paragraph heading2 = new Paragraph("Autoriz",
            new Font(Font.FontFamily.HELVETICA, 12, Font.NORMAL, new BaseColor(0x000000)));
    PdfPTable table = new PdfPTable(2);
    table.setWidthPercentage(100);
    Paragraph heading3 = new Paragraph("Vo. Bo.",
            new Font(Font.FontFamily.HELVETICA, 12, Font.NORMAL, new BaseColor(0x000000)));
    PdfPCell cell1 = new PdfPCell(heading2);
    cell1.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
    cell1.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    cell1.setColspan(1);
    cell1.setFixedHeight(20f);
    cell1.setBorder(Rectangle.NO_BORDER);
    PdfPCell cell2 = new PdfPCell(heading3);
    cell2.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
    cell2.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    cell2.setColspan(1);
    cell2.setFixedHeight(20f);
    cell2.setBorder(Rectangle.NO_BORDER);
    table.addCell(cell1);
    table.addCell(cell2);
    table.setSpacingBefore(16f);
    table.setSpacingAfter(32f);

    documento.add(heading);
    agregarTablaEgresos(egresos);
    documento.add(table);
    agregarZonaVistoBueno();
    documento.close();
}

From source file:org.inspira.condominio.pdf.DocumentoEstadoDeCuenta.java

private void bakeContent(String path, String imgResString) throws IOException, DocumentException {
    File outFile = new File(path);
    outFile.getParentFile().mkdirs();//  w w  w.  ja  v  a2 s  . c o  m
    PdfWriter.getInstance(documento, new FileOutputStream(outFile));
    documento.open();
    documento.add(new Paragraph(
            "Ciudad de Mxico, "
                    + DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.getDefault()).format(new Date()),
            new Font(FontFamily.HELVETICA, 18, Font.NORMAL, new BaseColor(0x000000))));
    Paragraph intro = new Paragraph(new Phrase("Comprobante de estado de cuenta", F_NORMAL));
    intro.setAlignment(Paragraph.ALIGN_RIGHT);
    intro.setSpacingBefore(10f);
    documento.add(intro);
    Image image = Image.getInstance(imgResString);
    PdfPTable table = new PdfPTable(1);
    table.setTotalWidth(image.getScaledWidth());
    table.setLockedWidth(true);
    PdfPCell cell = new PdfPCell();
    cell.setBorder(0);
    //cell.setCellEvent(new ImageBackgroundEvent(image));
    cell.setFixedHeight(image.getScaledHeight());
    table.addCell(cell);
    documento.add(table);
    Paragraph p1 = new Paragraph("Estado de cuenta: ".concat(idEdoCta), F_NORMAL);
    p1.setSpacingBefore(5f);
    p1.setSpacingAfter(25f);
    p1.setAlignment(Paragraph.ALIGN_CENTER);
    documento.add(p1);
    documento.add(new Paragraph("Pagos", F_NORMAL));
    agregaTablaDePagos();
    Paragraph pNotas = new Paragraph("Notas: ".concat(notas), F_NORMAL);
    pNotas.setSpacingAfter(12f);
    pNotas.setSpacingAfter(2f);
    documento.add(pNotas);
    Paragraph pAdeudos = new Paragraph("Adeudos", F_NORMAL);
    pAdeudos.setSpacingBefore(25f);
    documento.add(pAdeudos);
    agregaTablaDeAdeudos();
    documento.add(new Paragraph(
            "Recuerde que puede consultar su estado de pagos y adeudos desde la aplicacin mvil o directamente con su administrador.",
            F_NORMAL));
    Paragraph hechoPor = new Paragraph("Elabor:", F_NORMAL);
    hechoPor.setSpacingBefore(30f);
    hechoPor.setSpacingAfter(15f);
    documento.add(hechoPor);
    Paragraph nombreDelAdmin = new Paragraph(admin, F_NORMAL);
    nombreDelAdmin.setAlignment(Paragraph.ALIGN_CENTER);
    documento.add(nombreDelAdmin);
    Paragraph nombreDeCondominio = new Paragraph(condominio, F_NORMAL);
    nombreDeCondominio.setAlignment(Paragraph.ALIGN_CENTER);
    documento.add(nombreDeCondominio);
}

From source file:org.inspira.condominio.pdf.DocumentoIngreso.java

public void exportarPdf(String destino, String nombreInmueble, String dir)
        throws IOException, DocumentException {
    File file = new File(destino);
    PdfWriter.getInstance(documento, new FileOutputStream(file));
    documento.open();//from ww  w .  ja  va 2  s.co  m
    Paragraph inmueble = new Paragraph(nombreInmueble,
            new Font(Font.FontFamily.HELVETICA, 26, Font.BOLD, new BaseColor(0x000000)));
    inmueble.setSpacingAfter(8f);
    documento.add(inmueble);
    documento.add(new Paragraph(dir, F_NORMAL));
    documento.add(new Paragraph(
            "Periodo: ".concat(
                    DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.getDefault()).format(new Date())),
            F_NORMAL));
    Paragraph heading = new Paragraph("Formato de ingresos ordinario",
            new Font(Font.FontFamily.HELVETICA, 18, Font.BOLD, new BaseColor(0x000000)));
    heading.setSpacingBefore(16f);
    heading.setSpacingAfter(16f);
    Paragraph heading2 = new Paragraph("Cobranza ordinaria",
            new Font(Font.FontFamily.HELVETICA, 18, Font.BOLD, new BaseColor(0x000000)));
    heading2.setSpacingBefore(16f);
    heading2.setSpacingAfter(16f);
    Paragraph heading3 = new Paragraph("Formato de ingresos extraordinario",
            new Font(Font.FontFamily.HELVETICA, 18, Font.BOLD, new BaseColor(0x000000)));
    heading3.setSpacingBefore(16f);
    heading3.setSpacingAfter(16f);
    Paragraph heading4 = new Paragraph("Cobranza extraordinaria",
            new Font(Font.FontFamily.HELVETICA, 18, Font.BOLD, new BaseColor(0x000000)));
    heading4.setSpacingBefore(16f);
    heading4.setSpacingAfter(16f);
    documento.add(heading);
    totalRegular = addTablaFormatoIngresos(infoIngresos);
    documento.add(heading2);
    addTablaCobranza(infoIngresos);
    documento.add(heading3);
    totalExtra = addTablaFormatoIngresos(infoIngresosExtra);
    documento.add(heading4);
    addTablaCobranza(infoIngresosExtra);
    Paragraph heading5 = new Paragraph(
            String.format("TOTAL DE INGRESOS: %.2f pesos", totalRegular + totalExtra),
            new Font(Font.FontFamily.HELVETICA, 18, Font.BOLD, new BaseColor(0x000000)));
    heading5.setSpacingBefore(16f);
    heading5.setSpacingAfter(16f);
    documento.add(heading5);
    documento.close();
}