Example usage for com.itextpdf.text.pdf PdfPTable setWidths

List of usage examples for com.itextpdf.text.pdf PdfPTable setWidths

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf PdfPTable setWidths.

Prototype

public void setWidths(final int relativeWidths[]) throws DocumentException 

Source Link

Document

Sets the relative widths of the table.

Usage

From source file:naprawa.praca.PracaController.java

public PdfPTable addTableCzescService(String rodzaj, RodzajUslugi usluga) {
    PdfPTable tableCzesc = new PdfPTable(3);
    try {/*from w  w w  .  jav a2 s.  co  m*/
        tableCzesc.setWidthPercentage(100);
        int[] width = { 8, 77, 15 };
        tableCzesc.setWidths(width);
        PdfPCell cell = getNewCell(rodzaj);
        cell.setColspan(10);
        cell.setBorder(PdfPCell.NO_BORDER);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        tableCzesc.addCell(cell);

        int i = 1;
        for (Object item : mapaUslug.get(usluga)) {
            Usluga czesc = ((Usluga) item);
            tableCzesc.addCell(getNewCell(i + "."));
            tableCzesc.addCell(getNewCell(czesc.getOpis()));
            tableCzesc.addCell(getNewCell(TO_Invoice.getWynikSumaKoszt(czesc.getKoszt()) + " z"));
            i++;
        }
    } catch (DocumentException ex) {
        Logger.getLogger(PracaController.class.getName()).log(Level.SEVERE, null, ex);
    }
    return tableCzesc;
}

From source file:om.edu.squ.squportal.portlet.tsurvey.dao.pdf.TeachingSurveyPdfImpl.java

License:Open Source License

/**
 * /*from  w w  w  . ja v a 2 s  . c om*/
 * method name  : getPdfSurveyAnalysis
 * @param object
 * @param semesterYear
 * @param questionByYear
 * @param questionSetNo
 * @param byos
 * @param inputStream
 * @param res
 * @return
 * @throws DocumentException
 * @throws IOException
 * TeachingSurveyPdfImpl
 * return type  : OutputStream
 * 
 * purpose      : Generate PDF content
 *
 * Date          :   Mar 28, 2016 7:21:04 PM
 */
public OutputStream getPdfSurveyAnalysis(Object object, String semesterYear, String questionByYear,
        int questionSetNo, ByteArrayOutputStream byos, InputStream inputStream, ResourceResponse res)
        throws DocumentException, IOException {

    Font font = FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, BaseColor.BLACK);

    PdfReader pdfTemplate = new PdfReader(inputStream);
    PdfStamper pdfStamper = new PdfStamper(pdfTemplate, byos);
    Survey survey = (Survey) object;
    String sectionNos = "";
    String seatsTaken = "";
    DecimalFormat formatter = new DecimalFormat("###.##");

    String RIGHT = Constants.RIGHT;
    String CENTER = Constants.CENTER;
    String LEFT = Constants.LEFT;

    pdfStamper.getAcroFields().setField("txtCourse", survey.getCourseCode() + " / " + survey.getCourseName());
    pdfStamper.getAcroFields().setField("txtCollegeName", survey.getCollegeName());

    for (SurveyResponse resp : survey.getSurveyResponses()) {
        sectionNos = sectionNos + resp.getSectionNo() + " ";
        seatsTaken = String.valueOf(resp.getSeatsTaken());
    }

    pdfStamper.getAcroFields().setField("txtSectionNo", sectionNos);
    pdfStamper.getAcroFields().setField("txtDepartmentName", survey.getDepartmentName());
    pdfStamper.getAcroFields().setField("txtEmpName", survey.getEmpName());
    pdfStamper.getAcroFields().setField("txtStudentRegistered", seatsTaken);

    pdfStamper.getAcroFields().setField("txtSemesterYear", semesterYear);

    pdfStamper.getAcroFields().setGenerateAppearances(true);

    /* ****************** */

    PdfPTable table = new PdfPTable(13);

    table.addCell(getPdfCell("", 2, 0, font, LEFT));
    table.addCell(getPdfCell(
            UtilProperty.getMessage("prop.course.teaching.survey.analysis.course.teaching.items", null), 2, 0,
            font, CENTER));
    table.addCell(
            getPdfCell(UtilProperty.getMessage("prop.course.teaching.survey.analysis.response.number", null), 0,
                    6, font, CENTER));
    table.addCell(getPdfCell(
            UtilProperty.getMessage("prop.course.teaching.survey.analysis.response.percentage", null), 2, 0,
            font, CENTER));
    table.addCell(getPdfCell(UtilProperty.getMessage("prop.course.teaching.survey.analysis.mean", null), 0, 4,
            font, CENTER));

    table.addCell(
            getPdfCell(UtilProperty.getMessage("prop.course.teaching.survey.analysis.disagree.strong", null), 0,
                    0, font, CENTER));
    table.addCell(getPdfCell(UtilProperty.getMessage("prop.course.teaching.survey.analysis.disagree", null), 0,
            0, font, CENTER));
    table.addCell(getPdfCell(UtilProperty.getMessage("prop.course.teaching.survey.analysis.agree", null), 0, 0,
            font, CENTER));
    table.addCell(getPdfCell(UtilProperty.getMessage("prop.course.teaching.survey.analysis.agree.strong", null),
            0, 0, font, CENTER));
    table.addCell(
            getPdfCell(UtilProperty.getMessage("prop.course.teaching.survey.analysis.applicable.not", null), 0,
                    0, font, CENTER));
    table.addCell(getPdfCell(UtilProperty.getMessage("prop.course.teaching.survey.analysis.total", null), 0, 0,
            font, CENTER));
    table.addCell(getPdfCell(UtilProperty.getMessage("prop.course.teaching.survey.analysis.sect", null), 0, 0,
            font, CENTER));
    table.addCell(getPdfCell(UtilProperty.getMessage("prop.course.teaching.survey.analysis.crs", null), 0, 0,
            font, CENTER));
    table.addCell(getPdfCell(UtilProperty.getMessage("prop.course.teaching.survey.analysis.dept", null), 0, 0,
            font, CENTER));
    table.addCell(getPdfCell(UtilProperty.getMessage("prop.course.teaching.survey.analysis.col", null), 0, 0,
            font, CENTER));

    /* ---------------------------------------------------------------------------- */
    table.addCell(getPdfCell("", 0, 0, font));
    table.addCell(getPdfCell(UtilProperty.getMessage("prop.course.teaching.survey.analysis.course.items", null),
            0, 12, font, CENTER));

    int cTotal = 0;
    float cPctVal = 0f;
    float cSectionMean = 0f;
    float cCourseMean = 0f;
    float cDepart = 0f;
    float cCollege = 0f;
    int rowCount = 0;

    for (SurveyResponse sures : survey.getSurveyResponses()) {
        for (Analysis analysis : sures.getAnalysisList()) {
            if (analysis.getQuestion().equals("Q2") || analysis.getQuestion().equals("Q14")
                    || analysis.getQuestion().equals(questionByYear)) {
                /***  First part    ***/
                table.addCell(getPdfCell(analysis.getQuestion(), 0, 0, font));
                table.addCell(
                        getPdfCell(
                                UtilProperty.getMessage("prop.course.teaching.survey.analysis.set"
                                        + questionSetNo + ".question" + analysis.getQuestionLabel(), null),
                                0, 0, font, LEFT));
                table.addCell(getPdfCell(String.valueOf(analysis.getStrongDisagree()), 0, 0, font, RIGHT));
                table.addCell(getPdfCell(String.valueOf(analysis.getDisAgree()), 0, 0, font, RIGHT));
                table.addCell(getPdfCell(String.valueOf(analysis.getAgree()), 0, 0, font, RIGHT));
                table.addCell(getPdfCell(String.valueOf(analysis.getStrongAgree()), 0, 0, font, RIGHT));
                table.addCell(getPdfCell(String.valueOf(analysis.getNotApplicable()), 0, 0, font, RIGHT));
                table.addCell(getPdfCell(String.valueOf(analysis.getTotal()), 0, 0, font, RIGHT));
                table.addCell(getPdfCell(String.valueOf(analysis.getPercentageResponse()), 0, 0, font, RIGHT));
                table.addCell(getPdfCell(String.valueOf(analysis.getSectionMean()), 0, 0, font, RIGHT));
                table.addCell(getPdfCell(String.valueOf(analysis.getCourseMean()), 0, 0, font, RIGHT));
                table.addCell(getPdfCell(String.valueOf(analysis.getDepartmentMean()), 0, 0, font, RIGHT));
                table.addCell(getPdfCell(String.valueOf(analysis.getCollegeMean()), 0, 0, font, RIGHT));

                cTotal = cTotal + analysis.getTotal();
                cPctVal = cPctVal + analysis.getPercentageResponse();
                cSectionMean = cSectionMean + analysis.getSectionMean();
                cCourseMean = cCourseMean + analysis.getCollegeMean();
                cDepart = cDepart + analysis.getDepartmentMean();
                cCollege = cCollege + analysis.getCollegeMean();
                rowCount = rowCount + 1;

            }
        }
    }

    /***  First part - Summary   ***/
    table.addCell(getPdfCell(String.valueOf(""), 0, 0, font));
    table.addCell(getPdfCell(UtilProperty.getMessage("prop.course.teaching.survey.analysis.summary", null), 0,
            0, font, RIGHT));
    table.addCell(getPdfCell(String.valueOf(""), 0, 5, font));
    table.addCell(getPdfCell(String.valueOf(cTotal), 0, 0, font, RIGHT));
    table.addCell(getPdfCell(String.valueOf(formatter.format(cPctVal / rowCount)), 0, 0, font, RIGHT));
    table.addCell(getPdfCell(String.valueOf(formatter.format(cSectionMean / rowCount)), 0, 0, font, RIGHT));
    table.addCell(getPdfCell(String.valueOf(formatter.format(cCourseMean / rowCount)), 0, 0, font, RIGHT));
    table.addCell(getPdfCell(String.valueOf(formatter.format(cDepart / rowCount)), 0, 0, font, RIGHT));
    table.addCell(getPdfCell(String.valueOf(formatter.format(cCollege / rowCount)), 0, 0, font, RIGHT));

    table.addCell(getPdfCell("", 0, 13, font));

    table.addCell(getPdfCell("", 0, 0, font));
    table.addCell(
            getPdfCell(UtilProperty.getMessage("prop.course.teaching.survey.analysis.teaching.items", null), 0,
                    12, font, LEFT));

    cTotal = 0;
    cPctVal = 0f;
    cSectionMean = 0f;
    cCourseMean = 0f;
    cDepart = 0f;
    cCollege = 0f;
    rowCount = 0;
    for (SurveyResponse sures : survey.getSurveyResponses()) {
        for (Analysis analysis : sures.getAnalysisList()) {
            if (!(analysis.getQuestion().equals("Q2") || analysis.getQuestion().equals("Q14")
                    || analysis.getQuestion().equals(questionByYear))) {

                table.addCell(getPdfCell(analysis.getQuestion(), 0, 0, font));
                table.addCell(
                        getPdfCell(
                                UtilProperty.getMessage("prop.course.teaching.survey.analysis.set"
                                        + questionSetNo + ".question" + analysis.getQuestionLabel(), null),
                                0, 0, font, LEFT));
                table.addCell(getPdfCell(String.valueOf(analysis.getStrongDisagree()), 0, 0, font, RIGHT));
                table.addCell(getPdfCell(String.valueOf(analysis.getDisAgree()), 0, 0, font, RIGHT));
                table.addCell(getPdfCell(String.valueOf(analysis.getAgree()), 0, 0, font, RIGHT));
                table.addCell(getPdfCell(String.valueOf(analysis.getStrongAgree()), 0, 0, font, RIGHT));
                table.addCell(getPdfCell(String.valueOf(analysis.getNotApplicable()), 0, 0, font, RIGHT));
                table.addCell(getPdfCell(String.valueOf(analysis.getTotal()), 0, 0, font, RIGHT));
                table.addCell(getPdfCell(String.valueOf(analysis.getPercentageResponse()), 0, 0, font, RIGHT));
                table.addCell(getPdfCell(String.valueOf(analysis.getSectionMean()), 0, 0, font, RIGHT));
                table.addCell(getPdfCell(String.valueOf(analysis.getCourseMean()), 0, 0, font, RIGHT));
                table.addCell(getPdfCell(String.valueOf(analysis.getDepartmentMean()), 0, 0, font, RIGHT));
                table.addCell(getPdfCell(String.valueOf(analysis.getCollegeMean()), 0, 0, font, RIGHT));

                cTotal = cTotal + analysis.getTotal();
                cPctVal = cPctVal + analysis.getPercentageResponse();
                cSectionMean = cSectionMean + analysis.getSectionMean();
                cCourseMean = cCourseMean + analysis.getCollegeMean();
                cDepart = cDepart + analysis.getDepartmentMean();
                cCollege = cCollege + analysis.getCollegeMean();
                rowCount = rowCount + 1;

            }

        }

    }

    /***  Second part - Summary   ***/
    table.addCell(getPdfCell(String.valueOf(""), 0, 0, font));
    table.addCell(getPdfCell(UtilProperty.getMessage("prop.course.teaching.survey.analysis.summary", null), 0,
            0, font, RIGHT));
    table.addCell(getPdfCell(String.valueOf(""), 0, 5, font));
    table.addCell(getPdfCell(String.valueOf(cTotal), 0, 0, font, RIGHT));
    table.addCell(getPdfCell(String.valueOf(formatter.format(cPctVal / rowCount)), 0, 0, font, RIGHT));
    table.addCell(getPdfCell(String.valueOf(formatter.format(cSectionMean / rowCount)), 0, 0, font, RIGHT));
    table.addCell(getPdfCell(String.valueOf(formatter.format(cCourseMean / rowCount)), 0, 0, font, RIGHT));
    table.addCell(getPdfCell(String.valueOf(formatter.format(cDepart / rowCount)), 0, 0, font, RIGHT));
    table.addCell(getPdfCell(String.valueOf(formatter.format(cCollege / rowCount)), 0, 0, font, RIGHT));

    if (!survey.getMessage().equals("")) {
        table.addCell(getPdfCell("", 0, 13, font));
        table.addCell(getPdfCell("", 0, 0, font));
        table.addCell(getPdfCell(survey.getMessage(), 0, 12, font, CENTER));
    }

    table.setTotalWidth(750);
    table.setLockedWidth(true);
    table.setWidths(new float[] { 1, 6, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 });

    ColumnText column = new ColumnText(pdfStamper.getOverContent(1));
    Rectangle rectPage1 = new Rectangle(120, 20, 659, 480);

    column.setSimpleColumn(rectPage1);
    column.addElement(table);

    int status = column.go();

    pdfStamper.setFormFlattening(true);

    pdfStamper.close();

    pdfTemplate.close();

    res.setContentType("application/pdf");

    return res.getPortletOutputStream();

}

From source file:org.apache.jmeter.visualizers.CreateReport.java

License:Apache License

/**
 * Creates a table; widths are set with setWidths().
 * @return a PdfPTable//from   w  w  w . j  a  v  a  2  s .c  om
 * @throws DocumentException
 */
public PdfPTable createTable1() throws DocumentException {
    PdfPTable table = new PdfPTable(7);

    table.setWidthPercentage(570 / 5.23f);
    table.setWidths(new int[] { 4, 4, 3, 3, 3, 3, 5 });
    PdfPCell cell = null;
    for (int k = 0; k < 10; k++) {
        if (k != 5 && k != 8 && k != 9) {
            cell = new PdfPCell(new Phrase(JMeterUtils.getResString(COLUMNS[k]), headerFont));
            BaseColor BC = new BaseColor(164, 188, 196);
            cell.setBackgroundColor(BC);
            cell.setColspan(1);
            table.addCell(cell);
        }
    }

    for (int l = 0; l < model.getRowCount(); l++) //row count does not include table headers
        for (int k = 0; k < 10; k++) {
            if (k != 5 && k != 8 && k != 9) {
                cell = new PdfPCell(new Phrase(model.getValueAt(l, k).toString(), rowFont));
                cell.setGrayFill(2);
                table.addCell(cell);
            }
        }
    return table;

    /* original basic statements
    PdfPTable table = new PdfPTable(3);
    table.setWidthPercentage(288 / 5.23f);
    table.setWidths(new int[]{2, 1, 1});
    PdfPCell cell;
    cell = new PdfPCell(new Phrase("Table 1"));
    cell.setColspan(3);
    table.addCell(cell);
    cell = new PdfPCell(new Phrase("Cell with rowspan 2"));
    cell.setRowspan(2);
    table.addCell(cell);
    table.addCell("row 1; cell 1");
    table.addCell("row 1; cell 2");
    table.addCell("row 2; cell 1");
    table.addCell("row 2; cell 2");
    return table;
    */
}

From source file:org.apache.jmeter.visualizers.CreateReport.java

License:Apache License

public PdfPTable createTable2() throws DocumentException {
    PdfPTable table = new PdfPTable(4);

    table.setWidthPercentage(570 / 5.23f);
    table.setWidths(new int[] { 1, 2, 1, 3 });
    PdfPCell cell = null;//from  www.j a va 2 s  . c o  m
    for (int k = 0; k < 4; k++) {
        {
            cell = new PdfPCell(new Phrase(model2.getColumnName(k), headerFont));
            BaseColor BC = new BaseColor(164, 188, 196);
            cell.setBackgroundColor(BC);
            cell.setColspan(1);
            table.addCell(cell);
        }
    }

    for (int l = 0; l < model2.getRowCount(); l++) //row count does not include table headers
        for (int k = 0; k < 4; k++) {

            cell = new PdfPCell(new Phrase(model2.getValueAt(l, k).toString(), rowFont));
            cell.setGrayFill(2);
            table.addCell(cell);

        }
    return table;
}

From source file:org.bonitasoft.studio.migration.utils.PDFMigrationReportWriter.java

License:Open Source License

private void createTable(Paragraph paragrah) throws MalformedURLException, IOException, DocumentException {
    PdfPTable table = new PdfPTable(6);
    table.setHeaderRows(0);/*  www  .j a v a  2s  .  c  o m*/
    table.setWidthPercentage(95f);
    PdfPCell c1 = new PdfPCell(new Phrase(Messages.elementType));
    c1.setBackgroundColor(BaseColor.LIGHT_GRAY);
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    c1.setVerticalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase(Messages.name));
    c1.setBackgroundColor(BaseColor.LIGHT_GRAY);
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    c1.setVerticalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase(Messages.property));
    c1.setBackgroundColor(BaseColor.LIGHT_GRAY);
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    c1.setVerticalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase(Messages.information));
    c1.setBackgroundColor(BaseColor.LIGHT_GRAY);
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    c1.setVerticalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase(Messages.status));
    c1.setBackgroundColor(BaseColor.LIGHT_GRAY);
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    c1.setVerticalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase(Messages.reviewed));
    c1.setBackgroundColor(BaseColor.LIGHT_GRAY);
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    c1.setVerticalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    table.setHeaderRows(1);

    List<Change> changes = report.getChanges();
    if (viewer != null) {
        for (int i = 0; i < changes.size(); i++) {
            addTableRow(table, (Change) viewer.getElementAt(i));
        }
    } else {
        for (Change change : changes) {
            addTableRow(table, change);
        }
    }

    table.setWidths(new int[] { 3, 3, 3, 5, 2, 2 });
    table.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.setComplete(true);

    paragrah.add(table);
}

From source file:org.cherchgk.actions.tournament.result.show.GetPDFTournamentResultAction.java

License:Apache License

public InputStream getDocument() throws DocumentException, IOException {
    Font normalFont = getNormalFont();
    Font boldFont = getBoldFont();

    ByteArrayOutputStream out = new ByteArrayOutputStream();
    Document document = new Document();
    PdfWriter.getInstance(document, out);
    document.open();/*from   w w  w.  j  a  v a2s .com*/

    Paragraph tournamentNameParagraph = new Paragraph(tournament.getTitle(), boldFont);
    tournamentNameParagraph.setAlignment(Element.ALIGN_CENTER);
    document.add(tournamentNameParagraph);

    Paragraph tournamentDateParagraph = new Paragraph(tournament.getDateAsString(), boldFont);
    tournamentDateParagraph.setAlignment(Element.ALIGN_CENTER);
    document.add(tournamentDateParagraph);

    if (teamCategory != null) {
        Paragraph teamCategoryParagraph = new Paragraph(teamCategory.getTitle(), boldFont);
        teamCategoryParagraph.setAlignment(Element.ALIGN_CENTER);
        document.add(teamCategoryParagraph);
    }

    int numColumns = 3 + tournamentResult.getRankingAlgorithms().size();
    PdfPTable resultTable = new PdfPTable(numColumns);
    int[] widths = new int[numColumns];
    widths[0] = 1;
    widths[1] = 3;
    for (int i = 2; i < numColumns; i++) {
        widths[i] = 1;
    }
    resultTable.setWidths(widths);
    resultTable.setSpacingBefore(10f);

    PdfPCell cell = new PdfPCell(new Phrase("", boldFont));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell.setColspan(2);
    cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
    resultTable.addCell(cell);

    for (RankingAlgorithm rankingAlgorithm : tournamentResult.getRankingAlgorithms()) {
        cell = new PdfPCell(new Phrase(rankingAlgorithm.getPointName(), boldFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
        resultTable.addCell(cell);
    }

    cell = new PdfPCell(new Phrase("?", boldFont));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
    resultTable.addCell(cell);

    boolean showTeamCategoryInTable = (teamCategory == null) && !tournament.getTeamCategories().isEmpty();

    for (TournamentResult.TeamResult teamResult : tournamentResult.getTeamResultList()) {
        if (showTeamCategoryInTable) {
            if (teamResult.getTeam().getTeamCategory() != null) {
                cell = new PdfPCell(new Phrase(teamResult.getTeam().getTeamCategory().getTitle(), normalFont));
            } else {
                cell = new PdfPCell(new Phrase("", normalFont));
            }
            resultTable.addCell(cell);
        }
        cell = new PdfPCell(new Phrase(teamResult.getTeam().getName(), normalFont));
        if (!showTeamCategoryInTable) {
            cell.setColspan(2);
        }
        resultTable.addCell(cell);
        for (Map<Team, RankingPoint> m : tournamentResult.getRankingPointsList()) {
            cell = new PdfPCell(new Phrase(m.get(teamResult.getTeam()).toString(), normalFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            resultTable.addCell(cell);
        }
        cell = new PdfPCell(new Phrase(teamResult.getPlace(), normalFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        resultTable.addCell(cell);
    }

    document.add(resultTable);
    document.close();

    return new ByteArrayInputStream(out.toByteArray());
}

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

License:Open Source License

private static PdfPTable prebuildHeaderTable() throws DocumentException {
    PdfPTable table = new PdfPTable(6);
    table.setHorizontalAlignment(Element.ALIGN_LEFT);
    table.setWidthPercentage(100f);//  w  ww .j  ava2s.  c o m
    table.setWidths(new float[] { 0.12f, 0.2f, 0.15f, 0.2f, 0.2f, 0.08f });
    return table;
}

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

License:Open Source License

public static PdfPTable buildFooterVersetzungsvermerkLine(String versetzungsvermerk, Font footerFont)
        throws DocumentException {
    PdfPCell labelCell = new PdfPCell(new Phrase("Versetzungsvermerk", footerFont));
    labelCell.setBorder(Rectangle.BOTTOM);
    labelCell.setBorderWidth(1f);/*  w  ww  . jav  a  2  s  .  c om*/

    PdfPCell nameCell = new PdfPCell(new Phrase(versetzungsvermerk, footerFont));
    nameCell.setBorder(Rectangle.BOTTOM);
    nameCell.setBorderWidth(1f);

    PdfPTable table = new PdfPTable(2);
    table.setHorizontalAlignment(Element.ALIGN_LEFT);
    table.setWidthPercentage(100f);
    table.addCell(labelCell);
    table.addCell(nameCell);
    table.setWidths(new float[] { 0.3f, 0.7f });
    return table;
}

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

License:Open Source License

public static PdfPTable buildFooterDatumLine(String datumString, Font footerFont) throws DocumentException {
    PdfPCell labelCell = new PdfPCell(new Phrase("Datum", footerFont));
    labelCell.setBorder(Rectangle.BOTTOM);
    labelCell.setBorderWidth(1f);//from   ww  w .  j  a  v  a2  s .  c o m

    PdfPCell nameCell = new PdfPCell(new Phrase(datumString, footerFont));
    nameCell.setBorder(Rectangle.BOTTOM);
    nameCell.setBorderWidth(1f);

    PdfPTable table = new PdfPTable(2);
    table.setHorizontalAlignment(Element.ALIGN_LEFT);
    table.setWidthPercentage(100f);
    table.addCell(labelCell);
    table.addCell(nameCell);
    table.setWidths(new float[] { 0.3f, 0.7f });
    return table;
}

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

License:Open Source License

public static PdfPTable buildFooterDienstsiegelLine(Font footerFont) throws DocumentException {
    PdfPCell leftCell = new PdfPCell(new Phrase("", footerFont));
    leftCell.setBorder(Rectangle.NO_BORDER);
    leftCell.setBorderWidth(1f);//from   ww  w.j a  va  2  s  .  co m

    PdfPCell centerCell = new PdfPCell(new Phrase("Dienstsiegel der Schule", footerFont));
    centerCell.setBorder(Rectangle.NO_BORDER);
    centerCell.setBorderWidth(1f);
    centerCell.setHorizontalAlignment(Element.ALIGN_CENTER);

    PdfPCell rightCell = new PdfPCell(new Phrase("", footerFont));
    rightCell.setBorder(Rectangle.NO_BORDER);
    rightCell.setBorderWidth(1f);

    PdfPTable table = new PdfPTable(3);
    table.setHorizontalAlignment(Element.ALIGN_MIDDLE);
    table.setWidthPercentage(100f);
    table.addCell(leftCell);
    table.addCell(centerCell);
    table.addCell(rightCell);
    table.setWidths(new float[] { 0.3f, 0.3f, 0.3f });
    return table;
}