Example usage for com.lowagie.text Section setNumberDepth

List of usage examples for com.lowagie.text Section setNumberDepth

Introduction

In this page you can find the example usage for com.lowagie.text Section setNumberDepth.

Prototype

public void setNumberDepth(int numberDepth) 

Source Link

Document

Sets the depth of the sectionnumbers that will be shown preceding the title.

Usage

From source file:com.stratelia.webactiv.newsEdito.control.PdfGenerator.java

License:Open Source License

/**
 * Method declaration//  w ww  .j  a  va2s  . c  o  m
 * @param document
 * @param archiveDetail
 * @param publicationBm
 * @param langue
 * @see
 */
public static void addEditorial(Document document, NodeDetail archiveDetail, PublicationBm publicationBm,
        String langue) throws NewsEditoException {

    SilverTrace.info("NewsEdito", "PdfGenerator.addEditorial", "NewsEdito.MSG_ENTRY_METHOD");

    try {
        ResourceLocator message = new ResourceLocator(
                "com.stratelia.webactiv.newsEdito.multilang.newsEditoBundle", langue);
        Collection<PublicationDetail> pubList = publicationBm.getDetailsByFatherPK(archiveDetail.getNodePK());
        Iterator<PublicationDetail> i = pubList.iterator();

        if (i.hasNext()) {
            try {

                Font publicationFont = new Font(Font.HELVETICA, 18, Font.BOLD, new Color(0, 64, 64));
                Font titleFont = new Font(Font.HELVETICA, 24, Font.NORMAL, new Color(255, 255, 255));

                Paragraph cTitle = new Paragraph(message.getString("editorial"), titleFont);
                Chapter chapter = new Chapter(cTitle, 0);

                chapter.setNumberDepth(0);

                PublicationDetail detail = null;
                Paragraph name = null;
                Section subsection = null;
                Image img = null;
                while (i.hasNext()) {

                    detail = i.next();
                    name = new Paragraph(detail.getName(), publicationFont);
                    subsection = chapter.addSection(name, 0);

                    subsection.setNumberDepth(0);

                    if (detail.getDescription() != null) {
                        subsection.add(new Paragraph(detail.getDescription()));

                    }
                    if (detail.getImage() != null) {

                        String imagePath = FileRepositoryManager
                                .getAbsolutePath(detail.getPK().getComponentName()) + getImagePath()
                                + File.separator + detail.getImage();
                        try {
                            SilverTrace.info("NewsEdito", "PDFGenerator.addEditorial", "root.MSG_PARAM_VALUE",
                                    "imagePath = " + imagePath);
                            img = Image.getInstance(imagePath);
                        } catch (Exception e) {
                            SilverTrace.info("NewsEdito", "PDFGenerator.addEditorial",
                                    "NewsEdito.MSG_CANNOT_RETRIEVE_IMAGE", "imagePath = " + imagePath);
                        }
                        if (img == null) {
                            SilverTrace.info("NewsEdito", "PdfGenerator.addEditorial",
                                    "NewsEdito.MSG_CANNOT_RETRIEVE_IMAGE");
                        } else {
                            subsection.add(img);
                        }
                    }
                }
                document.add(chapter);

            } catch (DocumentException de) {
                SilverTrace.warn("NewsEdito", "PdfGenerator.addEditorial", "NewsEdito.EX_NO_EDITO_ADDED");
            }

        }
    } catch (Exception e) {
        throw new NewsEditoException("PdfGenerator.addEditorial", NewsEditoException.WARNING,
                "NewsEdito.EX_PROBLEM_TO_ADD_EDITO", e);
    }

}