Example usage for com.lowagie.text Paragraph setAlignment

List of usage examples for com.lowagie.text Paragraph setAlignment

Introduction

In this page you can find the example usage for com.lowagie.text Paragraph setAlignment.

Prototype

public void setAlignment(String alignment) 

Source Link

Document

Sets the alignment of this paragraph.

Usage

From source file:fr.paris.lutece.plugins.directory.modules.pdfproducer.utils.PDFUtils.java

License:Open Source License

/**
 * method to create PDF/*from  w w  w.  j  a  v  a 2s . com*/
 * @param adminUser The admin user
 * @param locale The locale
 * @param strNameFile PDF name
 * @param out OutputStream
 * @param nIdRecord the id record
 * @param listIdEntryConfig list of config id entry
 * @param bExtractNotFilledField if true, extract empty fields, false
 */
public static void doCreateDocumentPDF(AdminUser adminUser, Locale locale, String strNameFile, OutputStream out,
        int nIdRecord, List<Integer> listIdEntryConfig, Boolean bExtractNotFilledField) {
    Document document = new Document(PageSize.A4);

    Plugin plugin = PluginService.getPlugin(DirectoryPlugin.PLUGIN_NAME);

    EntryFilter filter;

    Record record = RecordHome.findByPrimaryKey(nIdRecord, plugin);

    filter = new EntryFilter();
    filter.setIdDirectory(record.getDirectory().getIdDirectory());
    filter.setIsGroup(EntryFilter.FILTER_TRUE);

    List<IEntry> listEntry = DirectoryUtils.getFormEntries(record.getDirectory().getIdDirectory(), plugin,
            adminUser);
    int nIdDirectory = record.getDirectory().getIdDirectory();
    Directory directory = DirectoryHome.findByPrimaryKey(nIdDirectory, plugin);

    try {
        PdfWriter.getInstance(document, out);
    } catch (DocumentException e) {
        AppLogService.error(e);
    }

    document.open();

    if (record.getDateCreation() != null) {
        SimpleDateFormat monthDayYearformatter = new SimpleDateFormat(
                AppPropertiesService.getProperty(PROPERTY_POLICE_FORMAT_DATE));

        Font fontDate = new Font(
                DirectoryUtils.convertStringToInt(AppPropertiesService.getProperty(PROPERTY_POLICE_NAME)),
                DirectoryUtils.convertStringToInt(AppPropertiesService.getProperty(PROPERTY_POLICE_SIZE_DATE)),
                DirectoryUtils
                        .convertStringToInt(AppPropertiesService.getProperty(PROPERTY_POLICE_STYLE_DATE)));

        Paragraph paragraphDate = new Paragraph(
                new Phrase(monthDayYearformatter.format(record.getDateCreation()).toString(), fontDate));

        paragraphDate.setAlignment(DirectoryUtils
                .convertStringToInt(AppPropertiesService.getProperty(PROPERTY_POLICE_ALIGN_DATE)));

        try {
            document.add(paragraphDate);
        } catch (DocumentException e) {
            AppLogService.error(e);
        }
    }

    Image image;

    try {

        image = Image.getInstance(ImageIO.read(new File(AppPathService
                .getAbsolutePathFromRelativePath(AppPropertiesService.getProperty(PROPERTY_IMAGE_URL)))), null);
        image.setAlignment(
                DirectoryUtils.convertStringToInt(AppPropertiesService.getProperty(PROPERTY_IMAGE_ALIGN)));
        float fitWidth;
        float fitHeight;

        try {
            fitWidth = Float.parseFloat(AppPropertiesService.getProperty(PROPERTY_IMAGE_FITWIDTH));
            fitHeight = Float.parseFloat(AppPropertiesService.getProperty(PROPERTY_IMAGE_FITHEIGHT));
        } catch (NumberFormatException e) {
            fitWidth = 100f;
            fitHeight = 100f;
        }

        image.scaleToFit(fitWidth, fitHeight);

        try {
            document.add(image);
        } catch (DocumentException e) {
            AppLogService.error(e);
        }
    } catch (BadElementException e) {
        AppLogService.error(e);
    } catch (MalformedURLException e) {
        AppLogService.error(e);
    } catch (IOException e) {
        AppLogService.error(e);
    }

    directory.getTitle();

    Font fontTitle = new Font(
            DirectoryUtils.convertStringToInt(AppPropertiesService.getProperty(PROPERTY_POLICE_NAME)),
            DirectoryUtils
                    .convertStringToInt(AppPropertiesService.getProperty(PROPERTY_POLICE_SIZE_TITLE_DIRECTORY)),
            DirectoryUtils.convertStringToInt(
                    AppPropertiesService.getProperty(PROPERTY_POLICE_STYLE_TITLE_DIRECTORY)));
    fontTitle.isUnderlined();

    Paragraph paragraphHeader = new Paragraph(new Phrase(directory.getTitle(), fontTitle));
    paragraphHeader.setAlignment(Element.ALIGN_CENTER);
    paragraphHeader.setSpacingBefore(DirectoryUtils.convertStringToInt(
            AppPropertiesService.getProperty(PROPERTY_POLICE_SPACING_BEFORE_TITLE_DIRECTORY)));
    paragraphHeader.setSpacingAfter(DirectoryUtils.convertStringToInt(
            AppPropertiesService.getProperty(PROPERTY_POLICE_SPACING_AFTER_TITLE_DIRECTORY)));

    try {
        document.add(paragraphHeader);
    } catch (DocumentException e) {
        AppLogService.error(e);
    }

    builderPDFWithEntry(document, plugin, nIdRecord, listEntry, listIdEntryConfig, locale,
            bExtractNotFilledField);
    document.close();
}

From source file:fr.paris.lutece.plugins.directory.modules.pdfproducer.utils.PDFUtils.java

License:Open Source License

/**
 * method to builder PDF with directory entry
 * @param document document pdf//from w w  w .  j  a va  2 s . c om
 * @param plugin plugin
 * @param nIdRecord id record
 * @param listEntry list of entry
 * @param listIdEntryConfig list of config id entry
 * @param locale the locale
 * @param bExtractNotFilledField if true, extract empty fields, false
 */
private static void builderPDFWithEntry(Document document, Plugin plugin, int nIdRecord, List<IEntry> listEntry,
        List<Integer> listIdEntryConfig, Locale locale, Boolean bExtractNotFilledField) {
    Map<String, List<RecordField>> mapIdEntryListRecordField = DirectoryUtils
            .getMapIdEntryListRecordField(listEntry, nIdRecord, plugin);

    for (IEntry entry : listEntry) {
        if (entry.getEntryType().getGroup() && (listIdEntryConfig.isEmpty()
                || listIdEntryConfig.contains(Integer.valueOf(entry.getIdEntry())))) {
            Font fontEntryTitleGroup = new Font(
                    DirectoryUtils.convertStringToInt(AppPropertiesService.getProperty(PROPERTY_POLICE_NAME)),
                    DirectoryUtils.convertStringToInt(
                            AppPropertiesService.getProperty(PROPERTY_POLICE_SIZE_ENTRY_GROUP)),
                    DirectoryUtils.convertStringToInt(
                            AppPropertiesService.getProperty(PROPERTY_POLICE_STYLE_ENTRY_GROUP)));
            Paragraph paragraphTitleGroup = new Paragraph(new Phrase(entry.getTitle(), fontEntryTitleGroup));
            paragraphTitleGroup.setAlignment(Element.ALIGN_LEFT);
            paragraphTitleGroup.setIndentationLeft(DirectoryUtils.convertStringToInt(
                    AppPropertiesService.getProperty(PROPERTY_POLICE_MARGIN_LEFT_ENTRY_GROUP)));
            paragraphTitleGroup.setSpacingBefore(DirectoryUtils.convertStringToInt(
                    AppPropertiesService.getProperty(PROPERTY_POLICE_SPACING_BEFORE_ENTRY_GROUP)));
            paragraphTitleGroup.setSpacingAfter(DirectoryUtils.convertStringToInt(
                    AppPropertiesService.getProperty(PROPERTY_POLICE_SPACING_AFTER_ENTRY_GROUP)));

            try {
                document.add(paragraphTitleGroup);
            } catch (DocumentException e) {
                AppLogService.error(e);
            }

            if (entry.getChildren() != null) {
                for (IEntry child : entry.getChildren()) {
                    if (listIdEntryConfig.isEmpty()
                            || listIdEntryConfig.contains(Integer.valueOf(child.getIdEntry()))) {
                        try {
                            builFieldsInPDF(mapIdEntryListRecordField.get(Integer.toString(child.getIdEntry())),
                                    document, child, locale, bExtractNotFilledField);
                        } catch (DocumentException e) {
                            AppLogService.error(e);
                        }
                    }
                }
            }
        } else {
            if (listIdEntryConfig.isEmpty()
                    || listIdEntryConfig.contains(Integer.valueOf(entry.getIdEntry()))) {
                try {
                    builFieldsInPDF(mapIdEntryListRecordField.get(Integer.toString(entry.getIdEntry())),
                            document, entry, locale, bExtractNotFilledField);
                } catch (DocumentException e) {
                    AppLogService.error(e);
                }
            }
        }
    }
}

From source file:fr.univlorraine.mondossierweb.controllers.InscriptionController.java

License:Apache License

/**
 * /*w  ww .  ja v  a  2 s .c om*/
 * @param document pdf
 */
public void creerPdfCertificatScolarite(final Document document, Etudiant etudiant, Inscription inscription) {

    //configuration des fonts
    Font normal = FontFactory.getFont(FontFactory.HELVETICA, 10, Font.NORMAL);
    Font normalBig = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD);
    Font header = FontFactory.getFont(FontFactory.HELVETICA, 14, Font.BOLD);

    //date
    Date d = new Date();
    DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
    String date = dateFormat.format(d);

    document.open();
    try {

        Signataire signataire = multipleApogeeService
                .getSignataire(configController.getCertScolCodeSignataire());

        // Ajout Bordeaux1
        if (configController.isCertScolUtiliseLogo()) {
            //ajout image test
            if (configController.getLogoUniversitePdf() != null
                    && !configController.getLogoUniversitePdf().equals("")) {
                Image imageLogo = Image.getInstance(configController.getLogoUniversitePdf());
                float scaleRatio = 40 / imageLogo.getHeight();
                float newWidth = scaleRatio * imageLogo.getWidth();
                imageLogo.scaleAbsolute(newWidth, 40);
                imageLogo.setAbsolutePosition(100, 750);
                document.add(imageLogo);
            } else if (configController.getCertScolHeaderUniv() != null
                    && !configController.getCertScolHeaderUniv().equals("")) {
                Image imageHeader = Image.getInstance(configController.getCertScolHeaderUniv());
                float scaleHeader = 600 / imageHeader.getWidth();
                float newHeigthHeader = scaleHeader * imageHeader.getHeight();
                imageHeader.scaleAbsolute(600, newHeigthHeader);
                imageHeader.setAbsolutePosition(0, 765);
                document.add(imageHeader);
            }

            if (configController.getCertScolFooter() != null
                    && !configController.getCertScolFooter().equals("")) {
                Image imageFooter = Image.getInstance(configController.getCertScolFooter());
                float scaleFooter = 600 / imageFooter.getWidth();
                float newHeigthFooter = scaleFooter * imageFooter.getHeight();
                imageFooter.scaleAbsolute(600, newHeigthFooter);
                imageFooter.setAbsolutePosition(0, 0);
                document.add(imageFooter);
            }
        }

        Paragraph pTitre = new Paragraph("\n\n" + applicationContext
                .getMessage("pdf.certificat.title", null, Locale.getDefault()).toUpperCase(), header);
        pTitre.setAlignment(Element.ALIGN_CENTER);
        document.add(pTitre);

        Paragraph pCertifie = new Paragraph("\n\n\n\n" + signataire.getQua_sig() + " "
                + applicationContext.getMessage("pdf.certificat.certifie", null, Locale.getDefault()) + "\n\n",
                normal);
        pCertifie.setAlignment(Element.ALIGN_LEFT);
        document.add(pCertifie);

        if (etudiant.getNom() != null) {
            String civ = multipleApogeeService.getCodCivFromCodInd(etudiant.getCod_ind());
            String civCertif = "";
            if (civ != null) {
                if (civ.equals("1")) {
                    civCertif = applicationContext.getMessage("pdf.certificat.civ1", null, Locale.getDefault());
                } else if (civ.equals("2")) {
                    civCertif = applicationContext.getMessage("pdf.certificat.civ2", null, Locale.getDefault());
                }
            }
            Paragraph pNom = new Paragraph(civCertif + " " + etudiant.getNom(), normalBig);
            pNom.setIndentationLeft(15);
            document.add(pNom);
        }
        if (etudiant.getCod_nne() != null) {
            Paragraph pNNE = new Paragraph(
                    "\n" + applicationContext.getMessage("pdf.certificat.id", null, Locale.getDefault()) + " : "
                            + etudiant.getCod_nne().toLowerCase(),
                    normal);
            pNNE.setAlignment(Element.ALIGN_LEFT);
            document.add(pNNE);
        }
        if (etudiant.getCod_etu() != null) {
            Paragraph p01 = new Paragraph(
                    applicationContext.getMessage("pdf.certificat.numetudiant", null, Locale.getDefault())
                            + " : " + etudiant.getCod_etu(),
                    normal);
            p01.setAlignment(Element.ALIGN_LEFT);
            document.add(p01);
        }
        if (etudiant.getDatenaissance() != null) {
            Paragraph pDateNaissance = new Paragraph(
                    applicationContext.getMessage("pdf.certificat.naissance1", null, Locale.getDefault()) + " "
                            + etudiant.getDatenaissance(),
                    normal);
            pDateNaissance.setAlignment(Element.ALIGN_LEFT);
            document.add(pDateNaissance);
        }
        if ((etudiant.getLieunaissance() != null) && (etudiant.getDepartementnaissance() != null)) {
            Paragraph pLieuNaissance = new Paragraph(
                    applicationContext.getMessage("pdf.certificat.naissance2", null, Locale.getDefault()) + " "
                            + etudiant.getLieunaissance() + " (" + etudiant.getDepartementnaissance() + ")",
                    normal);
            pLieuNaissance.setAlignment(Element.ALIGN_LEFT);
            document.add(pLieuNaissance);
        }

        String anneeEnCours = etudiantController.getAnneeUnivEnCoursToDisplay(MainUI.getCurrent());
        String inscritCertif = "";
        if (inscription.getCod_anu().equals(anneeEnCours)) {
            inscritCertif = applicationContext.getMessage("pdf.certificat.inscrit", null, Locale.getDefault());
        } else {
            inscritCertif = applicationContext.getMessage("pdf.certificat.ete.inscrit", null,
                    Locale.getDefault());
        }
        Paragraph pEstInscrit = new Paragraph("\n" + inscritCertif + " " + inscription.getCod_anu() + "\n ",
                normal);
        pEstInscrit.setAlignment(Element.ALIGN_LEFT);
        document.add(pEstInscrit);

        float[] widths = { 1.5f, 7.5f };
        PdfPTable table = new PdfPTable(widths);
        table.setWidthPercentage(100f);
        table.addCell(makeCell(applicationContext.getMessage("pdf.diplome", null, Locale.getDefault()) + " :",
                normal));
        table.addCell(makeCell(inscription.getLib_dip(), normal));
        table.addCell(
                makeCell(applicationContext.getMessage("pdf.year", null, Locale.getDefault()) + " :", normal));
        table.addCell(makeCell(inscription.getLib_etp(), normal));
        table.addCell(makeCell(
                applicationContext.getMessage("pdf.composante", null, Locale.getDefault()) + " :", normal));
        table.addCell(makeCell(inscription.getLib_comp(), normal));
        document.add(table);

        document.add(new Paragraph(" "));

        float[] widthsSignataire = { 2f, 1.3f };
        PdfPTable tableSignataire = new PdfPTable(widthsSignataire);
        tableSignataire.setWidthPercentage(100f);
        tableSignataire.addCell(makeCellSignataire("", normal));
        tableSignataire
                .addCell(makeCellSignataire(
                        applicationContext.getMessage("pdf.certificat.fait1", null, Locale.getDefault()) + " "
                                + configController.getCertScolLieuEdition() + applicationContext.getMessage(
                                        "pdf.certificat.fait2", null, Locale.getDefault())
                                + " " + date,
                        normal));
        tableSignataire.addCell(makeCellSignataire("", normal));
        tableSignataire.addCell(makeCellSignataire(signataire.getNom_sig(), normal));
        //ajout signature
        if (signataire.getImg_sig_std() != null && signataire.getImg_sig_std().length > 0) { //MODIF 09/10/2012
            tableSignataire.addCell(makeCellSignataire("", normal));
            LOG.debug(signataire.getImg_sig_std().toString());
            Image imageSignature = Image.getInstance(signataire.getImg_sig_std());

            float scaleRatio = 100 / imageSignature.getHeight();
            float newWidth = scaleRatio * imageSignature.getWidth();
            imageSignature.scaleAbsolute(newWidth, 100);
            imageSignature.setAbsolutePosition(350, 225);
            document.add(imageSignature);

        }

        document.add(tableSignataire);

        // Ajout tampon
        if (configController.getCertScolTampon() != null && !configController.getCertScolTampon().equals("")) {
            Image imageTampon = Image.getInstance(configController.getCertScolTampon());
            float scaleTampon = 100 / imageTampon.getWidth();
            float newHeigthTampon = scaleTampon * imageTampon.getHeight();
            imageTampon.scaleAbsolute(100, newHeigthTampon);
            imageTampon.setAbsolutePosition(415, 215);
            document.add(imageTampon);
        }

    } catch (BadElementException e) {
        LOG.error("Erreur  la gnration du certificat : BadElementException ", e);
    } catch (MalformedURLException e) {
        LOG.error("Erreur  la gnration du certificat : MalformedURLException ", e);
    } catch (IOException e) {
        LOG.error("Erreur  la gnration du certificat : IOException ", e);
    } catch (DocumentException e) {
        LOG.error("Erreur  la gnration du certificat : DocumentException ", e);
    }
    // step 6: fermeture du document.
    document.close();

}

From source file:geoportal.presentacion.beans.ReportesControlador.java

public void imprimirReporte() {
    //DateFormat dfDateFull = DateFormat.getDateInstance(DateFormat.FULL);
    try {//  w  w  w  .  ja  v a 2  s .co m

        //Generamos el archivo PDF
        String directorioArchivos;
        ServletContext ctx = (ServletContext) FacesContext.getCurrentInstance().getExternalContext()
                .getContext();
        directorioArchivos = ctx.getRealPath("/") + "reportes";
        String name = directorioArchivos + "/document-reporte.pdf";
        Document document = new Document();
        PdfWriter.getInstance(document, new FileOutputStream(name));
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(name));
        //PdfWriter writer = PdfWriter.getInstance(document,
        //new FileOutputStream("C:"));

        Paragraph paragraph = new Paragraph();
        Paragraph paragraph1 = new Paragraph();
        Paragraph paragraph2 = new Paragraph();

        //PdfPTable table = new PdfPTable(4);
        PdfPTable table1 = new PdfPTable(1);
        PdfPTable table2 = new PdfPTable(4);
        PdfPTable table3 = new PdfPTable(4);
        PdfPTable table5 = new PdfPTable(1);

        paragraph.add("\n\n\n\n\n\n\n");
        paragraph.setAlignment(Paragraph.ALIGN_CENTER);
        paragraph1.add("\n");
        paragraph1.setAlignment(Paragraph.ALIGN_CENTER);
        paragraph2.add("Total Denuncias:" + totalDenuncias);
        paragraph2.setAlignment(Paragraph.ALIGN_LEFT);

        //  Obtenemos una instancia de nuestro manejador de eventos
        MembreteHeaderiText header = new MembreteHeaderiText();
        //Asignamos el manejador de eventos al escritor.
        writer.setPageEvent(header);

        document.open();
        //            Chunk titulo = new Chunk(CHUNK, FontFactory.getFont(FontFactory.COURIER, 20, Font.UNDERLINE, BaseColor.BLACK));
        //
        //            titulo = new Chunk(IMAGE, FontFactory.getFont(FontFactory.COURIER, 20, Font.UNDERLINE, BaseColor.BLACK));
        //            document.add(titulo);
        //            Image foto = Image.getInstance(resources / ferrari.jpg?);
        //foto.scaleToFit(100, 100);        foto.setAlignment(Chunk.ALIGN_MIDDLE);

        //primera linea   
        PdfPCell cell5 = new PdfPCell(new Paragraph("VIOLENCIA INTRAFAMILIAR "));
        //segunda linea
        PdfPCell cell12 = new PdfPCell(new Paragraph("AO"));
        PdfPCell cell6 = new PdfPCell(new Paragraph("2010"));
        PdfPCell cell7 = new PdfPCell(new Paragraph("2011"));
        PdfPCell cell8 = new PdfPCell(new Paragraph("2012"));

        //tercera fila
        PdfPCell cell13 = new PdfPCell(new Paragraph("# DENUNCIAS"));
        PdfPCell cell9 = new PdfPCell(new Paragraph("" + lstVif2010.size()));
        PdfPCell cell10 = new PdfPCell(new Paragraph("" + lstVif2011.size()));
        PdfPCell cell11 = new PdfPCell(new Paragraph("" + lstVif_2012.size()));

        PdfPCell cell15 = new PdfPCell(new Paragraph("TOTAL DENUNCIAS:" + totalDenuncias));

        cell5.setHorizontalAlignment(Element.ALIGN_CENTER);

        cell6.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell7.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell8.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell9.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell10.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell11.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell12.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell13.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell15.setHorizontalAlignment(Element.ALIGN_LEFT);

        cell12.setBackgroundColor(Color.cyan);
        cell13.setBackgroundColor(Color.cyan);

        cell5.setBorder(Rectangle.NO_BORDER);
        cell15.setBorder(Rectangle.NO_BORDER);

        table1.addCell(cell5);
        //aadir segunda fila
        table2.addCell(cell12);
        table2.addCell(cell6);
        table2.addCell(cell7);
        table2.addCell(cell8);
        //aadir tercera fila
        table3.addCell(cell13);
        table3.addCell(cell9);
        table3.addCell(cell10);
        table3.addCell(cell11);
        //aadir cuarta fila
        table5.addCell(cell15);

        document.add(paragraph);
        document.add(table1);
        document.add(paragraph1);
        document.add(table2);
        document.add(table3);
        document.add(table5);
        //document.add(paragraph2);

        //document.add(table);
        //document.setFooter(event);
        document.close();
        //----------------------------
        //Abrimos el archivo PDF
        FacesContext context = FacesContext.getCurrentInstance();
        HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse();
        response.setContentType("application/pdf");
        response.setHeader("Content-disposition", "inline=filename=" + name);
        try {
            response.getOutputStream().write(Util.getBytesFromFile(new File(name)));
            response.getOutputStream().flush();
            response.getOutputStream().close();
            context.responseComplete();

        } catch (IOException e) {
            e.printStackTrace();
        }

    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:gov.utah.health.uper.reports.Registration.java

/**
 * Builds Header Information/*ww w . j  ava  2 s  .co  m*/
 * @param document
 * @throws DocumentException
 */
private void buildHeader(Document document, ApplicationBean app) throws DocumentException {

    Paragraph preface = new Paragraph("Utah Plant Extract Registry", subFont12);
    preface.setAlignment(Element.ALIGN_CENTER);
    document.add(preface);

    preface = new Paragraph("Issue Date:  ", subFont12);
    preface.add(app.getIssuedDate());
    preface.setAlignment(Element.ALIGN_CENTER);
    document.add(preface);

    preface = new Paragraph("Expiration Date:  ", subFont12);
    preface.add(app.getExpirationDate());

    preface.setAlignment(Element.ALIGN_CENTER);
    document.add(preface);

    preface = new Paragraph("Registration Number: ", subFont12);
    preface.add(app.getStateFileNumber());
    preface.setAlignment(Element.ALIGN_CENTER);
    document.add(preface);
    addSpacing(document);

}

From source file:gov.utah.health.uper.reports.Registration.java

private void buildPatient(Document document, PatientBean pt) throws DocumentException {
    Paragraph preface = new Paragraph(PATIENT, normalFontBold);
    preface.setAlignment(Element.ALIGN_LEFT);
    document.add(preface);/* w w  w .j  a v  a 2  s  .c o  m*/

    preface = new Paragraph("Name: ", normalFontBold);
    preface.add(pt.getFirstName() + " " + pt.getLastName());
    preface.setAlignment(Element.ALIGN_LEFT);
    document.add(preface);

    preface = new Paragraph("Date of Birth: ", normalFontBold);
    preface.add(pt.getDob());
    preface.setAlignment(Element.ALIGN_LEFT);
    document.add(preface);

    preface = new Paragraph("Address: ", normalFontBold);
    preface.setAlignment(Element.ALIGN_LEFT);
    StringBuilder sb = new StringBuilder(pt.getAddressCurrent());
    sb.append(" ");
    sb.append(pt.getCityCurrent());
    sb.append(", ");
    sb.append(pt.getStateCurrent());
    sb.append(" ");
    sb.append(pt.getZipCurrent());

    preface.add(sb.toString());
    document.add(preface);
    addSpacing(document);

}

From source file:gov.utah.health.uper.reports.Registration.java

private void buildParent(Document document, PatientBean pt) throws DocumentException {
    Paragraph preface = new Paragraph(PARENT, normalFontBold);
    preface.setAlignment(Element.ALIGN_LEFT);
    document.add(preface);/*from   w  w  w  . ja va2  s .com*/

    preface = new Paragraph("Name: ", normalFontBold);
    preface.add(pt.getParentFirstName() + " " + pt.getParentLastName());
    preface.setAlignment(Element.ALIGN_LEFT);
    document.add(preface);

    preface = new Paragraph("Date of Birth: ", normalFontBold);
    preface.add(pt.getParentDob());
    preface.setAlignment(Element.ALIGN_LEFT);
    document.add(preface);

    preface = new Paragraph("Address: ", normalFontBold);
    StringBuilder sb = new StringBuilder(pt.getParentAddressCurrent());
    sb.append(" ");
    sb.append(pt.getParentCityCurrent());
    sb.append(", ");
    sb.append(pt.getParentStateCurrent());
    sb.append(" ");
    sb.append(pt.getParentZipCurrent());

    preface.add(sb.toString());

    preface.setAlignment(Element.ALIGN_LEFT);
    document.add(preface);
    addSpacing(document);

}

From source file:gov.utah.health.uper.reports.Registration.java

private void buildPhysician(Document document, PatientBean pt) throws DocumentException {
    Paragraph preface = new Paragraph(PHYSICIAN, normalFontBold);
    preface.setAlignment(Element.ALIGN_LEFT);
    document.add(preface);//from  w  w w  .  ja va 2 s.c o m

    preface = new Paragraph("Name and Title: ", normalFontBold);
    preface.setAlignment(Element.ALIGN_LEFT);
    preface.add(pt.getPhysicianName());
    document.add(preface);

    preface = new Paragraph("Utah License Number: ", normalFontBold);
    preface.add(pt.getDoplNumber());
    preface.setAlignment(Element.ALIGN_LEFT);
    document.add(preface);

    preface = new Paragraph("Expiration Date: ", normalFontBold);
    preface.setAlignment(Element.ALIGN_LEFT);
    preface.add(pt.getLicenseExpireDate());
    document.add(preface);
    addSpacing(document);

}

From source file:gov.utah.health.uper.reports.Registration.java

/**
 * Builds Footer Information//from w w  w .j  a  v  a 2s  . com
 * @param document
 * @throws DocumentException
 */
private void buildFooter(Document document) throws DocumentException {

    Paragraph preface = new Paragraph(FOOTER, footerFont);
    preface.setAlignment(Element.ALIGN_CENTER);
    document.add(preface);
    document.add(Chunk.NEWLINE);
    preface = new Paragraph(FOOTER_WARN, footerFontBold);
    preface.setAlignment(Element.ALIGN_CENTER);
    document.add(preface);

    preface = new Paragraph(FOOTER_WARNING, footerFontBold);
    preface.setAlignment(Element.ALIGN_CENTER);
    document.add(preface);

}

From source file:io.vertigo.dynamo.plugins.export.rtf.RTFExporter.java

License:Apache License

/** {@inheritDoc} */
@Override/*from   w  ww. ja  v  a2  s  .  c  o m*/
protected void createWriter(final Document document, final OutputStream out) {
    // final RtfWriter2 writer =
    RtfWriter2.getInstance(document, out);
    // writer.setViewerPreferences(PdfWriter.PageLayoutTwoColumnLeft);

    // advanced page numbers : x/y
    final Font font = FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL);
    //-----
    final Paragraph footerParagraph = new Paragraph();
    footerParagraph.add(new RtfPageNumber(font));
    footerParagraph.add(new Phrase(" / ", font));
    footerParagraph.add(new RtfTotalPageNumber(font));
    footerParagraph.setAlignment(Element.ALIGN_CENTER);
    //-----
    final HeaderFooter footer = new RtfHeaderFooter(footerParagraph);
    footer.setBorder(Rectangle.TOP);
    document.setFooter(footer);
}