List of usage examples for com.lowagie.text PageSize LETTER
Rectangle LETTER
To view the source code for com.lowagie.text PageSize LETTER.
Click Source Link
From source file:org.tellervo.desktop.print.ProSheet.java
License:Open Source License
private void generateProSheet(OutputStream output) { Paragraph spacingPara = new Paragraph(); spacingPara.setSpacingBefore(10);/*from w w w .j av a 2 s. c o m*/ spacingPara.add(new Chunk(" ", bodyFont)); try { PdfWriter writer = PdfWriter.getInstance(document, output); document.setPageSize(PageSize.LETTER); // Set basic metadata document.addAuthor("Peter Brewer"); document.addSubject("Corina Provenience Sheet for " + o.getTitle()); HeaderFooter footer = new HeaderFooter(new Phrase(""), new Phrase("")); footer.setAlignment(Element.ALIGN_RIGHT); footer.setBorder(0); document.setFooter(footer); HeaderFooter header = new HeaderFooter(new Phrase(o.getLabCode() + " - " + o.getTitle(), bodyFont), false); header.setAlignment(Element.ALIGN_RIGHT); header.setBorder(0); document.setHeader(header); document.open(); cb = writer.getDirectContent(); // Title Left ColumnText ct = new ColumnText(cb); ct.setSimpleColumn(document.left(), document.top() - 193, document.right(), document.top() - 20, 20, Element.ALIGN_LEFT); ct.addText(getTitlePDF()); ct.go(); // Timestamp ColumnText ct3 = new ColumnText(cb); ct3.setSimpleColumn(document.left(), document.top() - 223, 283, document.top() - 60, 20, Element.ALIGN_LEFT); ct3.setLeading(0, 1.2f); ct3.addText(getTimestampPDF()); ct3.go(); // Pad text document.add(spacingPara); document.add(getObjectDescription()); document.add(getObjectComments()); document.add(spacingPara); getElementTable(); } catch (DocumentException de) { System.err.println(de.getMessage()); } // Close the document document.close(); }
From source file:org.tellervo.desktop.print.SeriesReport.java
License:Open Source License
private void generateSeriesReport(OutputStream output) { displayUnits = NormalTridasUnit//from ww w .j ava2 s .c o m .valueOf(App.prefs.getPref(PrefKey.DISPLAY_UNITS, NormalTridasUnit.MICROMETRES.name().toString())); try { PdfWriter writer = PdfWriter.getInstance(document, output); document.setPageSize(PageSize.LETTER); document.open(); cb = writer.getDirectContent(); // Set basic metadata document.addAuthor("Peter Brewer"); document.addSubject("Tellervo Series Report for " + s.getDisplayTitle()); // Title Left ColumnText ct = new ColumnText(cb); ct.setSimpleColumn(document.left(), document.top() - 163, 283, document.top(), 20, Element.ALIGN_LEFT); ct.addText(getTitlePDF()); ct.go(); // Barcode ColumnText ct2 = new ColumnText(cb); ct2.setSimpleColumn(370, document.top(15) - 100, document.right(0), document.top(0), 20, Element.ALIGN_RIGHT); ct2.addElement(getBarCode()); ct2.go(); // Timestamp ColumnText ct3 = new ColumnText(cb); ct3.setSimpleColumn(document.left(), document.top() - 223, 283, document.top() - 60, 20, Element.ALIGN_LEFT); ct3.setLeading(0, 1.2f); ct3.addText(getTimestampPDF()); ct3.go(); // Authorship ColumnText ct4 = new ColumnText(cb); ct4.setSimpleColumn(284, document.top() - 223, document.right(10), document.top() - 60, 20, Element.ALIGN_RIGHT); ct4.setLeading(0, 1.2f); ct4.addText(getAuthorshipPDF()); ct4.go(); // Pad text document.add(new Paragraph(" ")); Paragraph p2 = new Paragraph(); p2.setSpacingBefore(50); p2.setSpacingAfter(10); p2.add(new Chunk(" ", bodyFont)); document.add(new Paragraph(p2)); // Ring width table getRingWidthTable(); document.add(getParagraphSpace()); if (s.getSeries() instanceof TridasMeasurementSeries) { // MEASUREMENT SERIES //document.add(getRingRemarks()); document.add(getWoodCompletenessPDF()); document.add(getParagraphSpace()); document.add(getSeriesComments()); document.add(getParagraphSpace()); document.add(getInterpretationPDF()); document.add(getParagraphSpace()); document.add(getElementAndSampleInfo()); } else { // DERIVED SERIES getWJTable(); document.add(getParagraphSpace()); document.add(getSeriesComments()); document.add(getParagraphSpace()); //document.add(getRingRemarks()); } } catch (DocumentException de) { System.err.println(de.getMessage()); } // Close the document document.close(); }
From source file:org.tellervo.desktop.util.labels.CornellSampleLabelPage.java
License:Open Source License
public Rectangle getPageSize() { return PageSize.LETTER; }
From source file:org.tn5250j.spoolfile.SpoolExportWizard.java
License:Open Source License
/** * Open the correct type of output file depending on selection(s) *//* w w w .j a va2 s. co m*/ public void openOutputFile() { try { // update status updateStatus("Opening File"); // default to txt extention String suffix = ".txt"; String fileName = ""; // if pdf then change to pdf extenstion if (cvtType.getSelectedIndex() == 0) suffix = ".pdf"; // for e-mailing setup a temporary file if (email.isSelected()) { File dir = new File(System.getProperty("user.dir")); // setup the temp file name String tempFile = spooledFile.getText().trim() + '_' + jobName.getText().trim() + '_' + user.getText().trim() + '_' + spooledFileNumber.getText().trim() + '_' + number.getText().trim(); // create the temporary file File f = File.createTempFile(tempFile, suffix, dir); System.out.println(f.getName()); System.out.println(f.getCanonicalPath()); conicalPath = f.getCanonicalPath(); // set it to delete on exit f.deleteOnExit(); // create the file fw = new FileOutputStream(f); } else if (ifs.isSelected()) { fileName = ifsPathInfo.getText().trim(); ifsfw = new IFSFileOutputStream(splfile.getSystem(), fileName); } else { fileName = pcPathInfo.getText().trim(); fw = new FileOutputStream(fileName); } // if not PDF then this is all we have to do so return if (cvtType.getSelectedIndex() > 0) return; // On pdf's then we need to create a PDF document if (document == null) { document = new Document(); // create the pdf writer based on selection of pc or ifs file if (ifs.isSelected()) { bos = PdfWriter.getInstance(document, ifsfw); } else { bos = PdfWriter.getInstance(document, fw); } // create the base font BaseFont bf = BaseFont.createFont("Courier", "Cp1252", false); // set the default size of the font to 9.0 float fontsize = 9.0f; // if we have a font selectd then try to use it if (fontSize.getText().length() > 0) fontsize = Float.parseFloat(fontSize.getText().trim()); // create the pdf font to use within the document font = new com.lowagie.text.Font(bf, fontsize, com.lowagie.text.Font.NORMAL); // set the PDF properties of the supplied properties if (author.getText().length() > 0) document.addAuthor(author.getText()); if (title.getText().length() > 0) document.addTitle(title.getText()); if (subject.getText().length() > 0) document.addSubject(subject.getText()); // set the page sizes and the page orientation String ps = (String) pageSize.getSelectedItem(); if (ps.equals("A3")) { if (portrait.isSelected()) document.setPageSize(PageSize.A3); else document.setPageSize(PageSize.A3.rotate()); } if (ps.equals("A4")) { if (portrait.isSelected()) document.setPageSize(PageSize.A4); else document.setPageSize(PageSize.A4.rotate()); } if (ps.equals("A5")) { if (portrait.isSelected()) document.setPageSize(PageSize.A5); else document.setPageSize(PageSize.A5.rotate()); } if (ps.equals("LETTER")) { if (portrait.isSelected()) document.setPageSize(PageSize.LETTER); else document.setPageSize(PageSize.LETTER.rotate()); } if (ps.equals("LEGAL")) { if (portrait.isSelected()) document.setPageSize(PageSize.LEGAL); else document.setPageSize(PageSize.LEGAL.rotate()); } if (ps.equals("LEDGER")) { if (portrait.isSelected()) document.setPageSize(PageSize.LEDGER); else document.setPageSize(PageSize.LEDGER.rotate()); } } } catch (IOException _ex) { System.out.println("Cannot open 1 " + _ex.getMessage()); } catch (Exception _ex2) { System.out.println("Cannot open 2 " + _ex2.getMessage()); } }
From source file:org.unitime.timetable.action.SolutionReportAction.java
License:Open Source License
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { SolutionReportForm myForm = (SolutionReportForm) form; sessionContext.checkPermission(Right.SolutionReports); // Read operation to be performed String op = (myForm.getOp() != null ? myForm.getOp() : request.getParameter("op")); Session session = SessionDAO.getInstance().get(sessionContext.getUser().getCurrentAcademicSessionId()); BitSet sessionDays = session.getDefaultDatePattern().getPatternBitSet(); int startDayDayOfWeek = Constants.getDayOfWeek(session.getDefaultDatePattern().getStartDate()); SolverProxy solver = courseTimetablingSolverService.getSolver(); if (solver == null) { request.setAttribute("SolutionReport.message", "Neither a solver is started nor solution is loaded."); } else {/*w ww . j ava2 s . c om*/ try { for (RoomType type : RoomType.findAll()) { RoomReport roomReport = solver.getRoomReport(sessionDays, startDayDayOfWeek, type.getUniqueId()); if (roomReport != null && !roomReport.getGroups().isEmpty()) { WebTable t = getRoomReportTable(request, roomReport, false, type.getUniqueId()); if (t != null) request.setAttribute("SolutionReport.roomReportTable." + type.getReference(), t.printTable( WebTable.getOrder(sessionContext, "solutionReports.roomReport.ord"))); } } RoomReport roomReport = solver.getRoomReport(sessionDays, startDayDayOfWeek, null); if (roomReport != null && !roomReport.getGroups().isEmpty()) { WebTable t = getRoomReportTable(request, roomReport, false, null); if (t != null) request.setAttribute("SolutionReport.roomReportTable.nonUniv", t.printTable(WebTable.getOrder(sessionContext, "solutionReports.roomReport.ord"))); } DeptBalancingReport deptBalancingReport = solver.getDeptBalancingReport(); if (deptBalancingReport != null && !deptBalancingReport.getGroups().isEmpty()) request.setAttribute("SolutionReport.deptBalancingReportTable", getDeptBalancingReportTable(request, deptBalancingReport, false).printTable( WebTable.getOrder(sessionContext, "solutionReports.deptBalancingReport.ord"))); ViolatedDistrPreferencesReport violatedDistrPreferencesReport = solver .getViolatedDistrPreferencesReport(); if (violatedDistrPreferencesReport != null && !violatedDistrPreferencesReport.getGroups().isEmpty()) request.setAttribute("SolutionReport.violatedDistrPreferencesReportTable", getViolatedDistrPreferencesReportTable(request, violatedDistrPreferencesReport, false) .printTable(WebTable.getOrder(sessionContext, "solutionReports.violDistPrefReport.ord"))); DiscouragedInstructorBtbReport discouragedInstructorBtbReportReport = solver .getDiscouragedInstructorBtbReport(); if (discouragedInstructorBtbReportReport != null && !discouragedInstructorBtbReportReport.getGroups().isEmpty()) request.setAttribute("SolutionReport.discouragedInstructorBtbReportReportTable", getDiscouragedInstructorBtbReportReportTable(request, discouragedInstructorBtbReportReport, false).printTable( WebTable.getOrder(sessionContext, "solutionReports.violInstBtb.ord"))); StudentConflictsReport studentConflictsReport = solver.getStudentConflictsReport(); if (studentConflictsReport != null && !studentConflictsReport.getGroups().isEmpty()) request.setAttribute("SolutionReport.studentConflictsReportTable", getStudentConflictsReportTable(request, studentConflictsReport, false) .printTable(WebTable.getOrder(sessionContext, "solutionReports.studConf.ord"))); SameSubpartBalancingReport sameSubpartBalancingReport = solver.getSameSubpartBalancingReport(); if (sameSubpartBalancingReport != null && !sameSubpartBalancingReport.getGroups().isEmpty()) request.setAttribute("SolutionReport.sameSubpartBalancingReportTable", getSameSubpartBalancingReportTable(request, sameSubpartBalancingReport, false) .printTable(PdfWebTable.getOrder(sessionContext, "solutionReports.sectBalancingReport.ord"))); PerturbationReport perturbationReport = solver.getPerturbationReport(); if (perturbationReport != null && !perturbationReport.getGroups().isEmpty()) request.setAttribute("SolutionReport.perturbationReportTable", getPerturbationReportTable(request, perturbationReport, false) .printTable(WebTable.getOrder(sessionContext, "solutionReports.pert.ord"))); } catch (Exception e) { e.printStackTrace(); } } if ("Export PDF".equals(op)) { OutputStream out = ExportUtils.getPdfOutputStream(response, "report"); Document doc = new Document( new Rectangle(60f + PageSize.LETTER.getHeight(), 60f + 0.75f * PageSize.LETTER.getHeight()), 30, 30, 30, 30); PdfWriter iWriter = PdfWriter.getInstance(doc, out); iWriter.setPageEvent(new PdfEventHandler()); doc.open(); boolean atLeastOneRoomReport = false; for (RoomType type : RoomType.findAll()) { RoomReport roomReport = solver.getRoomReport(sessionDays, startDayDayOfWeek, type.getUniqueId()); if (roomReport == null || roomReport.getGroups().isEmpty()) continue; PdfWebTable table = getRoomReportTable(request, roomReport, true, type.getUniqueId()); if (table == null) continue; PdfPTable pdfTable = table .printPdfTable(WebTable.getOrder(sessionContext, "solutionReports.roomReport.ord")); if (!atLeastOneRoomReport) { doc.setPageSize(new Rectangle(60f + table.getWidth(), 60f + 0.75f * table.getWidth())); doc.newPage(); } doc.add(new Paragraph(table.getName(), PdfFont.getBigFont(true))); doc.add(pdfTable); atLeastOneRoomReport = true; } RoomReport roomReport = solver.getRoomReport(sessionDays, startDayDayOfWeek, null); if (roomReport != null && !roomReport.getGroups().isEmpty()) { PdfWebTable table = getRoomReportTable(request, roomReport, true, null); if (table != null) { PdfPTable pdfTable = table .printPdfTable(WebTable.getOrder(sessionContext, "solutionReports.roomReport.ord")); if (!atLeastOneRoomReport) { doc.setPageSize(new Rectangle(60f + table.getWidth(), 60f + 0.75f * table.getWidth())); doc.newPage(); } doc.add(new Paragraph(table.getName(), PdfFont.getBigFont(true))); doc.add(pdfTable); atLeastOneRoomReport = true; } } if (atLeastOneRoomReport) { PdfPTable pdfTable = new PdfPTable(new float[] { 10f, 100f }); pdfTable.setWidthPercentage(100); pdfTable.getDefaultCell().setPadding(3); pdfTable.getDefaultCell().setBorderWidth(0); pdfTable.setSplitRows(false); pdfTable.addCell("Group"); pdfTable.addCell("group size <minimum, maximum)"); pdfTable.addCell("Size"); pdfTable.addCell("actual group size (size of the smallest and the biggest room in the group)"); pdfTable.addCell("NrRooms"); pdfTable.addCell("number of rooms in the group"); pdfTable.addCell("ClUse"); pdfTable.addCell("number of classes that are using a room from the group (actual solution)"); pdfTable.addCell("ClShould"); pdfTable.addCell( "number of classes that \"should\" use a room of the group (smallest available room of a class is in this group)"); pdfTable.addCell("ClMust"); pdfTable.addCell( "number of classes that must use a room of the group (all available rooms of a class are in this group)"); pdfTable.addCell("HrUse"); pdfTable.addCell("average hours a room of the group is used (actual solution)"); pdfTable.addCell("HrShould"); pdfTable.addCell( "average hours a room of the group should be used (smallest available room of a class is in this group)"); pdfTable.addCell("HrMust"); pdfTable.addCell( "average hours a room of this group must be used (all available rooms of a class are in this group)"); pdfTable.addCell(""); pdfTable.addCell("*) cumulative numbers (group minimum ... inf) are displayed in parentheses."); doc.add(pdfTable); } DiscouragedInstructorBtbReport discouragedInstructorBtbReportReport = solver .getDiscouragedInstructorBtbReport(); if (discouragedInstructorBtbReportReport != null && !discouragedInstructorBtbReportReport.getGroups().isEmpty()) { PdfWebTable table = getDiscouragedInstructorBtbReportReportTable(request, discouragedInstructorBtbReportReport, true); PdfPTable pdfTable = table .printPdfTable(WebTable.getOrder(sessionContext, "solutionReports.violInstBtb.ord")); doc.setPageSize(new Rectangle(60f + table.getWidth(), 60f + 0.75f * table.getWidth())); doc.newPage(); doc.add(new Paragraph(table.getName(), PdfFont.getBigFont(true))); doc.add(pdfTable); } ViolatedDistrPreferencesReport violatedDistrPreferencesReport = solver .getViolatedDistrPreferencesReport(); if (violatedDistrPreferencesReport != null && !violatedDistrPreferencesReport.getGroups().isEmpty()) { PdfWebTable table = getViolatedDistrPreferencesReportTable(request, violatedDistrPreferencesReport, true); PdfPTable pdfTable = table .printPdfTable(WebTable.getOrder(sessionContext, "solutionReports.violDistPrefReport.ord")); doc.setPageSize(new Rectangle(60f + table.getWidth(), 60f + 0.75f * table.getWidth())); doc.newPage(); doc.add(new Paragraph(table.getName(), PdfFont.getBigFont(true))); doc.add(pdfTable); } StudentConflictsReport studentConflictsReport = solver.getStudentConflictsReport(); if (studentConflictsReport != null && !studentConflictsReport.getGroups().isEmpty()) { PdfWebTable table = getStudentConflictsReportTable(request, studentConflictsReport, true); PdfPTable pdfTable = table .printPdfTable(WebTable.getOrder(sessionContext, "solutionReports.studConf.ord")); doc.setPageSize(new Rectangle(60f + table.getWidth(), 60f + 0.75f * table.getWidth())); doc.newPage(); doc.add(new Paragraph(table.getName(), PdfFont.getBigFont(true))); doc.add(pdfTable); } SameSubpartBalancingReport sameSubpartBalancingReport = solver.getSameSubpartBalancingReport(); if (sameSubpartBalancingReport != null && !sameSubpartBalancingReport.getGroups().isEmpty()) { PdfWebTable table = getSameSubpartBalancingReportTable(request, sameSubpartBalancingReport, true); PdfPTable pdfTable = table.printPdfTable( WebTable.getOrder(sessionContext, "solutionReports.sectBalancingReport.ord")); doc.setPageSize(new Rectangle(60f + table.getWidth(), 60f + 0.75f * table.getWidth())); doc.newPage(); doc.add(new Paragraph(table.getName(), PdfFont.getBigFont(true))); doc.add(pdfTable); } DeptBalancingReport deptBalancingReport = solver.getDeptBalancingReport(); if (deptBalancingReport != null && !deptBalancingReport.getGroups().isEmpty()) { PdfWebTable table = getDeptBalancingReportTable(request, deptBalancingReport, true); PdfPTable pdfTable = table.printPdfTable( WebTable.getOrder(sessionContext, "solutionReports.deptBalancingReport.ord")); doc.setPageSize(new Rectangle(60f + table.getWidth(), 60f + 0.75f * table.getWidth())); doc.newPage(); doc.add(new Paragraph(table.getName(), PdfFont.getBigFont(true))); doc.add(pdfTable); } PerturbationReport perturbationReport = solver.getPerturbationReport(); if (perturbationReport != null && !perturbationReport.getGroups().isEmpty()) { PdfWebTable table = getPerturbationReportTable(request, perturbationReport, true); PdfPTable pdfTable = table .printPdfTable(WebTable.getOrder(sessionContext, "solutionReports.pert.ord")); doc.setPageSize(new Rectangle(60f + table.getWidth(), 60f + 0.75f * table.getWidth())); doc.newPage(); doc.add(new Paragraph(table.getName(), PdfFont.getBigFont(true))); doc.add(pdfTable); pdfTable = new PdfPTable(new float[] { 5f, 100f }); pdfTable.setWidthPercentage(100); pdfTable.getDefaultCell().setPadding(3); pdfTable.getDefaultCell().setBorderWidth(0); pdfTable.setSplitRows(false); pdfTable.addCell("Class"); pdfTable.addCell("Class name"); pdfTable.addCell("Time"); pdfTable.addCell("Time (initial -> assigned)"); pdfTable.addCell("Room"); pdfTable.addCell("Room (initial -> assigned)"); pdfTable.addCell("Dist"); pdfTable.addCell("Distance between assignments (if different are used buildings)"); pdfTable.addCell("St"); pdfTable.addCell("Number of affected students"); pdfTable.addCell("StT"); pdfTable.addCell("Number of affected students by time change"); pdfTable.addCell("StR"); pdfTable.addCell("Number of affected students by room change"); pdfTable.addCell("StB"); pdfTable.addCell("Number of affected students by building change"); pdfTable.addCell("Ins"); pdfTable.addCell("Number of affected instructors"); pdfTable.addCell("InsT"); pdfTable.addCell("Number of affected instructors by time change"); pdfTable.addCell("InsR"); pdfTable.addCell("Number of affected instructors by room change"); pdfTable.addCell("InsB"); pdfTable.addCell("Number of affected instructors by building change"); pdfTable.addCell("Rm"); pdfTable.addCell("Number of rooms changed"); pdfTable.addCell("Bld"); pdfTable.addCell("Number of buildings changed"); pdfTable.addCell("Tm"); pdfTable.addCell("Number of times changed"); pdfTable.addCell("Day"); pdfTable.addCell("Number of days changed"); pdfTable.addCell("Hr"); pdfTable.addCell("Number of hours changed"); pdfTable.addCell("TFSt"); pdfTable.addCell("Assigned building too far for instructor (from the initial one)"); pdfTable.addCell("TFIns"); pdfTable.addCell("Assigned building too far for students (from the initial one)"); pdfTable.addCell("DStC"); pdfTable.addCell("Difference in student conflicts"); pdfTable.addCell("NStC"); pdfTable.addCell("Number of new student conflicts"); pdfTable.addCell("DTPr"); pdfTable.addCell("Difference in time preferences"); pdfTable.addCell("DRPr"); pdfTable.addCell("Difference in room preferences"); pdfTable.addCell("DInsB"); pdfTable.addCell("Difference in back-to-back instructor preferences"); doc.add(pdfTable); } doc.close(); out.flush(); out.close(); return null; } return mapping.findForward("showSolutionReport"); }
From source file:org.unitime.timetable.reports.PdfLegacyReport.java
License:Open Source License
public void open(OutputStream out, int mode) throws DocumentException, IOException { iOut = out;/*from www .j a v a2 s . c o m*/ if (mode == sModeText) { iPrint = new PrintWriter(iOut); } else { iNrLines = (mode == sModeLedger ? 116 : 50); iDoc = new Document(mode == sModeLedger ? PageSize.LEDGER.rotate() : PageSize.LETTER.rotate()); PdfWriter.getInstance(iDoc, iOut); iDoc.addTitle(iTitle); iDoc.addAuthor("UniTime " + Constants.getVersion() + ", www.unitime.org"); iDoc.addSubject(iSubject); iDoc.addCreator("UniTime " + Constants.getVersion() + ", www.unitime.org"); iDoc.open(); } iEmpty = true; iPageNo = 0; iLineNo = 0; }
From source file:org.unitime.timetable.util.PdfWorksheet.java
License:Open Source License
private PdfWorksheet(OutputStream out, Collection<SubjectArea> subjectAreas, String courseNumber) throws IOException, DocumentException { iUseCommitedAssignments = ApplicationProperty.WorksheetPdfUseCommittedAssignments.isTrue(); iSubjectAreas = new TreeSet<SubjectArea>(new Comparator<SubjectArea>() { @Override// w w w .j a v a 2 s . c om public int compare(SubjectArea s1, SubjectArea s2) { return s1.getSubjectAreaAbbreviation().compareTo(s2.getSubjectAreaAbbreviation()); } }); iSubjectAreas.addAll(subjectAreas); iCourseNumber = courseNumber; if (iCourseNumber != null && (iCourseNumber.trim().length() == 0 || "*".equals(iCourseNumber.trim().length()))) iCourseNumber = null; iDoc = new Document(PageSize.LETTER.rotate()); iOut = out; PdfWriter.getInstance(iDoc, iOut); String session = null; String subjects = ""; for (SubjectArea sa : iSubjectAreas) { if (subjects.isEmpty()) subjects += ", "; subjects += sa.getSubjectAreaAbbreviation(); if (session == null) session += sa.getSession().getLabel(); } iDoc.addTitle(subjects + (iCourseNumber == null ? "" : " " + iCourseNumber) + " Worksheet"); iDoc.addAuthor(ApplicationProperty.WorksheetPdfAuthor.value().replace("%", Constants.getVersion())); iDoc.addSubject(subjects + (session == null ? "" : " -- " + session)); iDoc.addCreator("UniTime " + Constants.getVersion() + ", www.unitime.org"); if (!iSubjectAreas.isEmpty()) iCurrentSubjectArea = iSubjectAreas.first(); iDoc.open(); printHeader(); }
From source file:org.unitime.timetable.webutil.DesignatorListBuilder.java
License:Open Source License
public void pdfTableForSubjectArea(HttpServletRequest request, String subjectAreaId, int order) { SubjectAreaDAO sDao = new SubjectAreaDAO(); SubjectArea sa = sDao.get(new Long(subjectAreaId)); Set designators = sa.getDesignatorInstructors(); // Create new table PdfWebTable webTable = new PdfWebTable(2, sa.getSubjectAreaAbbreviation() + " Designator List", null, new String[] { "Instructor", "Code" }, new String[] { "left", "left" }, new boolean[] { true, true }); webTable.enableHR("#9CB0CE"); if (designators == null || designators.size() == 0) return;//w w w . j a va 2 s. c o m User user = Web.getUser(request.getSession()); String nameFormat = Settings.getSettingValue(user, Constants.SETTINGS_INSTRUCTOR_NAME_FORMAT); String instructorSortOrder = Settings.getSettingValue(user, Constants.SETTINGS_INSTRUCTOR_SORT); for (Iterator i = designators.iterator(); i.hasNext();) { Designator d = (Designator) i.next(); String name = d.getInstructor().getName(nameFormat); String nameOrd = d.getInstructor().nameLastNameFirst().toLowerCase(); if (instructorSortOrder != null && instructorSortOrder.equals(Constants.SETTINGS_INSTRUCTOR_SORT_NATURAL)) nameOrd = name.toLowerCase(); webTable.addLine(null, new String[] { name, d.getCode() }, new Comparable[] { nameOrd, d.getCode() }); } FileOutputStream out = null; try { File file = ApplicationProperties.getTempFile("designators", "pdf"); out = new FileOutputStream(file); Document doc = new Document(PageSize.LETTER, 30, 30, 30, 30); PdfEventHandler.initFooter(doc, out); doc.open(); doc.add(new Paragraph(webTable.getName(), PdfFont.getBigFont(true))); doc.add(webTable.printPdfTable(order)); doc.close(); request.setAttribute(Constants.REQUEST_OPEN_URL, "temp/" + file.getName()); } catch (Exception e) { Debug.error(e); } finally { try { if (out != null) out.close(); } catch (IOException e) { } } }
From source file:org.unitime.timetable.webutil.pdf.PdfEventTableBuilder.java
License:Open Source License
public File pdfTableForEvents(EventListForm form) { List events = loadEvents(form); if (events.isEmpty()) return null; boolean mainContact = form.isAdmin() || form.isEventManager(); FileOutputStream out = null;// w ww . j a v a 2s . c om try { File file = ApplicationProperties.getTempFile("events", "pdf"); iDocument = new Document(PageSize.LETTER, 15, 15, 15, 30); out = new FileOutputStream(file); iWriter = PdfEventHandler.initFooter(iDocument, out); iDocument.open(); iPdfTable = new PdfPTable(getWidths(true, mainContact)); iPdfTable.setWidthPercentage(100); iPdfTable.getDefaultCell().setPadding(3); iPdfTable.getDefaultCell().setBorderWidth(0); iPdfTable.setSplitRows(false); pdfBuildTableHeader(true, mainContact, events.size()); for (Iterator it = events.iterator(); it.hasNext();) { Event event = (Event) it.next(); if (form.getMode() == EventListForm.sModeEvents4Approval) { boolean myApproval = false; for (Iterator j = event.getMeetings().iterator(); j.hasNext();) { Meeting m = (Meeting) j.next(); if (m.getApprovedDate() == null && m.getLocation() != null && form.getManagingDepartments() .contains(m.getLocation().getControllingDepartment())) { myApproval = true; break; } } if (!myApproval) continue; } TreeSet<MultiMeeting> meetings = event.getMultiMeetings(); pdfAddEventsRowsToTable(event, mainContact, meetings); for (MultiMeeting meeting : meetings) pdfAddMeetingRowsToTable(meeting, mainContact, form.getDispConflicts()); } iDocument.add(iPdfTable); iDocument.close(); return file; } catch (Exception e) { Debug.error(e); } finally { try { if (out != null) out.close(); } catch (IOException e) { } } return null; }
From source file:org.unitime.timetable.webutil.pdf.PdfEventTableBuilder.java
License:Open Source License
public File pdfTableForMeetings(MeetingListForm form) { List meetings = loadMeetings(form); if (meetings.isEmpty()) return null; boolean mainContact = form.isAdmin() || form.isEventManager(); FileOutputStream out = null;/*from w w w . j a v a 2 s .com*/ try { File file = ApplicationProperties.getTempFile("meetings", "pdf"); float[] widths = getWidths(false, mainContact); iDocument = new Document(PageSize.LETTER.rotate(), 15, 15, 15, 30); out = new FileOutputStream(file); iWriter = PdfEventHandler.initFooter(iDocument, out); iDocument.open(); iPdfTable = new PdfPTable(widths); iPdfTable.setWidthPercentage(100); iPdfTable.getDefaultCell().setPadding(3); iPdfTable.getDefaultCell().setBorderWidth(0); iPdfTable.setSplitRows(false); pdfBuildTableHeader(false, mainContact, meetings.size()); Event lastEvent = null; Date now = new Date(); boolean line = MeetingListForm.sOrderByName.equals(form.getOrderBy()); for (Iterator it = meetings.iterator(); it.hasNext();) { Meeting meeting = (Meeting) it.next(); pdfAddMeetingRowsToTable(meeting, mainContact, lastEvent, now, line, form.getDispConflicts()); lastEvent = meeting.getEvent(); } iDocument.add(iPdfTable); iDocument.close(); return file; } catch (Exception e) { Debug.error(e); } finally { try { if (out != null) out.close(); } catch (IOException e) { } } return null; }