Example usage for com.lowagie.text Rectangle Rectangle

List of usage examples for com.lowagie.text Rectangle Rectangle

Introduction

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

Prototype

public Rectangle(float urx, float ury) 

Source Link

Document

Constructs a Rectangle -object starting from the origin (0, 0).

Usage

From source file:org.unitime.timetable.export.solver.ExportTimetablePDF.java

License:Apache License

protected void printTables(FilterInterface filter, TimetableGridResponse response, ExportHelper helper)
        throws IOException {
    helper.setup("application/pdf", reference(), true);
    try {//from  w  w w. j  a  v a  2s .c  o m
        Document document = new Document();
        PdfWriter writer = PdfWriter.getInstance(document, helper.getOutputStream());
        writer.setPageEvent(new PdfEventHandler());
        int index = 0;
        int margin = 50;
        int width = 1000;
        for (TimetableGridModel model : response.getModels())
            width = Math.max(width, pageWidth(filter, model, response.getWeekOffset()));
        int displayMode = Integer.valueOf(filter.getParameterValue("dispMode", "0"));
        int height = (displayMode == 2 ? (2 * margin + width) * 22 / 17 - 2 * margin
                : (2 * margin + width) * 17 / 22 - 2 * margin);
        for (TimetableGridModel model : response.getModels())
            height = Math.max(height, pageHeight(filter, model, response.getWeekOffset(), true));
        document.setPageSize(new Rectangle(width + 2 * margin, height + 2 * margin));
        document.setMargins(margin, margin, margin, margin);
        document.open();
        int used = 0;
        if (Integer.valueOf(filter.getParameterValue("dispMode", "0")) == 0) {
            boolean hasDay[] = { true, true, true, true, true, false, false };
            String days = filter.getParameterValue("days");
            if (days != null && days.length() == 7 && days.indexOf('1') >= 0) {
                for (int i = 0; i < 7; i++)
                    hasDay[i] = (days.charAt(i) == '1');
            }
            for (int i = 0; i < 7; i++) {
                if (!hasDay[i])
                    continue;
                String d = "";
                for (int j = 0; j < 7; j++)
                    d += (i == j ? "1" : "0");
                filter.getParameter("days").setValue(d);
                boolean first = true;
                for (TimetableGridModel model : response.getModels()) {
                    if (used > 0
                            && pageHeight(filter, model, response.getWeekOffset(), first) > height - used) {
                        document.newPage();
                        used = 0;
                    }
                    TimetableGrid tg = new TimetableGrid(filter, model, index++, width,
                            response.getWeekOffset(), used == 0 || first);
                    PdfContentByte canvas = writer.getDirectContent();
                    tg.print(canvas, margin, margin + used, height + 2 * margin, null);
                    used += tg.getHeight();
                    first = false;
                }
                used += 25;
            }
        } else {
            for (TimetableGridModel model : response.getModels()) {
                if (used > 0 && pageHeight(filter, model, response.getWeekOffset(), false) > height - used) {
                    document.newPage();
                    used = 0;
                }
                TimetableGrid tg = new TimetableGrid(filter, model, index++, width, response.getWeekOffset(),
                        used == 0);
                PdfContentByte canvas = writer.getDirectContent();
                tg.print(canvas, margin, margin + used, height + 2 * margin, null);
                used += tg.getHeight() + 25;
            }
        }
        if (document != null)
            document.close();
    } catch (DocumentException e) {
        throw new IOException(e.getMessage(), e);
    }
}

From source file:org.unitime.timetable.webutil.DistributionPrefsTableBuilder.java

License:Open Source License

public void toPdfTable(OutputStream out, SessionContext context, Collection distPrefs, String title)
        throws Exception {
    String instructorFormat = UserProperty.NameFormat.get(context.getUser());

    PdfWebTable tbl = new PdfWebTable(5, title, null,
            new String[] { "Preference", "Type", "Structure", "Owner", "Class" },
            new String[] { "left", "left", "left", "left", "left" },
            new boolean[] { true, true, true, true, true });

    int nrPrefs = 0;

    for (Iterator i1 = distPrefs.iterator(); i1.hasNext();) {
        DistributionPref dp = (DistributionPref) i1.next();

        if (!context.hasPermission(dp, Right.DistributionPreferenceDetail))
            continue;

        nrPrefs++;/*  www.ja v a2 s.  c o m*/

        String objStr = "";

        PreferenceGroup pg = dp.getOwner();

        String ownerType = "Unknown";
        if (pg instanceof Department) {
            Department d = (Department) pg;
            ownerType = d.getShortLabel();
        }

        for (Iterator i2 = dp.getOrderedSetOfDistributionObjects().iterator(); i2.hasNext();) {
            DistributionObject dO = (DistributionObject) i2.next();
            objStr += dO.preferenceText();
            if (i2.hasNext())
                objStr += "\n";
        }

        String groupingText = dp.getGroupingName();
        Comparable groupingCmp = (dp.getGrouping() == null ? "0" : dp.getGrouping().toString());

        if (pg instanceof DepartmentalInstructor) {
            DepartmentalInstructor instructor = (DepartmentalInstructor) pg;
            Department d = instructor.getDepartment();
            ownerType = d.getShortLabel();
            TreeSet classes = new TreeSet(
                    new ClassInstructorComparator(new ClassComparator(ClassComparator.COMPARE_BY_HIERARCHY)));
            classes.addAll(instructor.getClasses());
            for (Iterator i2 = classes.iterator(); i2.hasNext();) {
                ClassInstructor clazz = (ClassInstructor) i2.next();
                if (!clazz.isLead().booleanValue())
                    continue;
                if (objStr.length() > 0)
                    objStr += "\n";
                objStr += clazz.getClassInstructing().toString();
            }
            groupingText = "Instructor " + instructor.getName(instructorFormat);
            groupingCmp = instructor.getName(instructorFormat);
        }

        String distType = dp.getDistributionType().getLabel();
        String prefLevel = dp.getPrefLevel().getPrefName();
        String onClick = null;

        tbl.addLine(onClick, new String[] { prefLevel, distType, groupingText, ownerType, objStr },
                new Comparable[] { prefLevel, distType, groupingCmp, ownerType, objStr });

    }

    if (nrPrefs == 0)
        tbl.addLine(null, new String[] { "No preferences found", "", "", "", "" }, null);

    int ord = WebTable.getOrder(context, "distPrefsTable.ord");
    ord = (ord > 0 ? 1 : -1) * (1 + Math.abs(ord));

    PdfPTable table = tbl.printPdfTable(ord);

    float width = tbl.getWidth();

    Document doc = new Document(new Rectangle(60f + width, 60f + 1.30f * width), 30, 30, 30, 30);

    PdfWriter iWriter = PdfWriter.getInstance(doc, out);
    iWriter.setPageEvent(new PdfEventHandler());
    doc.open();

    if (tbl.getName() != null)
        doc.add(new Paragraph(tbl.getName(), PdfFont.getBigFont(true)));

    doc.add(table);

    doc.close();
}

From source file:org.unitime.timetable.webutil.ExamDistributionPrefsTableBuilder.java

License:Open Source License

public void toPdfTable(OutputStream out, HttpServletRequest request, SessionContext context,
        Collection distPrefs, Long examTypeId) throws Exception {
    WebTable.setOrder(context, "examDistPrefsTable.ord", request.getParameter("order"), 4);

    PdfWebTable tbl = new PdfWebTable(4,
            ExamTypeDAO.getInstance().get(examTypeId).getLabel() + " Examination Distribution Preferences",
            null, new String[] { " Preference ", " Type ", " Exam ", " Class/Course " },
            new String[] { "left", "left", "left", "left" }, new boolean[] { true, true, true, true });

    int nrPrefs = 0;

    for (Iterator i1 = distPrefs.iterator(); i1.hasNext();) {
        DistributionPref dp = (DistributionPref) i1.next();

        if (!context.hasPermission(dp, Right.ExaminationDistributionPreferenceDetail))
            continue;

        nrPrefs++;//from  w  w  w  .j a va  2 s. co m

        String examStr = "";
        String objStr = "";

        for (Iterator i2 = dp.getOrderedSetOfDistributionObjects().iterator(); i2.hasNext();) {
            DistributionObject dO = (DistributionObject) i2.next();
            Exam exam = (Exam) dO.getPrefGroup();
            examStr += dO.preferenceText();
            for (Iterator i3 = exam.getOwners().iterator(); i3.hasNext();) {
                ExamOwner owner = (ExamOwner) i3.next();
                objStr += owner.getLabel();
                if (i3.hasNext()) {
                    examStr += "\n";
                    objStr += "\n";
                }
            }
            if (i2.hasNext()) {
                examStr += "\n";
                objStr += "\n";
            }
        }

        String distType = dp.getDistributionType().getLabel();
        String prefLevel = dp.getPrefLevel().getPrefName();

        tbl.addLine(null, new String[] { prefLevel, distType, examStr, objStr },
                new Comparable[] { null, distType, examStr, objStr });

    }

    if (nrPrefs == 0)
        tbl.addLine(null, new String[] { "No preferences found", "", "", "" }, null);

    int ord = WebTable.getOrder(context, "examDistPrefsTable.ord");
    ord = (ord > 0 ? 1 : -1) * (1 + Math.abs(ord));

    PdfPTable table = tbl.printPdfTable(ord);

    float width = tbl.getWidth();

    Document doc = new Document(new Rectangle(60f + width, 60f + 1.30f * width), 30, 30, 30, 30);

    PdfWriter iWriter = PdfWriter.getInstance(doc, out);
    iWriter.setPageEvent(new PdfEventHandler());
    doc.open();

    if (tbl.getName() != null)
        doc.add(new Paragraph(tbl.getName(), PdfFont.getBigFont(true)));

    doc.add(table);

    doc.close();
}

From source file:org.unitime.timetable.webutil.pdf.PdfClassAssignmentReportListTableBuilder.java

License:Open Source License

public void pdfTableForClasses(OutputStream out, ClassAssignmentProxy classAssignment,
        ExamAssignmentProxy examAssignment, ClassAssignmentsReportForm form, SessionContext context)
        throws Exception {
    setVisibleColumns(form);/*from  ww  w .j a va 2 s.com*/

    Collection classes = (Collection) form.getClasses();

    if (isShowTimetable()) {
        boolean hasTimetable = false;
        if (context.hasPermission(Right.ClassAssignments) && classAssignment != null) {
            if (classAssignment instanceof CachedClassAssignmentProxy) {
                ((CachedClassAssignmentProxy) classAssignment).setCache(classes);
            }
            for (Iterator i = classes.iterator(); i.hasNext();) {
                Object[] o = (Object[]) i.next();
                Class_ clazz = (Class_) o[0];
                if (classAssignment.getAssignment(clazz) != null) {
                    hasTimetable = true;
                    break;
                }
            }
        }
        setDisplayTimetable(hasTimetable);
    }
    setUserSettings(context.getUser());

    if (examAssignment != null || Exam.hasTimetable(context.getUser().getCurrentAcademicSessionId())) {
        setShowExam(true);
        setShowExamTimetable(true);
        setShowExamName(false);
    }
    setShowInstructor(true);
    if (StudentClassEnrollment.sessionHasEnrollments(context.getUser().getCurrentAcademicSessionId())) {
        setShowDemand(true);
    }

    float[] widths = getWidths();
    float totalWidth = 0;
    for (int i = 0; i < widths.length; i++)
        totalWidth += widths[i];

    iDocument = new Document(new Rectangle(60f + totalWidth, 60f + 1.30f * totalWidth), 30f, 30f, 30f, 30f);

    iWriter = PdfEventHandler.initFooter(iDocument, out);
    iDocument.open();

    int ct = 0;
    Iterator it = classes.iterator();
    SubjectArea subjectArea = null;
    String prevLabel = null;
    while (it.hasNext()) {
        Object[] o = (Object[]) it.next();
        Class_ c = (Class_) o[0];
        CourseOffering co = (CourseOffering) o[1];
        if (subjectArea == null || !subjectArea.getUniqueId().equals(co.getSubjectArea().getUniqueId())) {
            if (iPdfTable != null) {
                iDocument.add(iPdfTable);
                iDocument.newPage();
            }

            iPdfTable = new PdfPTable(getWidths());
            iPdfTable.setWidthPercentage(100);
            iPdfTable.getDefaultCell().setPadding(3);
            iPdfTable.getDefaultCell().setBorderWidth(0);
            iPdfTable.setSplitRows(false);

            subjectArea = co.getSubjectArea();
            ct = 0;

            iDocument.add(new Paragraph(labelForTable(subjectArea), PdfFont.getBigFont(true)));
            iDocument.add(new Paragraph(" "));
            pdfBuildTableHeader(context.getUser().getCurrentAcademicSessionId());
        }

        pdfBuildClassRow(classAssignment, examAssignment, ++ct, co, c, "", context, prevLabel);
        prevLabel = c.getClassLabel(co);
    }

    if (iPdfTable != null)
        iDocument.add(iPdfTable);

    iDocument.close();
}

From source file:org.unitime.timetable.webutil.pdf.PdfClassListTableBuilder.java

License:Open Source License

public void pdfTableForClasses(OutputStream out, ClassAssignmentProxy classAssignment,
        ExamAssignmentProxy examAssignment, ClassListForm form, SessionContext context) throws Exception {
    setVisibleColumns(form);//from   w w w.j a v a2  s .com

    TreeSet classes = (TreeSet) form.getClasses();
    if (isShowTimetable()) {
        boolean hasTimetable = false;
        if (context.hasPermission(Right.ClassAssignments) && classAssignment != null) {
            if (classAssignment instanceof CachedClassAssignmentProxy) {
                ((CachedClassAssignmentProxy) classAssignment).setCache(classes);
            }
            for (Iterator i = classes.iterator(); i.hasNext();) {
                Object[] o = (Object[]) i.next();
                Class_ clazz = (Class_) o[0];
                if (classAssignment.getAssignment(clazz) != null) {
                    hasTimetable = true;
                    break;
                }
            }
        }
        setDisplayTimetable(hasTimetable);
    }
    setUserSettings(context.getUser());

    if (isShowExam())
        setShowExamTimetable(
                examAssignment != null || Exam.hasTimetable(context.getUser().getCurrentAcademicSessionId()));

    float[] widths = getWidths();
    float totalWidth = 0;
    for (int i = 0; i < widths.length; i++)
        totalWidth += widths[i];

    iDocument = new Document(new Rectangle(60f + totalWidth, 60f + 0.77f * totalWidth), 30f, 30f, 30f, 30f);

    iWriter = PdfEventHandler.initFooter(iDocument, out);
    iDocument.open();

    int ct = 0;
    Iterator it = classes.iterator();
    SubjectArea subjectArea = null;
    String prevLabel = null;
    while (it.hasNext()) {
        Object[] o = (Object[]) it.next();
        Class_ c = (Class_) o[0];
        CourseOffering co = (CourseOffering) o[1];
        if (subjectArea == null || !subjectArea.getUniqueId().equals(co.getSubjectArea().getUniqueId())) {
            if (iPdfTable != null) {
                iDocument.add(iPdfTable);
                iDocument.newPage();
            }

            iPdfTable = new PdfPTable(getWidths());
            iPdfTable.setWidthPercentage(100);
            iPdfTable.getDefaultCell().setPadding(3);
            iPdfTable.getDefaultCell().setBorderWidth(0);
            iPdfTable.setSplitRows(false);

            subjectArea = co.getSubjectArea();
            ct = 0;

            iDocument.add(new Paragraph(labelForTable(subjectArea), PdfFont.getBigFont(true)));
            iDocument.add(new Paragraph(" "));
            pdfBuildTableHeader(context.getUser().getCurrentAcademicSessionId());
        }
        pdfBuildClassRow(classAssignment, examAssignment, ++ct, co, c, "", context, prevLabel);
        prevLabel = c.getClassLabel(co);
    }

    if (iPdfTable != null)
        iDocument.add(iPdfTable);

    iDocument.close();
}

From source file:org.unitime.timetable.webutil.pdf.PdfInstructionalOfferingTableBuilder.java

License:Open Source License

protected void pdfTableForInstructionalOfferings(OutputStream out, ClassAssignmentProxy classAssignment,
        ExamAssignmentProxy examAssignment, TreeSet insructionalOfferings, Long subjectAreaId,
        SessionContext context, boolean displayHeader, boolean allCoursesAreGiven, Comparator classComparator)
        throws Exception {

    if (insructionalOfferings == null)
        return;//www  .jav  a2s  .c o m

    SubjectArea subjectArea = SubjectAreaDAO.getInstance().get(subjectAreaId);

    if (classComparator != null)
        setClassComparator(classComparator);

    if (isShowTimetable()) {
        boolean hasTimetable = false;
        if (context.hasPermission(Right.ClassAssignments) && classAssignment != null) {
            if (classAssignment instanceof CachedClassAssignmentProxy) {
                Vector allClasses = new Vector();
                for (Iterator i = insructionalOfferings.iterator(); !hasTimetable && i.hasNext();) {
                    InstructionalOffering io = (InstructionalOffering) i.next();
                    for (Iterator j = io.getInstrOfferingConfigs().iterator(); !hasTimetable && j.hasNext();) {
                        InstrOfferingConfig ioc = (InstrOfferingConfig) j.next();
                        for (Iterator k = ioc.getSchedulingSubparts().iterator(); !hasTimetable
                                && k.hasNext();) {
                            SchedulingSubpart ss = (SchedulingSubpart) k.next();
                            for (Iterator l = ss.getClasses().iterator(); l.hasNext();) {
                                Class_ clazz = (Class_) l.next();
                                allClasses.add(clazz);
                            }
                        }
                    }
                }
                ((CachedClassAssignmentProxy) classAssignment).setCache(allClasses);
                hasTimetable = !classAssignment.getAssignmentTable(allClasses).isEmpty();
            } else {
                for (Iterator i = insructionalOfferings.iterator(); !hasTimetable && i.hasNext();) {
                    InstructionalOffering io = (InstructionalOffering) i.next();
                    for (Iterator j = io.getInstrOfferingConfigs().iterator(); !hasTimetable && j.hasNext();) {
                        InstrOfferingConfig ioc = (InstrOfferingConfig) j.next();
                        for (Iterator k = ioc.getSchedulingSubparts().iterator(); !hasTimetable
                                && k.hasNext();) {
                            SchedulingSubpart ss = (SchedulingSubpart) k.next();
                            for (Iterator l = ss.getClasses().iterator(); l.hasNext();) {
                                Class_ clazz = (Class_) l.next();
                                if (classAssignment.getAssignment(clazz) != null) {
                                    hasTimetable = true;
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
        setDisplayTimetable(hasTimetable);
    }

    if (isShowExam())
        setShowExamTimetable(
                examAssignment != null || Exam.hasTimetable(context.getUser().getCurrentAcademicSessionId()));

    ArrayList notOfferedOfferings = new ArrayList();
    ArrayList offeredOfferings = new ArrayList();
    ArrayList offeringIds = new ArrayList();

    Iterator it = insructionalOfferings.iterator();
    InstructionalOffering io = null;
    boolean hasOfferedCourses = false;
    boolean hasNotOfferedCourses = false;
    setUserSettings(context.getUser());

    while (it.hasNext()) {
        io = (InstructionalOffering) it.next();
        if (io.isNotOffered() == null || io.isNotOffered().booleanValue()) {
            hasNotOfferedCourses = true;
            notOfferedOfferings.add(io);
        } else {
            hasOfferedCourses = true;
            offeredOfferings.add(io);
        }
    }

    float[] widths = getWidths();
    float totalWidth = 0;
    for (int i = 0; i < widths.length; i++)
        totalWidth += widths[i];

    iDocument.setPageSize(new Rectangle(60f + totalWidth, 60f + 0.77f * totalWidth));

    if (hasOfferedCourses || allCoursesAreGiven) {
        iPdfTable = new PdfPTable(getWidths());
        iPdfTable.setWidthPercentage(100);
        iPdfTable.getDefaultCell().setPadding(3);
        iPdfTable.getDefaultCell().setBorderWidth(0);
        iPdfTable.setSplitRows(false);

        if (displayHeader) {
            if (!iDocument.isOpen())
                iDocument.open();
            else
                iDocument.newPage();
            iDocument.add(new Paragraph(MSG.labelOfferedCourses(subjectArea.getSubjectAreaAbbreviation()),
                    PdfFont.getBigFont(true)));
        }
        pdfBuildTableHeader(context.getUser().getCurrentAcademicSessionId());

        if (hasOfferedCourses) {
            it = offeredOfferings.iterator();
            while (it.hasNext()) {
                io = (InstructionalOffering) it.next();
                offeringIds.add(io.getUniqueId());
                pdfAddInstrOffrRowsToTable(classAssignment, examAssignment, io, subjectAreaId, context);
            }
        } else {
            if (displayHeader)
                iDocument.add(new Paragraph(MSG.errorNoCoursesOffered(subjectArea.getSubjectAreaAbbreviation()),
                        PdfFont.getFont(true, false, Color.RED)));
        }

        iDocument.add(iPdfTable);
    }

    if (hasNotOfferedCourses || allCoursesAreGiven) {
        iPdfTable = new PdfPTable(getWidths());
        iPdfTable.setWidthPercentage(100);
        iPdfTable.getDefaultCell().setPadding(3);
        iPdfTable.getDefaultCell().setBorderWidth(0);
        iPdfTable.setSplitRows(false);

        if (displayHeader) {
            iDocument.newPage();
            iDocument.add(new Paragraph(MSG.labelNotOfferedCourses(subjectArea.getSubjectAreaAbbreviation()),
                    PdfFont.getBigFont(true)));
        }
        pdfBuildTableHeader(context.getUser().getCurrentAcademicSessionId());

        if (hasNotOfferedCourses) {
            it = notOfferedOfferings.iterator();
            while (it.hasNext()) {
                io = (InstructionalOffering) it.next();
                offeringIds.add(io.getUniqueId());
                pdfAddInstrOffrRowsToTable(classAssignment, examAssignment, io, subjectAreaId, context);
            }
        } else {
            if (displayHeader)
                iDocument
                        .add(new Paragraph(MSG.errorAllCoursesOffered(subjectArea.getSubjectAreaAbbreviation()),
                                PdfFont.getFont()));
        }

        iDocument.add(iPdfTable);
    }
}

From source file:org.unitime.timetable.webutil.PdfWebTable.java

License:Open Source License

public void exportPdf(OutputStream out, int ordCol) throws Exception {
    PdfPTable table = printPdfTable(ordCol);

    float width = getWidth();

    Document doc = new Document(new Rectangle(60f + width, 60f + 0.75f * width), 30, 30, 30, 30);

    PdfWriter iWriter = PdfWriter.getInstance(doc, out);
    iWriter.setPageEvent(new PdfEventHandler());
    doc.open();//from   w  w  w.ja  v  a  2 s.  c  o m

    if (iName != null)
        doc.add(new Paragraph(iName, PdfFont.getBigFont(true)));

    doc.add(table);

    doc.close();
}

From source file:org.unitime.timetable.webutil.timegrid.PdfEventGridTable.java

License:Open Source License

public void export(File file) throws Exception {
    if (iModel == null || iModel.isEmpty())
        return;/* w ww . j  a  v a2  s.  c o  m*/

    FileOutputStream out = null;
    try {
        iDocument = new Document(new Rectangle(1100f, 750f), 30, 30, 30, 30);

        out = new FileOutputStream(file);
        PdfEventHandler.initFooter(iDocument, out);
        iDocument.open();

        printTable();

        iDocument.close();
    } finally {
        try {
            if (out != null)
                out.close();
        } catch (IOException e) {
        }
    }
}

From source file:org.unitime.timetable.webutil.timegrid.PdfExamGridTable.java

License:Open Source License

public void export(OutputStream out) throws Exception {
    int nrCols = getNrColumns();
    iDocument = (iForm.getDispMode() == sDispModeInRowHorizontal
            || iForm.getDispMode() == sDispModeInRowVertical
                    ? new Document(
                            new Rectangle(Math.max(PageSize.LETTER.getWidth(), 60.0f + 100.0f * nrCols),
                                    Math.max(PageSize.LETTER.getHeight(), 60.0f + 150f * nrCols)).rotate(),
                            30, 30, 30, 30)
                    : new Document(
                            new Rectangle(Math.max(PageSize.LETTER.getWidth(), 60.0f + 100.0f * nrCols),
                                    Math.max(PageSize.LETTER.getHeight(), 60.0f + 150f * nrCols)),
                            30, 30, 30, 30));

    PdfEventHandler.initFooter(iDocument, out);
    iDocument.open();/* w ww.j a  v  a2s. co  m*/

    printTable();

    printLegend();

    iDocument.close();
}

From source file:org.unitime.timetable.webutil.timegrid.PdfTimetableGridTable.java

License:Open Source License

public void export(OutputStream out) throws Exception {
    int nrCols = getNrColumns();
    iDocument = (iTable.isDispModePerWeekVertical()
            ? new Document(new Rectangle(60.0f + 7.0f * nrCols, 60.0f + 9.3f * nrCols), 30, 30, 30, 30)
            : new Document(new Rectangle(60.0f + 10.0f * nrCols, 60.0f + 7.5f * nrCols), 30, 30, 30, 30));

    iWriter = PdfEventHandler.initFooter(iDocument, out);
    iDocument.open();//from w ww .  j  a  va  2 s .  c  o  m

    if (iTable.isDispModeInRow()) {
        for (iDay = iTable.startDay(); iDay <= iTable.endDay(); iDay++) {
            int rowNumber = 0;
            for (Enumeration e = iTable.models().elements(); e.hasMoreElements(); rowNumber++) {
                printToPdf((TimetableGridModel) e.nextElement(), rowNumber);
            }
            flushTable();
        }
    } else {
        int rowNumber = 0;
        for (Enumeration e = iTable.models().elements(); e.hasMoreElements(); rowNumber++) {
            printToPdf((TimetableGridModel) e.nextElement(), rowNumber);
        }
    }

    printLegend();

    iDocument.close();
}