Example usage for com.itextpdf.text Element ALIGN_LEFT

List of usage examples for com.itextpdf.text Element ALIGN_LEFT

Introduction

In this page you can find the example usage for com.itextpdf.text Element ALIGN_LEFT.

Prototype

int ALIGN_LEFT

To view the source code for com.itextpdf.text Element ALIGN_LEFT.

Click Source Link

Document

A possible value for paragraph alignment.

Usage

From source file:fenix.planner.pdf.PDFGenerator.java

License:Open Source License

private void createAndAddEventTable() throws DocumentException {
    PdfPTable table = new PdfPTable(new float[] { 1, 7, 1.2f });
    table.setWidthPercentage(100f);/* w  w w.j a v a  2  s.  c  o m*/
    table.getDefaultCell().setUseAscender(true);
    table.getDefaultCell().setUseDescender(true);
    table.setSpacingBefore(20);
    table.setSpacingAfter(20);

    // Header row
    table.getDefaultCell().setBorderWidthLeft(0);
    table.getDefaultCell().setBorderWidthTop(0);
    table.getDefaultCell().setBorderWidthRight(0);
    table.getDefaultCell().setPadding(5);
    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
    table.addCell(new Phrase("Datum", headerFont));
    table.addCell(new Phrase("mne", headerFont));
    table.addCell(new Phrase("Ansvarig", headerFont));
    table.setHeaderRows(1);
    table.getDefaultCell().setBackgroundColor(null);

    // Events
    for (Event event : program.getSortedCopyOfEvents()) {
        if (event.getDate().getMonthOfYear() % 2 == 0) {
            table.getDefaultCell().setBackgroundColor(new BaseColor(0xdd, 0xdd, 0xdd));
        } else {
            table.getDefaultCell().setBackgroundColor(null);
        }

        if (!event.getType().getBackgroundColor().equals(Color.WHITE)) {
            table.getDefaultCell()
                    .setBackgroundColor(awtColorToBaseColor(event.getType().getBackgroundColor()));
        }

        final BaseColor textColor = awtColorToBaseColor(event.getType().getForegroundColor());

        PdfPCell dateCell = new PdfPCell(table.getDefaultCell());
        dateCell.addElement(
                new Phrase(event.getDate().toString("dd.MM", locale), changeColor(subjectFont, textColor)));
        table.addCell(dateCell);

        PdfPCell subjectCell = new PdfPCell(table.getDefaultCell());
        subjectCell.addElement(new Phrase(event.getSubject(), changeColor(subjectFont, textColor)));
        if (event.getDescription().length() > 0) {
            subjectCell.addElement(new Phrase(event.getDescription(), changeColor(descriptionFont, textColor)));
        }
        if (event.getOrganizer() == null) {
            subjectCell.setColspan(2);
        }
        table.addCell(subjectCell);

        if (event.getOrganizer() != null) {
            PdfPCell organizerCell = new PdfPCell(table.getDefaultCell());
            organizerCell.addElement(
                    new Phrase(event.getOrganizer().getInitials(), changeColor(subjectFont, textColor)));
            table.addCell(organizerCell);
        }
    }

    document.add(table);
}

From source file:fenix.planner.pdf.PDFGenerator.java

License:Open Source License

private void createAndAddOrganizerTable() throws DocumentException {
    PdfPTable table = new PdfPTable(new float[] { 1, 3, 4, 2 });
    table.setSpacingBefore(20);//  ww  w  . j a v a  2  s .c om

    table.setWidthPercentage(100f);
    table.getDefaultCell().setUseAscender(true);
    table.getDefaultCell().setUseDescender(true);

    // Header row
    table.getDefaultCell().setBorder(0);
    table.getDefaultCell().setPadding(5);
    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
    table.getDefaultCell().setBackgroundColor(null);

    for (Organizer organizer : program.getSortedCopyOfOrganizers()) {
        table.addCell(new Phrase(organizer.getInitials(), organizerFont));
        table.addCell(new Phrase(organizer.getFullName(), organizerFont));
        table.addCell(new Phrase(organizer.getEmail(), organizerFont));
        table.addCell(new Phrase(organizer.getPhoneNumber(), organizerFont));
    }

    document.add(table);
}

From source file:file.PDFWriter.java

License:Open Source License

/**
 * Make the initial header to the PDF, with the date and character
 * @throws DocumentException/*from   www.j a va 2  s  . c om*/
 */
public void makePDFHeader() throws DocumentException {
    PdfPTable headerTable = new PdfPTable(2);
    headerTable.setWidthPercentage(100);

    PdfPCell dateCell = new PdfPCell(new Paragraph(
            "Date: " + date.monthOfYear().getAsString() + "/" + date.dayOfMonth().getAsString(), lineFont));
    dateCell.setHorizontalAlignment(Element.ALIGN_LEFT);
    dateCell.setBorder(PdfPCell.NO_BORDER);
    dateCell.setPadding(0.3f);
    PdfPCell characterCell = new PdfPCell(new Paragraph("Character: " + role.getName(), lineFont));
    characterCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    characterCell.setBorder(PdfPCell.NO_BORDER);

    headerTable.addCell(dateCell);
    headerTable.addCell(characterCell);
    document.add(headerTable);
    document.add(Chunk.NEWLINE);
    document.add(Chunk.NEWLINE);
}

From source file:fll.web.playoff.ScoresheetGenerator.java

License:Open Source License

/**
 * Stores the goal cells that are inserted into the output after the team name
 * headers and before the scoring/initials blanks at the bottom of the
 * scoresheet.//from  ww w.j  a  v  a 2 s  .  c  o m
 */
private void setChallengeInfo(final ChallengeDescription description) {
    setPageTitle(description.getTitle());

    if (null != description.getRevision()) {
        setRevisionInfo(description.getRevision());
    }

    if (null != description.getCopyright()) {
        m_copyright = description.getCopyright();
    } else {
        m_copyright = null;
    }

    final PerformanceScoreCategory performanceElement = description.getPerformance();
    // use ArrayList as we will be doing indexed access in the loop
    final List<AbstractGoal> goals = new ArrayList<>(performanceElement.getGoals());

    final float[] relativeWidths = new float[3];
    relativeWidths[0] = 4;
    relativeWidths[1] = 48;
    relativeWidths[2] = 48;
    m_goalsTable = new PdfPTable(relativeWidths);

    String prevCategory = null;
    for (int goalIndex = 0; goalIndex < goals.size(); ++goalIndex) {
        final AbstractGoal goal = goals.get(goalIndex);
        if (!goal.isComputed()) {
            final String category = goal.getCategory();

            // add category cell if needed
            boolean firstRowInCategory = false;
            if (!StringUtils.equals(prevCategory, category)) {
                if (!StringUtils.isEmpty(category)) {

                    // find out how many future goals have the same category
                    int categoryRowSpan = 1;
                    for (int otherIndex = goalIndex + 1; otherIndex < goals.size(); ++otherIndex) {
                        final AbstractGoal otherGoal = goals.get(otherIndex);
                        if (!otherGoal.isComputed()) {
                            if (StringUtils.equals(category, otherGoal.getCategory())) {
                                ++categoryRowSpan;
                            } else {
                                break;
                            }
                        }
                    }

                    final Paragraph catPara = new Paragraph(category, ARIAL_10PT_NORMAL);
                    final PdfPCell categoryCell = new PdfPCell(catPara);
                    categoryCell.setBorderWidthTop(1);
                    categoryCell.setBorderWidthBottom(0);
                    categoryCell.setBorderWidthLeft(0);
                    categoryCell.setBorderWidthRight(0);
                    categoryCell.setVerticalAlignment(Element.ALIGN_CENTER);
                    categoryCell.setHorizontalAlignment(Element.ALIGN_CENTER);
                    categoryCell.setRotation(90);
                    categoryCell.setRowspan(categoryRowSpan);
                    m_goalsTable.addCell(categoryCell);
                }

                // first row in a new category, which may be empty
                firstRowInCategory = true;
            }

            // This is the text for the left hand "label" cell
            final String title = goal.getTitle();
            final Paragraph p = new Paragraph(title, ARIAL_10PT_NORMAL);
            final PdfPCell goalLabel = new PdfPCell(p);
            goalLabel.setHorizontalAlignment(Element.ALIGN_RIGHT);
            goalLabel.setVerticalAlignment(Element.ALIGN_CENTER);
            if (firstRowInCategory) {
                goalLabel.setBorderWidthTop(1);
                goalLabel.setBorderWidthBottom(0);
                goalLabel.setBorderWidthLeft(0);
                goalLabel.setBorderWidthRight(0);
            } else {
                goalLabel.setBorder(0);
            }
            goalLabel.setPaddingRight(9);
            goalLabel.setVerticalAlignment(Element.ALIGN_TOP);
            if (StringUtils.isEmpty(category)) {
                // category column and goal label column
                goalLabel.setColspan(2);
            }
            m_goalsTable.addCell(goalLabel);

            // define the value cell
            final double min = goal.getMin();
            final String minStr = FP.equals(min, Math.round(min), 1E-6) ? String.valueOf((int) min)
                    : String.valueOf(min);
            final double max = goal.getMax();
            final String maxStr = FP.equals(max, Math.round(max), 1E-6) ? String.valueOf((int) max)
                    : String.valueOf(max);

            // If element has child nodes, then we have an enumerated list
            // of choices. Otherwise it is either yes/no or a numeric field.
            final PdfPCell goalValue = new PdfPCell();
            final Chunk choices = new Chunk("", COURIER_10PT_NORMAL);
            if (goal.isEnumerated()) {
                // replace spaces with "no-break" spaces
                boolean first = true;
                final List<EnumeratedValue> values = goal.getSortedValues();
                for (final EnumeratedValue value : values) {
                    if (!first) {
                        choices.append(" /" + Utilities.NON_BREAKING_SPACE);
                    } else {
                        first = false;
                    }
                    choices.append(value.getTitle().toUpperCase().replace(' ', Utilities.NON_BREAKING_SPACE));
                }
                goalValue.addElement(choices);

            } else {
                if (goal.isYesNo()) {
                    // order of yes/no needs to match ScoreEntry.generateYesNoButtons
                    final Paragraph q = new Paragraph("NO / YES", COURIER_10PT_NORMAL);
                    goalValue.addElement(q);

                } else {
                    final String range = "(" + minStr + " - " + maxStr + ")";
                    final PdfPTable t = new PdfPTable(2);
                    t.setHorizontalAlignment(Element.ALIGN_LEFT);
                    t.setTotalWidth(1 * POINTS_PER_INCH);
                    t.setLockedWidth(true);
                    final Phrase r = new Phrase("", ARIAL_8PT_NORMAL);
                    t.addCell(new PdfPCell(r));
                    final Phrase q = new Phrase(range, ARIAL_8PT_NORMAL);
                    t.addCell(new PdfPCell(q));
                    goalValue.setPaddingTop(9);
                    goalValue.addElement(t);
                }
            }

            if (firstRowInCategory) {
                goalValue.setBorderWidthTop(1);
                goalValue.setBorderWidthBottom(0);
                goalValue.setBorderWidthLeft(0);
                goalValue.setBorderWidthRight(0);
            } else {
                goalValue.setBorder(0);
            }
            goalValue.setVerticalAlignment(Element.ALIGN_MIDDLE);

            m_goalsTable.addCell(goalValue);

            // setup for next loop
            prevCategory = category;
        } // if not computed goal

    } // foreach goal

}

From source file:fr.ybonnel.breizhcamppdf.PdfRenderer.java

License:Apache License

private List<Talk> createProgrammePages() throws DocumentException, IOException {
    List<Talk> talksToExplain = new ArrayList<>();
    document.setPageSize(PageSize.A4.rotate());
    Font font = new Font();
    font.setStyle(Font.BOLD);//from w  ww.  j a va 2 s.co  m
    font.setSize(14);

    for (String date : service.getDates()) {

        Set<String> tracksInPage = new HashSet<>();

        Map<String, Talk> precedentTalk = new HashMap<>();
        PdfPTable table = createBeginningOfPage(font, date);
        for (String creneau : service.getCreneaux().get(date)) {
            // Nouvelle page  14h
            if (creneau.startsWith("14:00") && !tracksInPage.isEmpty()) {
                document.add(table);

                addLegend(tracksInPage);
                table = createBeginningOfPage(font, date);
            }

            PdfPCell cellCreneau = new PdfPCell();
            cellCreneau.setPaddingBottom(10);
            Paragraph startTime = new Paragraph(creneau);
            startTime.setAlignment(Element.ALIGN_CENTER);
            cellCreneau.addElement(startTime);
            Paragraph endTime = new Paragraph(getEndTime(date, creneau));
            endTime.setAlignment(Element.ALIGN_CENTER);
            cellCreneau.addElement(endTime);
            table.addCell(cellCreneau);
            for (String room : service.getRooms(date)) {
                PdfPCell cell = new PdfPCell();
                cell.setPaddingBottom(10);
                cell.setHorizontalAlignment(Element.ALIGN_LEFT);

                Talk talk = service.getTalkByDateAndCreneauxAndRoom(date, creneau, room);
                if (talk != null) {
                    talksToExplain.add(talk);
                    remplirCellWithTalk(cell, talk);
                    cell.setRowspan(getRowSpan(date, talk));
                    precedentTalk.put(room, talk);
                    tracksInPage.add(talk.getTrack());
                    table.addCell(cell);
                } else {
                    talk = precedentTalk.get(room);
                    if (!(talk != null && talk.getEnd().compareTo(creneau) > 0)) {
                        table.addCell(cell);
                    }
                }
            }
        }
        document.add(table);
        addLegend(tracksInPage);
    }
    return talksToExplain;
}

From source file:fr.ybonnel.breizhcamppdf.RoomPdfRenderer.java

License:Apache License

private List<Talk> createProgrammePages() throws DocumentException, IOException {
    List<Talk> talksToExplain = new ArrayList<>();
    document.setPageSize(PageSize.A4);/*from w w w .  j  ava  2  s.  co m*/
    Font font = new Font();
    font.setStyle(Font.BOLD);
    font.setSize(14);

    for (String date : service.getDates()) {

        for (String room : service.getRooms(date)) {

            Set<String> tracksInPage = new HashSet<>();

            Map<String, Talk> precedentTalk = new HashMap<>();
            PdfPTable table = createBeginningOfPage(font, date, room);
            for (String creneau : service.getCreneaux().get(date)) {

                PdfPCell cellCreneau = new PdfPCell();
                cellCreneau.setPaddingBottom(10);
                Paragraph startTime = new Paragraph(creneau);
                startTime.setAlignment(Element.ALIGN_CENTER);
                cellCreneau.addElement(startTime);
                Paragraph endTime = new Paragraph(getEndTime(date, creneau));
                endTime.setAlignment(Element.ALIGN_CENTER);
                cellCreneau.addElement(endTime);
                table.addCell(cellCreneau);

                PdfPCell cell = new PdfPCell();
                cell.setPaddingBottom(10);
                cell.setHorizontalAlignment(Element.ALIGN_LEFT);

                Talk talk = service.getTalkByDateAndCreneauxAndRoom(date, creneau, room);
                if (talk != null) {
                    talksToExplain.add(talk);
                    remplirCellWithTalk(cell, talk);
                    cell.setRowspan(getRowSpan(date, talk));
                    precedentTalk.put(room, talk);
                    tracksInPage.add(talk.getTrack());
                    table.addCell(cell);
                } else {
                    talk = precedentTalk.get(room);
                    if (!(talk != null && talk.getEnd().compareTo(creneau) > 0)) {
                        table.addCell(cell);
                    }
                }

            }
            document.add(table);
            addLegend(tracksInPage);
        }
    }
    return talksToExplain;
}

From source file:frames.main.java

private void jButton13ActionPerformed(java.awt.event.ActionEvent evt) {
    try {//from w  ww .  jav  a2 s .com

        BaseFont unicode = BaseFont.createFont("c:/windows/fonts/ALGER.ttf", BaseFont.IDENTITY_H,
                BaseFont.EMBEDDED);

        // Font font11113 = new Font(unicode, 16, Font.BOLD,BaseColor(2,2,2));
        ///////////////////////////////////////////////dark brown//////////////////////////////////////////////////////
        Font font1003 = new Font(unicode, 16, Font.BOLD, new BaseColor(101, 67, 33));
        Font font1008 = new Font(unicode, 20, Font.BOLD, new BaseColor(101, 67, 33));
        /////////////////////////////////////
        ///////////////////////////////////////////////dark red//////////////////////////////////////////////////////
        Font font1004 = new Font(unicode, 14, Font.BOLD, new BaseColor(139, 0, 0));
        Font font1005 = new Font(unicode, 14, Font.BOLD, new BaseColor(255, 0, 0));

        /////////////////////////////////////
        Font font100 = new Font(unicode, 8, Font.ITALIC, BaseColor.BLUE);
        Document document = new Document();
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("SMART-TC.pdf"));
        document.open();
        PdfContentByte cb = writer.getDirectContent();
        Font font111 = new Font(Font.FontFamily.COURIER, 16, Font.BOLD, BaseColor.ORANGE);
        com.itextpdf.text.Image image2 = com.itextpdf.text.Image
                .getInstance("C:\\smart kid\\src\\frames\\logo.jpg");
        image2.scaleAbsolute(125f, 125f);
        image2.setAbsolutePosition(31, 700);
        document.add(image2);
        com.itextpdf.text.Image ing = com.itextpdf.text.Image.getInstance("C:\\smart kid\\src\\frames\\BC.jpg");
        ing.setAbsolutePosition(1, 200);
        document.add(ing);
        Font font1111 = new Font(unicode, 16, Font.BOLD, BaseColor.ORANGE);
        Font font11111 = new Font(unicode, 14, Font.BOLD, BaseColor.ORANGE);
        java.awt.Font awtPlainFont = new java.awt.Font("ALGERIAN", java.awt.Font.PLAIN, 10);
        document.add(new Paragraph("                                    SMART KIDS CONVENT SCHOOL", font1008));
        document.add(new Paragraph(
                "                                                   HEERA NAGAR (GURGAON)         ", font1003));
        document.add(
                new Chunk("                                       SCHOLOR'S REGISTER AND TRANSFER CERTIFICATE",
                        font1005));
        document.add(new Paragraph("                                    "));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph("                            ", font111));
        Font font41 = new Font(Font.FontFamily.HELVETICA, 9, Font.BOLD, new BaseColor(0, 0, 0));
        Font font23 = new Font(Font.FontFamily.HELVETICA, 12, Font.BOLD, new BaseColor(92, 64, 51));
        Font font1 = new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD, new BaseColor(0, 0, 0));
        Font font11 = new Font(Font.FontFamily.HELVETICA, 12, Font.ITALIC, new BaseColor(148, 0, 211));
        Font font31 = new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD, new BaseColor(990000));
        Font font2 = new Font(Font.FontFamily.COURIER, 18, Font.ITALIC | Font.UNDERLINE);
        Font font3 = new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD, new BaseColor(255, 255, 200));

        document.add(new Paragraph(
                "Ref No:  " + TC16.getText() + "                         " + new java.util.Date().toString(),
                FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK)));
        document.add(new Paragraph("    "));
        String ho4 = TC1.getText();
        Paragraph p1 = new Paragraph();
        p1.add(new Chunk("NAME OF STUDENT        :",
                FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK)));
        p1.add(new Chunk(ho4, font11));
        document.add(p1);

        String ho5 = TC2.getText();
        Paragraph p2 = new Paragraph();
        p2.add(new Chunk("FATHER'S NAME          :",
                FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK)));
        p2.add(new Chunk(ho5, font11));
        document.add(p2);

        String ho6 = TC3.getText();
        Paragraph p93 = new Paragraph();
        p93.add(new Chunk("MOTHER'S NAME          :",
                FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK)));
        p93.add(new Chunk(ho6, font11));
        document.add(p93);

        Font font15 = new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD, new BaseColor(0, 0, 0));
        String ho8 = TC1.getText();
        String tt = TC4.getText();
        Paragraph p4 = new Paragraph();

        p4.add(new Chunk("RELIGION               :",
                FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK)));
        p4.add(new Chunk(tt, font11));

        document.add(p4);
        // document.add(new Paragraph("                                            ",font1003));
        String kk = TC5.getText();
        Paragraph p5 = new Paragraph();
        p5.add(new Chunk("CASTE OF SCHOLOR       :",
                FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK)));
        p5.add(new Chunk(kk, font11));
        document.add(p5);

        String ho10 = TC10.getText();
        Paragraph p6 = new Paragraph();
        p6.add(new Chunk("ADDRESS                :",
                FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK)));
        p6.add(new Chunk(ho10, font11));
        document.add(p6);

        Paragraph p8 = new Paragraph();
        p8.add(new Chunk("DATE OF BIRTH          :",
                FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK)));
        p8.add(new Chunk(TC9.getText(), font11));
        document.add(p8);
        Paragraph p9 = new Paragraph();
        p9.add(new Chunk("SECTION                :",
                FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK)));
        p9.add(new Chunk(TC7.getText(), font11));
        document.add(p9);
        Paragraph p10 = new Paragraph();
        p10.add(new Chunk("REGISTRATION NO:       :",
                FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK)));
        p10.add(new Chunk(TC8.getText(), font11));
        document.add(p10);
        document.add(new Paragraph("                                       "));

        PdfPTable table = new PdfPTable(8);
        String vacume = "";
        table.addCell("Class");
        table.addCell("Date of Admission");
        table.addCell("Date of Promotion");
        table.addCell("Date of Removal");
        table.addCell("Cause of Removal");
        table.addCell("Year");
        table.addCell("Conduct and Work");
        table.addCell("Sign");

        PdfPCell cell10 = new PdfPCell(new Paragraph("NURSERY", font100));
        table.addCell(cell10);
        if (TC6.getSelectedIndex() == 0) {
            PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100));
            PdfPCell cell12 = new PdfPCell(
                    new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100));
            PdfPCell cell13 = new PdfPCell(
                    new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100));
            ;
            PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100));
            PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100));
            PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100));
            table.addCell(cell11);
            table.addCell(cell12);
            table.addCell(cell13);
            table.addCell(cell14);
            table.addCell(cell15);
            table.addCell(cell16);
            table.addCell("");
        } else {
            for (int i = 0; i < 7; i++)
                table.addCell(vacume);
        }

        PdfPCell cell111 = new PdfPCell(new Paragraph("LKG", font100));
        table.addCell(cell111);
        if (TC6.getSelectedIndex() == 1) {
            PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100));
            PdfPCell cell12 = new PdfPCell(
                    new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100));
            PdfPCell cell13 = new PdfPCell(
                    new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100));
            ;
            PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100));
            PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100));
            PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100));
            table.addCell(cell11);
            table.addCell(cell12);
            table.addCell(cell13);
            table.addCell(cell14);
            table.addCell(cell15);
            table.addCell(cell16);
            table.addCell("");
        } else {
            for (int i = 0; i < 7; i++)
                table.addCell(vacume);
        }

        PdfPCell cell1 = new PdfPCell(new Paragraph("UKG", font100));
        table.addCell(cell1);
        if (TC6.getSelectedIndex() == 2) {
            PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100));
            PdfPCell cell12 = new PdfPCell(
                    new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100));
            PdfPCell cell13 = new PdfPCell(
                    new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100));
            ;
            PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100));
            PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100));
            PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100));
            table.addCell(cell11);
            table.addCell(cell12);
            table.addCell(cell13);
            table.addCell(cell14);
            table.addCell(cell15);
            table.addCell(cell16);
            table.addCell("");
        } else {
            for (int i = 0; i < 7; i++)
                table.addCell(vacume);
        }
        PdfPCell cell2 = new PdfPCell(new Paragraph("STD-1", font100));
        table.addCell(cell2);
        if (TC6.getSelectedIndex() == 3) {
            PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100));
            PdfPCell cell12 = new PdfPCell(
                    new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100));
            PdfPCell cell13 = new PdfPCell(
                    new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100));
            ;
            PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100));
            PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100));
            PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100));
            table.addCell(cell11);
            table.addCell(cell12);
            table.addCell(cell13);
            table.addCell(cell14);
            table.addCell(cell15);
            table.addCell(cell16);
            table.addCell("");
        } else {
            for (int i = 0; i < 7; i++)
                table.addCell(vacume);
        }

        PdfPCell cell3 = new PdfPCell(new Paragraph("STD-2", font100));
        table.addCell(cell3);
        if (TC6.getSelectedIndex() == 4) {
            PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100));
            PdfPCell cell12 = new PdfPCell(
                    new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100));
            PdfPCell cell13 = new PdfPCell(
                    new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100));
            ;
            PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100));
            PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100));
            PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100));
            table.addCell(cell11);
            table.addCell(cell12);
            table.addCell(cell13);
            table.addCell(cell14);
            table.addCell(cell15);
            table.addCell(cell16);
            table.addCell("");
        } else {
            for (int i = 0; i < 7; i++)
                table.addCell(vacume);
        }

        PdfPCell cell4 = new PdfPCell(new Paragraph("STD-3", font100));
        table.addCell(cell4);
        if (TC6.getSelectedIndex() == 5) {
            PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100));
            PdfPCell cell12 = new PdfPCell(
                    new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100));
            PdfPCell cell13 = new PdfPCell(
                    new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100));
            ;
            PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100));
            PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100));
            PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100));
            table.addCell(cell11);
            table.addCell(cell12);
            table.addCell(cell13);
            table.addCell(cell14);
            table.addCell(cell15);
            table.addCell(cell16);
            table.addCell("");
        } else {
            for (int i = 0; i < 7; i++)
                table.addCell(vacume);
        }

        PdfPCell cell5 = new PdfPCell(new Paragraph("STD-4", font100));
        table.addCell(cell5);
        if (TC6.getSelectedIndex() == 6) {
            PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100));
            PdfPCell cell12 = new PdfPCell(
                    new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100));
            PdfPCell cell13 = new PdfPCell(
                    new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100));
            ;
            PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100));
            PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100));
            PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100));
            table.addCell(cell11);
            table.addCell(cell12);
            table.addCell(cell13);
            table.addCell(cell14);
            table.addCell(cell15);
            table.addCell(cell16);
            table.addCell("");
        } else {
            for (int i = 0; i < 7; i++)
                table.addCell(vacume);
        }
        PdfPCell cell6 = new PdfPCell(new Paragraph("STD-5", font100));
        table.addCell(cell6);
        if (TC6.getSelectedIndex() == 7) {
            PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100));
            PdfPCell cell12 = new PdfPCell(
                    new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100));
            PdfPCell cell13 = new PdfPCell(
                    new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100));
            ;
            PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100));
            PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100));
            PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100));
            table.addCell(cell11);
            table.addCell(cell12);
            table.addCell(cell13);
            table.addCell(cell14);
            table.addCell(cell15);
            table.addCell(cell16);
            table.addCell("");
        } else {
            for (int i = 0; i < 7; i++)
                table.addCell(vacume);
        }
        PdfPCell cell8 = new PdfPCell(new Paragraph("STD-6", font100));
        table.addCell(cell8);
        if (TC6.getSelectedIndex() == 8) {
            PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100));
            PdfPCell cell12 = new PdfPCell(
                    new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100));
            PdfPCell cell13 = new PdfPCell(
                    new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100));
            ;
            PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100));
            PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100));
            PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100));
            table.addCell(cell11);
            table.addCell(cell12);
            table.addCell(cell13);
            table.addCell(cell14);
            table.addCell(cell15);
            table.addCell(cell16);
            table.addCell("");
        } else {
            for (int i = 0; i < 7; i++)
                table.addCell(vacume);
        }

        PdfPCell cell9 = new PdfPCell(new Paragraph("STD-7", font100));
        table.addCell(cell9);
        if (TC6.getSelectedIndex() == 9) {
            PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100));
            PdfPCell cell12 = new PdfPCell(
                    new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100));
            PdfPCell cell13 = new PdfPCell(
                    new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100));
            ;
            PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100));
            PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100));
            PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100));
            table.addCell(cell11);
            table.addCell(cell12);
            table.addCell(cell13);
            table.addCell(cell14);
            table.addCell(cell15);
            table.addCell(cell16);
            table.addCell("");
        } else {
            for (int i = 0; i < 7; i++)
                table.addCell(vacume);
        }

        PdfPCell cell18 = new PdfPCell(new Paragraph("STD-8", font100));
        table.addCell(cell18);
        if (TC6.getSelectedIndex() == 2) {
            PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100));
            PdfPCell cell12 = new PdfPCell(
                    new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100));
            PdfPCell cell13 = new PdfPCell(
                    new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100));
            ;
            PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100));
            PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100));
            PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100));
            table.addCell(cell11);
            table.addCell(cell12);
            table.addCell(cell13);
            table.addCell(cell14);
            table.addCell(cell15);
            table.addCell(cell16);
            table.addCell("");
        } else {
            for (int i = 0; i < 7; i++)
                table.addCell(vacume);
        }

        float[] ColumnWidths = new float[] { 8f, 12f, 12f, 12f, 22f, 8f, 15f, 7f };
        table.setWidths(ColumnWidths);
        table.setWidthPercentage(106);
        table.setHorizontalAlignment(Element.ALIGN_LEFT);
        document.add(table);

        document.add(new Paragraph("                                       "));
        document.add(new Paragraph("                                       "));
        document.add(new Paragraph(
                "1. I certified that the entries as regard details of the student have been duly checked from the 'Admission form' and that they are complete.",
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.NORMAL, BaseColor.BLACK)));
        // document.add(new Paragraph("                                                                                                        "));

        document.add(new Paragraph("                                       "));
        document.add(new Paragraph(
                "2. Certified that the above Students register have been posted up-to date of students leaving as required by the departmental rules.",
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.NORMAL, BaseColor.BLACK)));
        document.add(new Paragraph("                                       "));
        document.add(new Paragraph("                                       "));
        document.add(new Paragraph(
                "Prepared by:-" + "                                " + "Date:-" + " "
                        + new java.util.Date().toString() + "                      " + "Principal's Sign:-",
                FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.NORMAL, BaseColor.BLACK)));

        document.add(new Paragraph("                                       "));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph("An ISO 9001:2008 Certified School(Certificate Number:NOR/0712M/1505)",
                FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLUE)));
        document.add(new Paragraph("(Run By:Smart Educational Society)Regd.No.(DR/GGN/285)",
                FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLUE)));
        document.add(new Paragraph(
                "413A/23,Gali No:-2,Heera Nagar,Near Rajendra Hospital,Khandsa Road,Gurgaon(Haryana)",
                FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLUE)));
        cb.saveState();
        cb.setColorStroke(BaseColor.BLACK);
        cb.rectangle(2, 2, 588, 828);
        cb.stroke();
        cb.restoreState();
        JOptionPane.showMessageDialog(this, "it is saved");
        document.close();
    } catch (Exception ee) {
        JOptionPane.showMessageDialog(this, ee);
    } // TODO add your handling code here:
}

From source file:Functions.pdf_Export.java

public void createHeader(Document doc, Integer soHoaDon) {
    try {//from w  ww  . j  a  va2s .c  om
        PdfPTable table = new PdfPTable(new float[] { 80, 20 });
        table.setWidthPercentage(100);

        LinkedHashMap<String, Font> lines = new LinkedHashMap<>();
        lines.put("Shop Name: " + shopName, titleFont);
        lines.put("Address: " + address, smallFont);
        lines.put("Phone Number: " + phoneNumb, smallFont);
        lines.put("Website: " + web, smallFont);
        lines.put("Email: " + email, smallFont);

        // left cell with shop's infor
        PdfPCell leftCell = new PdfPCell();
        leftCell.setPaddingTop(-7);
        leftCell.setPaddingRight(35);
        Set<String> singleLine = lines.keySet();
        // this below loop to create a line with text, and set it's font
        for (String line : singleLine) {
            leftCell.addElement(new Phrase(line, lines.get(line)));
        }
        leftCell.setHorizontalAlignment(Element.ALIGN_LEFT);
        leftCell.setBorder(PdfPCell.NO_BORDER);
        table.addCell(leftCell);

        // right cell with bill's time
        String time = new HoaDonDAO().getHoaDon(soHoaDon).getNgayLapHoaDon().toString();
        PdfPCell rightCell = new PdfPCell();
        rightCell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        rightCell.addElement(new Phrase("Date: " + time + "\nNo.: " + soHoaDon, smallFont));

        rightCell.setBorder(PdfPCell.NO_BORDER);
        table.addCell(rightCell);

        doc.add(table);
    } catch (DocumentException ex) {
        Logger.getLogger(pdf_Export.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:Functions.pdf_Export.java

private void createProductTable(Document doc, Integer soHoaDon) {
    try {//from  w w w  .  ja  v  a2s . c o m
        PdfPTable table = new PdfPTable(new float[] { 10, 35, 15, 20, 20 });
        table.setWidthPercentage(100);
        String[] colName = { "No.", "Product Name", "Quantity", "Price (VND)", "Amount" };
        // table header
        for (int i = 0; i < colName.length; i++) {
            PdfPCell cell = new PdfPCell(new Phrase(colName[i], subFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cell);
        }

        List<ChiTietHoaDon> listCTHD = new ChiTietHoaDonDAO().getListChiTietHoaDon(soHoaDon);
        Integer productAmount = listCTHD.size();
        for (Integer i = 0; i < productAmount; i++) {
            String[] rowValue = getRowValue(i + 1, listCTHD);
            for (int j = 0; j < rowValue.length; j++) {
                PdfPCell cell = new PdfPCell(new Phrase(rowValue[j], smallFont));
                if (j == 1) {
                    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
                } else {
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                }
                table.addCell(cell);
            }
        }

        // add some blank rows
        for (Integer i = productAmount + 1; i < 11; i++) {
            for (int j = 0; j < 5; j++) {
                PdfPCell cell;
                if (j == 0) {
                    cell = new PdfPCell(new Phrase(i.toString(), smallFont));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                } else {
                    cell = new PdfPCell(new Phrase(" "));
                }
                table.addCell(cell);
            }
        }

        doc.add(table);
        Paragraph p = new Paragraph();
        addEmptyLine(p, 1);
        doc.add(p);
    } catch (DocumentException ex) {
        Logger.getLogger(pdf_Export.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:fxml.test.PDFService.java

private PdfPTable createDocumentHeader() throws IOException, BadElementException {

    //start creating header for the document......
    PdfPTable headerTable = new PdfPTable(3);
    headerTable.setHorizontalAlignment(Element.ALIGN_LEFT);
    try {/*from w ww .  j  a  va 2 s  .  co m*/
        headerTable.setTotalWidth(new float[] { 57.5f, 531.5f, 183f });
        headerTable.setLockedWidth(true);

    } catch (DocumentException ex) {
        Logger.getLogger(PDFService.class.getName()).log(Level.SEVERE, null, ex);
    }

    Image image = Image.getInstance(getClass().getClassLoader().getResource("img/sust.jpg"));
    image.scalePercent(42f);
    image.setAlignment(Element.ALIGN_LEFT);
    PdfPCell imageCell = new PdfPCell(image, false);
    imageCell.setPaddingTop(6);
    imageCell.setBorder(Rectangle.NO_BORDER);
    headerTable.addCell(imageCell);

    //start info table.....
    PdfPTable infoTable = new PdfPTable(1);
    infoTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);

    String universityText = "SHAHJALAL UNIVERSITY OF SCIENCE & TECHNOLOGY SYLHET, BANGLADESH";
    String tabulationText = "TABULATION SHEET";
    String deptText = inputs.get(0).trim();

    String s1 = inputs.get(1).trim();
    String s2 = inputs.get(2).trim();
    String semesterText = ("B.Sc (Engg.) " + s1 + " SEMESTER EXAMINATION " + s2);

    String session = inputs.get(3).trim();
    String date = inputs.get(4).trim();

    String sessionDateText = ("SESSION:" + session + " EXAMINATION HELD IN: " + date);

    infoTable.addCell(getCellForHeaderString(universityText, 0, false, 0, Element.ALIGN_CENTER, font10, true));
    infoTable.addCell(getCellForHeaderString(tabulationText, 0, false, 0, Element.ALIGN_CENTER, font10, false));
    infoTable.addCell(getCellForHeaderString(deptText, 0, false, 0, Element.ALIGN_CENTER, font10, false));
    infoTable.addCell(getCellForHeaderString(semesterText, 0, false, 0, Element.ALIGN_CENTER, font10, false));
    infoTable
            .addCell(getCellForHeaderString(sessionDateText, 0, false, 0, Element.ALIGN_CENTER, font10, false));
    //end info table.....

    PdfPCell infoCell = new PdfPCell(infoTable);
    infoCell.setBorder(Rectangle.NO_BORDER);
    headerTable.addCell(infoCell);

    PdfPCell resultPublishDateCell = new PdfPCell(
            new Paragraph("Result Published On............................",
                    new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD)));
    resultPublishDateCell.setBorder(Rectangle.NO_BORDER);
    resultPublishDateCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    resultPublishDateCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    headerTable.addCell(resultPublishDateCell);
    headerTable.setSpacingAfter(17.5f);
    // System.err.println("completed header table");
    return headerTable;
    //end creating header for the document......
}