Example usage for com.itextpdf.text Chunk NEWLINE

List of usage examples for com.itextpdf.text Chunk NEWLINE

Introduction

In this page you can find the example usage for com.itextpdf.text Chunk NEWLINE.

Prototype

Chunk NEWLINE

To view the source code for com.itextpdf.text Chunk NEWLINE.

Click Source Link

Document

This is a Chunk containing a newline.

Usage

From source file:managedBeans.RelatorioGeralBean.java

public void printToPDF() {
    System.out.println("criando relatorio geral");
    ExternalContext context = FacesContext.getCurrentInstance().getExternalContext();
    HttpServletRequest request = (HttpServletRequest) context.getRequest();
    Professor professor = (Professor) request.getSession().getAttribute("user");
    DateFormat dateFormat = new SimpleDateFormat("ddMMyyyy");
    Date date = new Date();
    String filePath = System.getProperty("user.home") + "\\Desktop\\RelatorioGeral" + dateFormat.format(date)
            + ".pdf";
    try {//  w w w.  ja v  a2 s  .  c o m
        Document document = new Document();
        PdfWriter.getInstance(document, new FileOutputStream(filePath));
        document.open();
        pdfWriter.addTitlePageProfessor(document, "Relatorio Geral", professor.getNome());
        document.add(Chunk.NEWLINE);
        pdfWriter.createTableGeral(document, listaAlunos);
        pdfWriter.addNumbers(document, listaAlunos.size(), listaProfessores.size(), listaExercicios.size(),
                listaFichas.size());
        document.close();

        File file = new File(filePath);
        HttpServletResponse response = (HttpServletResponse) context.getResponse();

        response.reset();
        response.setHeader("Content-Disposition", "attachment;filename=RelatorioGeral.pdf");
        response.setContentLength((int) file.length());
        ServletOutputStream out = null;
        try {
            FileInputStream input = new FileInputStream(file);
            byte[] buffer = new byte[1024];
            out = response.getOutputStream();
            int i = 0;
            while ((i = input.read(buffer)) != -1) {
                out.write(buffer);
                out.flush();
            }
            FacesContext.getCurrentInstance().getResponseComplete();
        } catch (IOException err) {
            err.printStackTrace();
        } finally {
            try {
                if (out != null) {
                    out.close();
                }
            } catch (IOException err) {
                err.printStackTrace();
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:net.sf.texprinter.generators.PDFGenerator.java

License:Open Source License

/**
 * Generates a PDF file from a Question object.
 * //from www .  j a  v a  2 s. com
 * @param question The question.
 * @param filename The filename.
 */
public static void generate(Question question, String filename) {

    // wait window
    ProgressMessage pm = new ProgressMessage("TeXPrinter is printing your PDF file.");

    // start wait window
    //pm.start();

    // log message
    log.log(Level.INFO, "Starting PDF generation of {0}.", filename);

    // define a new PDF document
    Document document = null;

    // define a new PDF writer
    PdfWriter writer = null;

    // lets try
    try {

        // create a new PDF document
        document = new Document();

        // define a new PDF Writer
        writer = PdfWriter.getInstance(document, new FileOutputStream(filename));

        // set the PDF version
        writer.setPdfVersion(PdfWriter.VERSION_1_6);

        // open the document
        document.open();

        // set the title font
        Font titleFont = new Font(FontFamily.HELVETICA, 16, Font.BOLD, BaseColor.BLACK);

        // set the chunk for the question title
        Chunk questionTitle = new Chunk(question.getQuestion().getTitle(), titleFont);

        // create a paragraph from that chunk
        Paragraph paragraphQuestionTitle = new Paragraph(questionTitle);

        // log message
        log.log(Level.INFO, "Adding the question title.");

        // add the question title to the document
        document.add(paragraphQuestionTitle);

        // set the asker font
        Font askerFont = new Font(FontFamily.HELVETICA, 10, Font.ITALIC, BaseColor.DARK_GRAY);

        // set the chunk for the asker
        Chunk questionAsker = new Chunk("Asked by " + question.getQuestion().getUser().getName() + " ("
                + question.getQuestion().getUser().getReputation() + ") on " + question.getQuestion().getDate()
                + " (" + String.valueOf(question.getQuestion().getVotes())
                + (question.getQuestion().getVotes() == 1 ? " vote" : " votes") + ")", askerFont);

        // create a paragraph from that chunk
        Paragraph paragraphQuestionAsker = new Paragraph(questionAsker);

        // log message
        log.log(Level.INFO, "Adding both asker and reputation.");

        // add the asker to the document
        document.add(paragraphQuestionAsker);

        // create a line separator
        LineSeparator line = new LineSeparator(1, 100, null, Element.ALIGN_CENTER, -5);

        // add the line to the document
        document.add(line);

        // add a new line
        document.add(Chunk.NEWLINE);

        // create a list of elements from the question objects
        List<Element> questionTextObjects = getPostText(question.getQuestion().getText());

        // log message
        log.log(Level.INFO, "Adding the question text.");

        // for each element
        for (Element questionTextObject : questionTextObjects) {

            // add it to the document
            document.add(questionTextObject);
        }

        // add a new line
        document.add(Chunk.NEWLINE);

        // create a new font for the comments title
        Font commentsTitleFont = new Font(FontFamily.HELVETICA, 12, Font.BOLD, BaseColor.BLACK);

        // create a new chunk based on that font
        Chunk commentsTitle = new Chunk(
                "This question has " + question.getQuestion().getComments().size()
                        + ((question.getQuestion().getComments().size() == 1) ? " comment:" : " comments:"),
                commentsTitleFont);

        // create a paragraph from that chunk
        Paragraph paragraphCommentsTitle = new Paragraph(commentsTitle);

        // if there are comments to this question
        if (!question.getQuestion().getComments().isEmpty()) {

            // log message
            log.log(Level.INFO, "Adding the question comments.");

            // add that paragraph to the document
            document.add(paragraphCommentsTitle);

            // add a new line
            document.add(Chunk.NEWLINE);

            // get all the comments
            List<Comment> questionComments = question.getQuestion().getComments();

            // for each comment
            for (Comment questionComment : questionComments) {

                // get the elements of the comment text
                List<Element> questionCommentObjects = getPostText(questionComment.getText());

                // for each element
                for (Element questionCommentObject : questionCommentObjects) {

                    // add it to the document
                    document.add(questionCommentObject);
                }

                // create a new paragraph about the comment author
                Paragraph paragraphCommentAuthor = new Paragraph(questionComment.getAuthor() + " on "
                        + questionComment.getDate() + " (" + String.valueOf(questionComment.getVotes())
                        + (questionComment.getVotes() == 1 ? " vote" : " votes") + ")", askerFont);

                // set the alignment to the right
                paragraphCommentAuthor.setAlignment(Element.ALIGN_RIGHT);

                // add the paragraph to the document
                document.add(paragraphCommentAuthor);

                // add a new line
                document.add(Chunk.NEWLINE);
            }
        }

        // add a line separator
        document.add(line);

        // add two new lines
        document.add(Chunk.NEWLINE);
        document.add(Chunk.NEWLINE);

        // get the list of answers
        List<Post> answersList = question.getAnswers();

        // if there are no answers
        if (answersList.isEmpty()) {

            // log message
            log.log(Level.INFO, "This question has no answers.");

            // create a new chunk
            Chunk noAnswersTitle = new Chunk("Sorry, this question has no answers yet.", titleFont);

            // create a paragraph from that chunk
            Paragraph paragraphNoAnswersTitle = new Paragraph(noAnswersTitle);

            // add the paragraph to the document
            document.add(paragraphNoAnswersTitle);

        } else {

            // log message
            log.log(Level.INFO, "Adding answers.");

            // there are answers, so create a counter for answers
            int answerCount = 1;

            // for each answer
            for (Post answer : answersList) {

                // log message
                log.log(Level.INFO, "Adding answer {0}.", answerCount);

                // set the message text as empty
                String answerAccepted = "";

                // if the answer is accepted
                if (answer.isAccepted()) {

                    // add that to the message
                    answerAccepted = " - Marked as accepted.";
                }

                // create a new chunk
                Chunk answerTitle = new Chunk("Answer #" + answerCount, titleFont);

                // create a paragraph from that chunk
                Paragraph paragraphAnswerTitle = new Paragraph(answerTitle);

                // add the paragraph to the document
                document.add(paragraphAnswerTitle);

                // increase the counter
                answerCount++;

                // create a new chunk
                Chunk questionAnswerer = new Chunk("Answered by " + answer.getUser().getName() + " ("
                        + answer.getUser().getReputation() + ") on " + answer.getDate() + answerAccepted + " ("
                        + String.valueOf(answer.getVotes()) + (answer.getVotes() == 1 ? " vote" : " votes")
                        + ")", askerFont);

                // create a paragraph from that chunk
                Paragraph paragraphQuestionAnswerer = new Paragraph(questionAnswerer);

                // add that paragraph to the document
                document.add(paragraphQuestionAnswerer);

                // add a line separator
                document.add(line);

                // add a new line
                document.add(Chunk.NEWLINE);

                // create a list of elements from the answer text
                List<Element> answerTextObjects = getPostText(answer.getText());

                // for each element
                for (Element answerTextObject : answerTextObjects) {

                    // add it to the document
                    document.add(answerTextObject);
                }

                // add a new line
                document.add(Chunk.NEWLINE);

                // create a new font style
                Font answerCommentsTitleFont = new Font(FontFamily.HELVETICA, 12, Font.BOLD, BaseColor.BLACK);

                // create a new chunk
                Chunk answerCommentsTitle = new Chunk(
                        "This answer has " + answer.getComments().size()
                                + ((answer.getComments().size() == 1) ? " comment:" : " comments:"),
                        answerCommentsTitleFont);

                // create a paragraph from that chunk
                Paragraph paragraphAnswerCommentsTitle = new Paragraph(answerCommentsTitle);

                // if there are comments for that answer
                if (!answer.getComments().isEmpty()) {

                    // log message
                    log.log(Level.INFO, "Adding comments for answer {0}.", (answerCount - 1));

                    // add that paragraph to the document
                    document.add(paragraphAnswerCommentsTitle);

                    // add a new line
                    document.add(Chunk.NEWLINE);

                    // get all the comments
                    List<Comment> answerComments = answer.getComments();

                    // for each comment
                    for (Comment answerComment : answerComments) {

                        // create a list of elements from the comment text
                        List<Element> answerCommentObjects = getPostText(answerComment.getText());

                        // for each element
                        for (Element answerCommentObject : answerCommentObjects) {

                            // add it to the document
                            document.add(answerCommentObject);
                        }

                        // create a new paragraph for the comment author
                        Paragraph paragraphAnswerCommentAuthor = new Paragraph(
                                answerComment.getAuthor() + " on " + answerComment.getDate() + " ("
                                        + String.valueOf(answerComment.getVotes())
                                        + (answerComment.getVotes() == 1 ? " vote" : " votes") + ")",
                                askerFont);

                        // set the aligment to the right
                        paragraphAnswerCommentAuthor.setAlignment(Element.ALIGN_RIGHT);

                        // add the paragraph to the document
                        document.add(paragraphAnswerCommentAuthor);

                        // add a new line
                        document.add(Chunk.NEWLINE);
                    }
                }

                // add a line separator
                document.add(line);

                // add two new lines
                document.add(Chunk.NEWLINE);
                document.add(Chunk.NEWLINE);
            }
        }

        // log message
        log.log(Level.INFO, "PDF generation complete, closing {0}.", filename);

        // close the document
        document.close();

        // stop wait window
        pm.interrupt();

    } catch (IOException ioexception) {

        // stop wait window
        pm.interrupt();

        // log message
        log.log(Level.SEVERE, "An IO error occurred while trying to create the PDF file. MESSAGE: {0}",
                StringUtils.printStackTrace(ioexception));

        // critical error, exit
        Dialogs.showExceptionWindow();

    } catch (Exception exception) {

        // log message
        log.log(Level.SEVERE, "A generic error occurred while trying to create the PDF file. MESSAGE: {0}",
                StringUtils.printStackTrace(exception));

        // log message
        log.log(Level.INFO, "I will try to remove the remaining PDF file.");

        try {

            // log message
            log.log(Level.INFO, "Closing both document and writer.");

            // close the document
            document.close();

            // close the writer
            writer.close();

        } catch (Exception ex) {

            // log message
            log.log(Level.WARNING, "I could not close either document or writer. MESSAGE: {0}",
                    StringUtils.printStackTrace(ex));
        }

        try {

            // reference problematic file
            File target = new File(filename);

            // log message
            log.log(Level.INFO, "Opening problematic file {0}.", filename);

            // check if file exists
            if (target.exists()) {

                // log message
                log.log(Level.INFO, "File exists, trying to delete it.");

                // trying to remove it
                if (target.delete()) {

                    // log message
                    log.log(Level.INFO, "File {0} was successfully removed.", filename);

                } else {

                    // log message
                    log.log(Level.SEVERE, "File {0} could not be removed.", filename);

                }
            }
        } catch (SecurityException se) {

            // log message
            log.log(Level.SEVERE, "A security exception was raised. MESSAGE: {0}",
                    StringUtils.printStackTrace(se));

        }

        // stop wait window
        pm.interrupt();

        // critical error, exit
        Dialogs.showExceptionWindow();

    }
}

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

License:Apache License

/**
 * Export a report to a pdf file.//w  w w.  j  a  v  a 2  s  .  co  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:nl.infosys.hartigehap.barSystem.domain.Bon.java

/**
 * Creates a PDF document.//from w ww. jav  a 2  s  . co m
 *
 * @param filename the path to the new PDF document
 * @throws DocumentException
 * @throws IOException
 */
private void create() {
    try {

        Document document = new Document(PageSize.A4);

        PdfWriter.getInstance(document, new FileOutputStream(file));

        document.open();

        document.add(header());

        document.add(Chunk.NEWLINE);

        document.add(table());

        document.setMargins(0, 0, 0, 100);

        document.close();

    } catch (Exception e) {
        System.out.println(e.getMessage());
    }
}

From source file:nl.infosys.hartigehap.barSystem.presentation.BonGui.java

/**
 * Creates a PDF document.//from  www  .  j  a  va  2 s. c o  m
 *
 * @param filename the path to the new PDF document
 * @throws DocumentException
 * @throws IOException
 */
private void createPdf() {
    try {

        Document document = new Document(PageSize.A4);

        PdfWriter.getInstance(document, new FileOutputStream(file));

        document.open();

        document.add(header());

        document.add(Chunk.NEWLINE);

        document.add(table());

        document.setMargins(0, 0, 0, 100);

        document.close();

    } catch (Exception e) {
        System.out.println(e.getMessage());
    }
}

From source file:org.fossa.rolp.util.PdfStreamSource.java

License:Open Source License

private void addFooter(LebData lebData, PdfWriter writer) throws DocumentException, PdfFormatierungsException {
    int footerMargin = 0;
    if (lebData.getSchulhalbjahr().isErstesHalbjahr()) {
        footerMargin = bottomMargin + 85;
    } else {//from   w  w w. ja v a  2s  .  c o  m
        footerMargin = bottomMargin + 170;
    }
    alertLonelyFooter(writer, footerMargin);
    while (writer.getVerticalPosition(false) > (footerMargin + 20)) {
        document.add(Chunk.NEWLINE);
    }
    float footerBegin = writer.getVerticalPosition(false);
    Paragraph footerTopParagraph = new Paragraph();
    footerTopParagraph.setLeading(1, 0.4f);
    footerTopParagraph.add(Chunk.NEWLINE);
    footerTopParagraph.add(Chunk.NEWLINE);

    Paragraph footerBottompParagraph = new Paragraph();
    footerBottompParagraph.setLeading(1, 0.4f);

    if (lebData.getSchulhalbjahr().isErstesHalbjahr()) {
        footerTopParagraph
                .add(PdfFormatHelper.buildFooterHalbjahrDatumLine(lebData.getDatumString(), footerFont));
        footerTopParagraph.add(PdfFormatHelper.buildFooterHalbjahrDatumKlassenleiterLine(footerFont));
    } else {
        footerTopParagraph.add(
                PdfFormatHelper.buildFooterVersetzungsvermerkLine(lebData.getVersetzungsvermerk(), footerFont));
        footerTopParagraph.add(Chunk.NEWLINE);
        footerTopParagraph.add(PdfFormatHelper.buildFooterDatumLine(lebData.getDatumString(), footerFont));
        document.add(footerTopParagraph);
        while (writer.getVerticalPosition(false) > (footerBegin - 82)) {
            document.add(Chunk.NEWLINE);
        }
        footerBottompParagraph.add(PdfFormatHelper.buildFooterDienstsiegelLine(footerFont));
        footerBottompParagraph.add(Chunk.NEWLINE);
        footerBottompParagraph.add(PdfFormatHelper.buildFooterUnterschriftenLine(footerFont));
    }
    footerBottompParagraph.add(Chunk.NEWLINE);
    footerBottompParagraph.add(Chunk.NEWLINE);
    footerBottompParagraph.add(Chunk.NEWLINE);
    footerBottompParagraph.add(PdfFormatHelper.buildFooterKenntnisLine(footerFont));
    document.add(footerBottompParagraph);
}

From source file:org.fossa.rolp.util.PdfStreamSource.java

License:Open Source License

private void addContent(PdfWriter writer) throws DocumentException, PdfFormatierungsException {
    Anchor anchor = new Anchor("Lernentwicklungsbericht", lernentwicklungsberichtUeberschriftFont);
    Chapter chapterLEB = new Chapter(new Paragraph(anchor), 1);
    chapterLEB.setNumberDepth(0);//from   w  w w.j av a2s  . c  o  m
    Paragraph paragraphHeader = new Paragraph();
    paragraphHeader.setLeading(FIXED_LEADING_TEXT, 1);
    sectionCount += 1;
    Section headerSection = chapterLEB.addSection(paragraphHeader);
    headerSection.setNumberDepth(0);

    paragraphHeader.add(Chunk.NEWLINE);
    paragraphHeader.add(PdfFormatHelper.buildHeaderNameLine(lebData.getSchuelername(), headerFont));
    paragraphHeader.add(Chunk.NEWLINE);
    paragraphHeader.add(PdfFormatHelper.buildHeaderKlassendatenLine(lebData, headerFont));
    headerSection.add(Chunk.NEWLINE);
    headerSection.add(Chunk.NEWLINE);
    document.add(chapterLEB);
    insertDummyLineIfNecessary(writer);

    addKlassenbrief(chapterLEB, writer);
    addIndividuelleEinschaetzung(chapterLEB, writer);
    addFacheinschaetzungen(chapterLEB, writer);
}

From source file:org.fossa.rolp.util.PdfStreamSource.java

License:Open Source License

private void addFacheinschaetzungen(Chapter chapterLEB, PdfWriter writer)
        throws DocumentException, PdfFormatierungsException {
    for (LebFacheinschaetzungData facheinschaetzungsdaten : lebData.getFacheinschaetzungsdaten()) {
        sectionCount += 1;/* w  ww .j av a  2 s  .  com*/
        breakHurenkind(writer);
        breakSchusterjunge(writer);
        Paragraph paragraphFacheinschaetzung = new Paragraph();
        Section facheinschaetzungsTextSection = chapterLEB.addSection(paragraphFacheinschaetzung);
        facheinschaetzungsTextSection.setNumberDepth(0);
        Collection<String> fachbezeichnungen = facheinschaetzungsdaten.getFachbezeichnungen();
        fachbezeichnungen.add(facheinschaetzungsdaten.getFachname());

        String facheinschaetzung = facheinschaetzungsdaten.getFacheinschaetzung();

        Integer firstIndex = null;
        String boldedWord = "";
        for (String fachbezeichnung : fachbezeichnungen) {
            int index = facheinschaetzung.toLowerCase().indexOf(fachbezeichnung.toLowerCase());
            if (index != -1 && (firstIndex == null || firstIndex > index)) {
                firstIndex = index;
                boldedWord = fachbezeichnung;
            }
        }
        Paragraph facheinschaetzungParapgraph = new Paragraph();
        facheinschaetzungParapgraph.setAlignment(Element.ALIGN_JUSTIFIED);
        facheinschaetzungParapgraph.setLeading(FIXED_LEADING_TEXT, zeilenabstandsfaktor);
        if (firstIndex == null) {
            facheinschaetzungParapgraph.add(new Phrase(
                    facheinschaetzungsdaten.getFacheinschaetzung().replace('\t', '\0'), standardTextFont));
        } else {
            String beforeBoldWord = facheinschaetzung.substring(0, firstIndex);
            facheinschaetzungParapgraph.add(new Phrase(beforeBoldWord.replace('\t', '\0'), standardTextFont));

            String boldWord = facheinschaetzung.substring(firstIndex, firstIndex + boldedWord.length());
            facheinschaetzungParapgraph.add(new Phrase(boldWord, standardTextBoldFont));

            String afterBoldWord = facheinschaetzung.substring(firstIndex + boldedWord.length());
            facheinschaetzungParapgraph.add(new Phrase(afterBoldWord.replace('\t', '\0'), standardTextFont));
        }
        facheinschaetzungParapgraph.setFont(standardTextFont);
        facheinschaetzungsTextSection.add(facheinschaetzungParapgraph);
        Paragraph unterschriftParagraph = new Paragraph();
        document.add(facheinschaetzungsTextSection);
        Section facheinschaetzungsUnterschriftSection = chapterLEB.addSection(unterschriftParagraph);
        facheinschaetzungsUnterschriftSection.setNumberDepth(0);
        unterschriftParagraph.add(
                new Phrase(facheinschaetzungsdaten.getUnterschrift().replace('\t', '\0'), standardTextFont));
        unterschriftParagraph.setAlignment(Element.ALIGN_RIGHT);
        unterschriftParagraph.add(Chunk.NEWLINE);
        unterschriftParagraph.add(Chunk.NEWLINE);
        document.add(facheinschaetzungsUnterschriftSection);
        alertHurenkind(writer);
        insertDummyLineIfNecessary(writer);
    }
}

From source file:org.fossa.rolp.util.PdfStreamSource.java

License:Open Source License

private void addKlassenbrief(Chapter chapterLEB, PdfWriter writer)
        throws DocumentException, PdfFormatierungsException {
    if (!lebData.getKlassenbrief().isEmpty()) {
        sectionCount += 1;/*from  ww w .j  a va  2s.  co m*/
        breakSchusterjunge(writer);
        Paragraph paragraphKlassenbrief = new Paragraph();
        Section klassenbriefSection = chapterLEB.addSection(paragraphKlassenbrief);
        klassenbriefSection.setNumberDepth(0);
        Paragraph klasseneinschaetzungParapgraph = new Paragraph(lebData.getKlassenbrief().replace('\t', '\0'),
                standardTextFont);
        klasseneinschaetzungParapgraph.setAlignment(Element.ALIGN_JUSTIFIED);
        klasseneinschaetzungParapgraph.setLeading(FIXED_LEADING_TEXT, zeilenabstandsfaktor);
        klasseneinschaetzungParapgraph.add(Chunk.NEWLINE);
        if (lebData.getIndividuelleEinschaetzung().isEmpty()) {
            klassenbriefSection.add(klasseneinschaetzungParapgraph);
            document.add(klassenbriefSection);
            document.add(getKlassenlehrerunterschrift(chapterLEB));
        } else {
            klasseneinschaetzungParapgraph.add(Chunk.NEWLINE);
            klassenbriefSection.add(klasseneinschaetzungParapgraph);
            document.add(klassenbriefSection);
        }
        alertLonelyHeader(writer);
        insertDummyLineIfNecessary(writer);
    }
}

From source file:org.fossa.rolp.util.PdfStreamSource.java

License:Open Source License

private Section getKlassenlehrerunterschrift(Section chapterLEB) {
    Paragraph unterschriftParagraph = new Paragraph();
    Section klassenbriefUnterschriftSection = chapterLEB.addSection(unterschriftParagraph);
    klassenbriefUnterschriftSection.setNumberDepth(0);
    unterschriftParagraph//from   w  w  w  .  j a  v  a  2 s . c om
            .add(new Phrase(lebData.getKlassenlehrerUnterschrift().replace('\t', '\0'), standardTextFont));
    unterschriftParagraph.setAlignment(Element.ALIGN_RIGHT);
    unterschriftParagraph.add(Chunk.NEWLINE);
    unterschriftParagraph.add(Chunk.NEWLINE);
    return klassenbriefUnterschriftSection;
}