List of usage examples for com.lowagie.text.pdf BaseFont createFont
public static BaseFont createFont(String name, String encoding, boolean embedded) throws DocumentException, IOException
From source file:com.t2.compassionMeditation.ViewSessionsActivity.java
License:Open Source License
/** * Create a PDF file based on the contents of the graph */// w w w . j av a 2s . c om void CreatePdf() { // Run the export on a separate thread. new Thread(new Runnable() { @Override public void run() { Document document = new Document(); try { Date calendar = Calendar.getInstance().getTime(); mResultsFileName = "BioZenResults_"; mResultsFileName += (calendar.getYear() + 1900) + "-" + (calendar.getMonth() + 1) + "-" + calendar.getDate() + "_"; mResultsFileName += calendar.getHours() + "-" + calendar.getMinutes() + "-" + calendar.getSeconds() + ".pdf"; PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(android.os.Environment.getExternalStorageDirectory() + java.io.File.separator + mResultsFileName)); document.open(); PdfContentByte contentByte = writer.getDirectContent(); BaseFont baseFont = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); // Note top of PDF = 900 float chartWidth = 332; float chartHeight = 45; float spaceHeight = chartHeight + 30; int horizontalPos = 180; float verticalPos = 780; // Write document header contentByte.beginText(); contentByte.setFontAndSize(baseFont, 20); contentByte.showTextAligned(PdfContentByte.ALIGN_CENTER, "T2 BioZen Report", 300, 800, 0); contentByte.showTextAligned(PdfContentByte.ALIGN_CENTER, "Generated on: " + calendar.toLocaleString(), 300, 770, 0); contentByte.endText(); contentByte.setLineWidth(1f); verticalPos -= spaceHeight; long startTime = startCal.getTimeInMillis(); long endTime = endCal.getTimeInMillis(); float maxChartValue = 0; float chartYAvg; BioSession tmpSession = sessionItems.get(0); int maxKeys = tmpSession.keyItemNames.length; // Loop through all of the the keys for (int key = 0; key < maxKeys; key++) { //Draw a border rect contentByte.setRGBColorStrokeF(0, 0, 0); contentByte.setLineWidth(1f); contentByte.rectangle(horizontalPos, verticalPos, chartWidth, chartHeight); contentByte.stroke(); // Write band name contentByte.beginText(); contentByte.setFontAndSize(baseFont, 12); BioSession tmpSession1 = sessionItems.get(0); contentByte.showTextAligned(PdfContentByte.ALIGN_RIGHT, tmpSession1.keyItemNames[key], 170, (verticalPos + (chartHeight / 2)) - 5, 0); contentByte.endText(); maxChartValue = 0; // First find the max Y for (BioSession session : sessionItems) { if (session.time >= startTime && session.time <= endTime) { chartYAvg = session.avgFilteredValue[key]; if (chartYAvg > maxChartValue) maxChartValue = chartYAvg; } } float lastY = -1; float xIncrement = 0; if (sessionItems.size() > 0) { xIncrement = chartWidth / sessionItems.size(); } float yIncrement = 0; if (maxChartValue > 0) { yIncrement = chartHeight / maxChartValue; } float highValue = 0; int highTime = 0; float highY = 0; float highX = 0; int lowTime = 0; float lowY = 100; float lowX = chartWidth; float lowValue = maxChartValue; int lCount = 0; String keyName = ""; ArrayList<RegressionItem> ritems = new ArrayList<RegressionItem>(); // Loop through the session points of this key String rawYValues = ""; for (BioSession session : sessionItems) { keyName = session.keyItemNames[key]; if (session.time >= startTime && session.time <= endTime) { chartYAvg = session.avgFilteredValue[key]; rawYValues += chartYAvg + ", "; if (lastY < 0) lastY = (float) chartYAvg; contentByte.setLineWidth(3f); contentByte.setRGBColorStrokeF(255, 0, 0); float graphXFrom = horizontalPos + (lCount * xIncrement); float graphYFrom = verticalPos + (lastY * yIncrement); float graphXTo = (horizontalPos + ((lCount + 1) * xIncrement)); float graphYTo = verticalPos + (chartYAvg * yIncrement); // Log.e(TAG, "[" + graphXFrom + ", " + graphYFrom + "] to [" + graphXTo + ", " + graphYTo + "]"); // Draw the actual graph contentByte.moveTo(graphXFrom, graphYFrom); contentByte.lineTo(graphXTo, graphYTo); contentByte.stroke(); //Add regression Item ritems.add(new RegressionItem(lCount, (chartYAvg * yIncrement))); if (chartYAvg > highValue) { highValue = chartYAvg; highY = graphYTo; highX = graphXTo; highTime = (int) (session.time / 1000); } if (chartYAvg < lowValue) { lowValue = chartYAvg; lowY = graphYTo; lowX = graphXTo; lowTime = (int) (session.time / 1000); } lCount++; lastY = (float) chartYAvg; } // End if (session.time >= startTime && session.time <= endTime ) } // End for (BioSession session : sessionItems) //Draw high low dates if (highY != 0 && lowY != 0) { SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yy"); String hDate = dateFormat.format(new Date((long) highTime * 1000L)); String lDate = dateFormat.format(new Date((long) lowTime * 1000L)); contentByte.beginText(); contentByte.setFontAndSize(baseFont, 8); contentByte.showTextAligned(PdfContentByte.ALIGN_CENTER, hDate, highX, highY, 0); contentByte.showTextAligned(PdfContentByte.ALIGN_CENTER, lDate, lowX, lowY, 0); contentByte.endText(); } //Draw Regression Line RegressionResult regression = calculateRegression(ritems); contentByte.saveState(); contentByte.setRGBColorStrokeF(0, 0, 250); contentByte.setLineDash(3, 3, 0); contentByte.moveTo(horizontalPos, verticalPos + (float) regression.intercept); contentByte.lineTo(horizontalPos + chartWidth, (float) ((verticalPos + regression.intercept) + (float) (regression.slope * (chartWidth / xIncrement)))); contentByte.stroke(); contentByte.restoreState(); contentByte.setRGBColorStrokeF(0, 0, 0); // Log.e(TAG, keyName + ": [" + rawYValues + "]"); // Get ready for the next key (and series of database points ) verticalPos -= spaceHeight; if (verticalPos < 30) { document.newPage(); verticalPos = 780 - spaceHeight; } } // End for (int key = 0; key < maxKeys; key++) //document.add(new Paragraph("You can also write stuff directly tot he document like this!")); } catch (DocumentException de) { System.err.println(de.getMessage()); Log.e(TAG, de.toString()); } catch (IOException ioe) { System.err.println(ioe.getMessage()); Log.e(TAG, ioe.toString()); } catch (Exception e) { System.err.println(e.getMessage()); Log.e(TAG, e.toString()); } // step 5: we close the document document.close(); fileExportCompleteHandler.sendEmptyMessage(EXPORT_SUCCESS); } }).start(); }
From source file:com.teag.reports.CashFlows.java
private void drawLifeExp() { PdfContentByte cb = writer.getDirectContentUnder(); char c = userInfo.getClientFirstName().charAt(0); char s = ' '; if (!userInfo.isSingle()) { s = userInfo.getSpouseFirstName().charAt(0); }//from w w w . j av a 2 s . c o m String cText = Character.toString(c) + ": " + userInfo.getClientFirstName() + " actuarial life expectancy - " + userInfo.getClientLifeExpectancy() + " years"; String sText = Character.toString(s) + ": " + userInfo.getSpouseFirstName() + " actuarial life expectancy - " + userInfo.getSpouseLifeExpectancy() + " years"; try { BaseFont font = BaseFont.createFont(Locations.getFontLocation() + "times.ttf", BaseFont.CP1252, BaseFont.EMBEDDED); cb.beginText(); cb.setFontAndSize(font, 8); cb.setRGBColorFill(255, 0, 0); cb.setTextMatrix(72 * .5F, .5f * 72); cb.showText(cText); cb.endText(); if (!userInfo.isSingle()) { cb.beginText(); cb.setFontAndSize(font, 8); cb.setRGBColorFill(255, 0, 0); cb.setTextMatrix(72 * .5F, .35f * 72); cb.showText(sText); cb.endText(); } } catch (Exception e) { System.err.println("Error printing Life Expectancy"); } }
From source file:com.teag.reports.EstatePlan.java
private void drawLifeExp() { PdfContentByte cb = writer.getDirectContentUnder(); char c = userInfo.getClientFirstName().charAt(0); char s = ' '; if (!userInfo.isSingle()) { s = userInfo.getSpouseFirstName().charAt(0); }/*from w ww .j av a2 s . c o m*/ String cText = Character.toString(c).toUpperCase() + ": " + userInfo.getClientFirstName() + " actuarial life expectancy - " + userInfo.getClientLifeExpectancy() + " years"; String sText = Character.toString(s).toUpperCase() + ": " + userInfo.getSpouseFirstName() + " actuarial life expectancy - " + userInfo.getSpouseLifeExpectancy() + " years"; try { BaseFont font = BaseFont.createFont(Locations.getFontLocation() + "times.ttf", BaseFont.CP1252, BaseFont.EMBEDDED); cb.beginText(); cb.setFontAndSize(font, 8); cb.setRGBColorFill(255, 0, 0); cb.setTextMatrix(72 * .5F, .4f * 72); cb.showText(cText); cb.endText(); if (!userInfo.isSingle()) { cb.beginText(); cb.setFontAndSize(font, 8); cb.setRGBColorFill(255, 0, 0); cb.setTextMatrix(72 * .5F, .25f * 72); cb.showText(sText); cb.endText(); } } catch (Exception e) { System.err.println("Error printing Life Expectancy"); } }
From source file:com.util.load.RecordDocCreate.java
/** * //from w w w .j a va2 s . c o m * @param unitInfo ??? * @param systemManager ? * @param rank * @param countTol ? * @param countSec ? * @param countThr ? * @param countThir? * @param countMay ? * @param fileName ?? * @return ? 1? */ public static int createRecordDoc(UnitInfo unitInfo, SystemManager systemManager, Rank rank, int countTol, int countSec, int countThr, int countThir, int countMay, File fileName) { Document document = new Document(PageSize.A4, 90.0F, 90.0F, 50.0F, 40.0F); try { RtfWriter2.getInstance(document, new FileOutputStream(fileName)); document.open(); String songPath = ""; String blackFontPath = ""; String fangsongPath = ""; String wingdings2FontPath = ""; if (System.getProperties().getProperty("os.name").toUpperCase().indexOf("WINDOWS") == 0) { songPath = "c:\\windows\\fonts\\msyh.ttf"; blackFontPath = "c:\\windows\\fonts\\simhei.ttf"; fangsongPath = "C:\\Windows\\Fonts\\simfang.ttf"; wingdings2FontPath = "c:\\windows\\fonts\\WINGDNG2.TTF"; } else { /*songPath="/usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono.ttf"; blackFontPath="/usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono-Bold.ttf"; fangsongPath="/usr/share/fonts/truetype/ttf-dejavu/DejaVuSerif.ttf"; wingdings2FontPath="/usr/share/fonts/truetype/unifont/unifont.ttf";*/ songPath = "/usr/share/fonts/dejavu/DejaVuSansMono.ttf"; blackFontPath = "/usr/share/fonts/dejavu/DejaVuSansMono-Bold.ttf"; fangsongPath = "/usr/share/fonts/dejavu/DejaVuSerif.ttf"; wingdings2FontPath = "/usr/share/fonts/dejavu/unifont.ttf"; } BaseFont blackBaseFont = BaseFont.createFont(songPath, "Identity-H", false); BaseFont songFont = BaseFont.createFont(blackFontPath, "Identity-H", false); BaseFont fangsongFont = BaseFont.createFont(fangsongPath, "Identity-H", false); BaseFont wingdings2Font = BaseFont.createFont(wingdings2FontPath, "Identity-H", false); Font songfont_11 = new Font(songFont, 11.0F, 0); Font songfontUnderLine_11 = new Font(songFont, 11.0F, 4); Chunk rightSign = new Chunk("R", new Font(wingdings2Font, 16.0F, 0)); Chunk blankSign = new Chunk("*", new Font(wingdings2Font, 20.0F, 0)); Paragraph p = new Paragraph(); //p.setFont(new Font(songFont, 14.0F, 0)); p.add(" 2"); document.add(p); Paragraph p1 = new Paragraph(); p1.add(new Chunk("?")); Table numTable = new Table(12, 1); numTable.setLeft(0); numTable.setWidth(50.0F); numTable.addCell(""); p1.add(numTable); document.add(p1); /*String docName=""; if("1".equals(rank.getRankOrganType())){ docName="??"; } if("2".equals(rank.getRankOrganType())){ docName="??"; } if("3".equals(rank.getRankOrganType())){ docName="??"; } if("4".equals(rank.getRankOrganType())){ docName="???"; } if("5".equals(rank.getRankOrganType())){ docName="?"; } if("6".equals(rank.getRankOrganType())){ docName="?"; }*/ p = new Paragraph(rank.getSysInfoName() + "?"); p.setFont(new Font(songFont, 36.0F, 1)); p.setAlignment(1); document.add(p); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); p = new Paragraph(); p.setAlignment(1); p.add(new Chunk(" ? ?", new Font(fangsongFont, 16.0F, 0))); p.add(new Chunk("__________", new Font(fangsongFont, 16.0F, 0))); p.add(new Chunk("()", new Font(fangsongFont, 16.0F, 4))); p.add(new Chunk("__________", new Font(fangsongFont, 16.0F, 0))); document.add(p); document.add(Chunk.NEWLINE); p = new Paragraph(); p.setAlignment(1); p.add(new Chunk(" ", new Font(fangsongFont, 16.0F, 0))); p.add(new Chunk("__________________________", new Font(fangsongFont, 16.0F, 0))); document.add(p); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); p = new Paragraph(); p.setAlignment(1); p.add(new Chunk(" ", new Font(fangsongFont, 16.0F, 0))); p.add(new Chunk("__________", new Font(fangsongFont, 16.0F, 0))); p.add(new Chunk("()", new Font(fangsongFont, 16.0F, 4))); p.add(new Chunk("__________", new Font(fangsongFont, 16.0F, 0))); document.add(p); document.add(Chunk.NEWLINE); p = new Paragraph(); p.setAlignment(1); p.add(new Chunk(" ", new Font(fangsongFont, 16.0F, 0))); p.add(new Chunk("__________________________", new Font(fangsongFont, 16.0F, 0))); document.add(p); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); p = new Paragraph(); p.setAlignment(1); p.add(new Chunk("????", new Font(fangsongFont, 16.0F, 0))); p.add(new Chunk("__________", new Font(fangsongFont, 16.0F, 0))); p.add(new Chunk("()", new Font(fangsongFont, 16.0F, 4))); p.add(new Chunk("__________", new Font(fangsongFont, 16.0F, 0))); document.add(p); document.add(Chunk.NEWLINE); p = new Paragraph(); p.setAlignment(1); p.add(new Chunk("? ? ", new Font(fangsongFont, 16.0F, 0))); p.add(new Chunk("__________________________", new Font(fangsongFont, 16.0F, 0))); document.add(p); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); p = new Paragraph(); p.setAlignment(1); p.add(new Chunk("?", new Font(songFont, 20.0F, 1))); document.add(p); p = new Paragraph(); p.setAlignment(1); p.add(new Chunk("", new Font(songFont, 16.0F, 1))); document.add(p); Chapter chapter = new Chapter(1); com.lowagie.text.List list = new com.lowagie.text.List(true, false, 20.0F); //1 ListItem listItem = new ListItem(); Chunk itemChunk = new Chunk("??", new Font(blackBaseFont, 11.0F, 0)); listItem.add(itemChunk); itemChunk = new Chunk( "????[2007]43?"); listItem.add(itemChunk); list.add(listItem); //2 listItem = new ListItem(); itemChunk = new Chunk("", new Font(blackBaseFont, 11.0F, 0)); listItem.add(itemChunk); itemChunk = new Chunk( "???????????????????????????????????????????????"); listItem.add(itemChunk); list.add(listItem); //3 listItem = new ListItem(); itemChunk = new Chunk("??", new Font(blackBaseFont, 11.0F, 0)); listItem.add(itemChunk); itemChunk = new Chunk( "??????"); listItem.add(itemChunk); list.add(listItem); //4 listItem = new ListItem("", new Font(songFont, 11.0F, 0)); listItem.add(blankSign); listItem.add(new Chunk("?", songfont_11)); listItem.add(rightSign); listItem.add(new Chunk("???", songfont_11)); list.add(listItem); //5 listItem = new ListItem(); itemChunk = new Chunk("???", new Font(songFont, 11.0F, 0)); listItem.add(itemChunk); itemChunk = new Chunk( "??11?6????????GA380-20025???????"); listItem.add(itemChunk); list.add(listItem); //6 listItem = new ListItem(); itemChunk = new Chunk("????", new Font(songFont, 11.0F, 0)); listItem.add(itemChunk); itemChunk = new Chunk("?????"); listItem.add(itemChunk); list.add(listItem); //7 listItem = new ListItem(); itemChunk = new Chunk("??", new Font(songFont, 11.0F, 0)); listItem.add(itemChunk); itemChunk = new Chunk("??"); listItem.add(itemChunk); list.add(listItem); //8 listItem = new ListItem(); itemChunk = new Chunk("??????", new Font(songFont, 11.0F, 0)); listItem.add(itemChunk); itemChunk = new Chunk( "???????"); listItem.add(itemChunk); list.add(listItem); //9 listItem = new ListItem(); itemChunk = new Chunk("04?", new Font(songFont, 11.0F, 0)); listItem.add(itemChunk); itemChunk = new Chunk("??(???)?"); listItem.add(itemChunk); list.add(listItem); //10 listItem = new ListItem(); itemChunk = new Chunk("05??", new Font(songFont, 11.0F, 0)); listItem.add(itemChunk); itemChunk = new Chunk("???"); listItem.add(itemChunk); list.add(listItem); //11 listItem = new ListItem(); itemChunk = new Chunk("06", new Font(songFont, 11.0F, 0)); listItem.add(itemChunk); itemChunk = new Chunk("???"); listItem.add(itemChunk); list.add(listItem); //12 listItem = new ListItem(); itemChunk = new Chunk("08", new Font(songFont, 11.0F, 0)); listItem.add(itemChunk); itemChunk = new Chunk( "????????GB/T124041997"); listItem.add(itemChunk); list.add(listItem); //13 listItem = new ListItem(); itemChunk = new Chunk("02?", new Font(songFont, 11.0F, 0)); listItem.add(itemChunk); itemChunk = new Chunk("????????"); listItem.add(itemChunk); list.add(listItem); //14 listItem = new ListItem(); itemChunk = new Chunk("05?", new Font(songFont, 11.0F, 0)); listItem.add(itemChunk); itemChunk = new Chunk(""); listItem.add(itemChunk); list.add(listItem); //15 listItem = new ListItem(); itemChunk = new Chunk("07?", new Font(songFont, 11.0F, 0)); listItem.add(itemChunk); itemChunk = new Chunk( "??????????"); listItem.add(itemChunk); list.add(listItem); //16 listItem = new ListItem(); itemChunk = new Chunk("08?", new Font(songFont, 11.0F, 0)); listItem.add(itemChunk); itemChunk = new Chunk( "?????????"); listItem.add(itemChunk); list.add(listItem); //17 listItem = new ListItem(); itemChunk = new Chunk("", new Font(songFont, 11.0F, 0)); listItem.add(itemChunk); itemChunk = new Chunk( "??????"); listItem.add(itemChunk); list.add(listItem); document.add(list); document.add(Chunk.NEXTPAGE); p = new Paragraph(); p.setAlignment(1); p.add(new Chunk(" ??", new Font(songFont, 16.0F, 0))); document.add(p); Table table1 = new Table(16); table1.setWidth(110.0F); table1.setWidths(new int[] { 20, 5, 5, 5, 5, 5, 5, 10, 25, 5, 5, 5, 5, 5, 5, 10 }); Cell cell = new Cell(new Phrase(new Chunk("01????", songfont_11))); setLocal(cell); table1.addCell(cell); cell = new Cell(unitInfo.getUnitName() == null ? " " : unitInfo.getUnitName()); setLocal(cell); cell.setColspan(15); table1.addCell(cell); cell = new Cell(new Phrase(new Chunk("02???", songfont_11))); setLocal(cell); table1.addCell(cell); cell = new Cell(); Font underLineFont = new Font(songFont, 11.0F, 4); cell.add(new Chunk(unitInfo.getProvince() == null ? "" : unitInfo.getProvince(), underLineFont)); cell.add(new Chunk("?(?) ", songfont_11)); cell.add(new Chunk(unitInfo.getCity() == null ? "" : unitInfo.getCity(), underLineFont)); cell.add(new Chunk(" (???) ", songfont_11)); cell.add(new Chunk(unitInfo.getCounty() == null ? "" : unitInfo.getCounty(), underLineFont)); cell.add(new Chunk("(??)", songfont_11)); cell.setColspan(15); table1.addCell(cell); cell = new Cell(new Phrase(new Chunk("03?", songfont_11))); setLocal(cell); table1.addCell(cell); table1.addCell( new Phrase(new Chunk(unitInfo.getPostcode() == null || "".equals(unitInfo.getPostcode()) ? "" : unitInfo.getPostcode().charAt(0) + "", songfont_11))); table1.addCell( new Phrase(new Chunk(unitInfo.getPostcode() == null || "".equals(unitInfo.getPostcode()) ? "" : unitInfo.getPostcode().charAt(1) + "", songfont_11))); table1.addCell( new Phrase(new Chunk(unitInfo.getPostcode() == null || "".equals(unitInfo.getPostcode()) ? "" : unitInfo.getPostcode().charAt(2) + "", songfont_11))); table1.addCell( new Phrase(new Chunk(unitInfo.getPostcode() == null || "".equals(unitInfo.getPostcode()) ? "" : unitInfo.getPostcode().charAt(3) + "", songfont_11))); table1.addCell( new Phrase(new Chunk(unitInfo.getPostcode() == null || "".equals(unitInfo.getPostcode()) ? "" : unitInfo.getPostcode().charAt(4) + "", songfont_11))); table1.addCell( new Phrase(new Chunk(unitInfo.getPostcode() == null || "".equals(unitInfo.getPostcode()) ? "" : unitInfo.getPostcode().charAt(5) + "", songfont_11))); table1.addCell(""); table1.addCell(new Phrase(new Chunk("04?", songfont_11))); table1.addCell(new Phrase( new Chunk(unitInfo.getDivisionCode() == null || "".equals(unitInfo.getDivisionCode()) ? "" : unitInfo.getDivisionCode().charAt(0) + "", songfont_11))); table1.addCell(new Phrase( new Chunk(unitInfo.getDivisionCode() == null || "".equals(unitInfo.getDivisionCode()) ? "" : unitInfo.getDivisionCode().charAt(1) + "", songfont_11))); table1.addCell(new Phrase( new Chunk(unitInfo.getDivisionCode() == null || "".equals(unitInfo.getDivisionCode()) ? "" : unitInfo.getDivisionCode().charAt(2) + "", songfont_11))); table1.addCell(new Phrase( new Chunk(unitInfo.getDivisionCode() == null || "".equals(unitInfo.getDivisionCode()) ? "" : unitInfo.getDivisionCode().charAt(3) + "", songfont_11))); table1.addCell(new Phrase( new Chunk(unitInfo.getDivisionCode() == null || "".equals(unitInfo.getDivisionCode()) ? "" : unitInfo.getDivisionCode().charAt(4) + "", songfont_11))); table1.addCell(new Phrase( new Chunk(unitInfo.getDivisionCode() == null || "".equals(unitInfo.getDivisionCode()) ? "" : unitInfo.getDivisionCode().charAt(5) + "", songfont_11))); table1.addCell(""); cell = new Cell(new Chunk("05??", new Font(songFont, 11.0F, 0))); setLocal(cell); cell.setRowspan(2); table1.addCell(cell); cell = new Cell(new Chunk(" ??", new Font(songFont, 11.0F, 0))); cell.setColspan(3); table1.addCell(cell); cell = new Cell(new Chunk(unitInfo.getUnitLeader() == null ? "" : unitInfo.getUnitLeader(), new Font(songFont, 11.0F, 0))); cell.setColspan(4); table1.addCell(cell); table1.addCell(new Phrase(new Chunk("?/?", new Font(songFont, 11.0F, 0)))); cell = new Cell(new Phrase( new Chunk(unitInfo.getDuty() == null ? "" : unitInfo.getDuty(), new Font(songFont, 11.0F, 0)))); cell.setColspan(7); table1.addCell(cell); cell = new Cell(new Phrase(new Chunk("?", new Font(songFont, 11.0F, 0)))); cell.setColspan(3); table1.addCell(cell); cell = new Cell(new Chunk(unitInfo.getUnitTel() == null ? "" : unitInfo.getUnitTel(), new Font(songFont, 11.0F, 0))); cell.setColspan(4); table1.addCell(cell); table1.addCell(new Phrase(new Chunk("?", new Font(songFont, 11.0F, 0)))); cell = new Cell(new Phrase(new Chunk(unitInfo.getUnitEmail() == null ? "" : unitInfo.getUnitEmail(), new Font(songFont, 11.0F, 0)))); cell.setColspan(7); table1.addCell(cell); cell = new Cell(new Phrase(new Chunk("06", new Font(songFont, 11.0F, 0)))); setLocal(cell); table1.addCell(cell); cell = new Cell(new Chunk(unitInfo.getUnitDep() == null ? "" : unitInfo.getUnitDep(), new Font(songFont, 11.0F, 0))); cell.setColspan(15); table1.addCell(cell); cell = new Cell(new Phrase(new Chunk("07?", new Font(songFont, 11.0F, 0)))); setLocal(cell); cell.setRowspan(3); table1.addCell(cell); cell = new Cell(new Phrase(new Chunk(" ??", new Font(songFont, 11.0F, 0)))); cell.setColspan(3); table1.addCell(cell); cell = new Cell(new Chunk(unitInfo.getDepContact() == null ? "" : unitInfo.getDepContact(), new Font(songFont, 11.0F, 0))); cell.setColspan(4); table1.addCell(cell); table1.addCell(new Phrase(new Chunk("?/?", new Font(songFont, 11.0F, 0)))); cell = new Cell(new Chunk(unitInfo.getDepDuty() == null ? "" : unitInfo.getDepDuty(), new Font(songFont, 11.0F, 0))); cell.setColspan(7); table1.addCell(cell); cell = new Cell(new Phrase(new Chunk("?", new Font(songFont, 11.0F, 0)))); cell.setColspan(3); table1.addCell(cell); cell = new Cell(new Chunk(unitInfo.getDepTel() == null ? "" : unitInfo.getDepTel(), new Font(songFont, 11.0F, 0))); cell.setColspan(4); table1.addCell(cell); cell = new Cell(new Phrase(new Chunk("?", new Font(songFont, 11.0F, 0)))); cell.setRowspan(2); table1.addCell(cell); cell = new Cell(new Chunk(unitInfo.getDepEmail() == null ? "" : unitInfo.getDepEmail(), new Font(songFont, 11.0F, 0))); cell.setColspan(7); cell.setRowspan(2); table1.addCell(cell); cell = new Cell(new Phrase(new Chunk("?", new Font(songFont, 11.0F, 0)))); cell.setColspan(3); table1.addCell(cell); cell = new Cell(new Chunk(unitInfo.getDepMobile() == null ? "" : unitInfo.getDepMobile(), new Font(songFont, 11.0F, 0))); cell.setColspan(4); table1.addCell(cell); cell = new Cell(new Phrase(new Chunk("08", new Font(songFont, 11.0F, 0)))); setLocal(cell); table1.addCell(cell); cell = new Cell("".equals(unitInfo.getSubordinate()) ? rightSign : blankSign); cell.add(new Chunk("1\t", new Font(songFont, 11.0F, 0))); cell.add("?".equals(unitInfo.getSubordinate()) ? rightSign : blankSign); cell.add(new Chunk("2?(?)\t", new Font(songFont, 11.0F, 0))); cell.add("".equals(unitInfo.getSubordinate()) ? rightSign : blankSign); cell.add(new Chunk("3(???)\t", new Font(songFont, 11.0F, 0))); cell.add(Chunk.NEWLINE); cell.add("".equals(unitInfo.getSubordinate()) ? rightSign : blankSign); cell.add(new Chunk("4(??)\t", new Font(songFont, 11.0F, 0))); cell.add("".equals(unitInfo.getSubordinate()) ? rightSign : blankSign); cell.add(new Chunk("9", new Font(songFont, 11.0F, 0))); cell.add(new Chunk(unitInfo.getOtherSub() != null ? unitInfo.getOtherSub() : "________", new Font(songFont, 11.0F, 4))); cell.setColspan(15); table1.addCell(cell); cell = new Cell(new Phrase(new Chunk("09??", new Font(songFont, 11.0F, 0)))); setLocal(cell); table1.addCell(cell); cell = new Cell("".equals(unitInfo.getUnitType()) ? rightSign : blankSign); cell.add(new Chunk("1\t\t", songfont_11)); cell.add("".equals(unitInfo.getUnitType()) ? rightSign : blankSign); cell.add(new Chunk("2\t\t", songfont_11)); cell.add("??".equals(unitInfo.getUnitType()) ? rightSign : blankSign); cell.add(new Chunk("3??\t\t", songfont_11)); cell.add("?".equals(unitInfo.getUnitType()) ? rightSign : blankSign); cell.add(new Chunk("4?", songfont_11)); cell.add(Chunk.NEWLINE); cell.add("".equals(unitInfo.getUnitType()) ? rightSign : blankSign); cell.add(new Chunk("9", songfont_11)); cell.add(new Chunk(unitInfo.getOtherUnitType() != null ? unitInfo.getOtherUnitType() : "________", new Font(songFont, 11.0F, 4))); cell.setColspan(15); table1.addCell(cell); cell = new Cell(new Phrase(new Chunk("10", songfont_11))); setLocal(cell); table1.addCell(cell); cell = new Cell("".equals(unitInfo.getEmployment()) ? rightSign : blankSign); cell.add(new Chunk("11\t\t", songfont_11)); cell.add("".equals(unitInfo.getEmployment()) ? rightSign : blankSign); cell.add(new Chunk("12\t", songfont_11)); cell.add("???".equals(unitInfo.getEmployment()) ? rightSign : blankSign); cell.add(new Chunk("13???", songfont_11)); cell.add(Chunk.NEWLINE); cell.add("?".equals(unitInfo.getEmployment()) ? rightSign : blankSign); cell.add(new Chunk("21?\t\t", songfont_11)); cell.add("".equals(unitInfo.getEmployment()) ? rightSign : blankSign); cell.add(new Chunk("22\t", songfont_11)); cell.add("".equals(unitInfo.getEmployment()) ? rightSign : blankSign); cell.add(new Chunk("23\t\t\t", songfont_11)); cell.add("".equals(unitInfo.getEmployment()) ? rightSign : blankSign); cell.add(new Chunk("24", songfont_11)); cell.add(Chunk.NEWLINE); cell.add("".equals(unitInfo.getEmployment()) ? rightSign : blankSign); cell.add(new Chunk("25\t\t", songfont_11)); cell.add("".equals(unitInfo.getEmployment()) ? rightSign : blankSign); cell.add(new Chunk("26\t", songfont_11)); cell.add("?".equals(unitInfo.getEmployment()) ? rightSign : blankSign); cell.add(new Chunk("27?\t\t\t", songfont_11)); cell.add("?".equals(unitInfo.getEmployment()) ? rightSign : blankSign); cell.add(new Chunk("28?", songfont_11)); cell.add(Chunk.NEWLINE); cell.add("".equals(unitInfo.getEmployment()) ? rightSign : blankSign); cell.add(new Chunk("31\t", songfont_11)); cell.add("".equals(unitInfo.getEmployment()) ? rightSign : blankSign); cell.add(new Chunk("32\t", songfont_11)); cell.add("?".equals(unitInfo.getEmployment()) ? rightSign : blankSign); cell.add(new Chunk("33?\t", songfont_11)); cell.add("".equals(unitInfo.getEmployment()) ? rightSign : blankSign); cell.add(new Chunk("34", songfont_11)); cell.add(Chunk.NEWLINE); cell.add("".equals(unitInfo.getEmployment()) ? rightSign : blankSign); cell.add(new Chunk("35\t\t", songfont_11)); cell.add("".equals(unitInfo.getEmployment()) ? rightSign : blankSign); cell.add(new Chunk("36\t", songfont_11)); cell.add("?".equals(unitInfo.getEmployment()) ? rightSign : blankSign); cell.add(new Chunk("37?\t\t\t", songfont_11)); cell.add("?".equals(unitInfo.getEmployment()) ? rightSign : blankSign); cell.add(new Chunk("38?", songfont_11)); cell.add(Chunk.NEWLINE); cell.add("".equals(unitInfo.getEmployment()) ? rightSign : blankSign); cell.add(new Chunk("39\t\t", songfont_11)); cell.add("".equals(unitInfo.getEmployment()) ? rightSign : blankSign); cell.add(new Chunk("40\t", songfont_11)); cell.add("?".equals(unitInfo.getEmployment()) ? rightSign : blankSign); cell.add(new Chunk("41?\t\t", songfont_11)); cell.add("".equals(unitInfo.getEmployment()) ? rightSign : blankSign); cell.add(new Chunk("42", songfont_11)); cell.add(Chunk.NEWLINE); cell.add("".equals(unitInfo.getEmployment()) ? rightSign : blankSign); cell.add(new Chunk("43\t\t", songfont_11)); cell.add("".equals(unitInfo.getEmployment()) ? rightSign : blankSign); cell.add(new Chunk("44\t", songfont_11)); cell.add("?".equals(unitInfo.getEmployment()) ? rightSign : blankSign); cell.add(new Chunk("45?\t\t\t", songfont_11)); cell.add("".equals(unitInfo.getEmployment()) ? rightSign : blankSign); cell.add(new Chunk("46", songfont_11)); cell.add(Chunk.NEWLINE); cell.add("".equals(unitInfo.getEmployment()) ? rightSign : blankSign); cell.add(new Chunk("47\t\t", songfont_11)); cell.add("".equals(unitInfo.getEmployment()) ? rightSign : blankSign); cell.add(new Chunk("48\t", songfont_11)); cell.add("??".equals(unitInfo.getEmployment()) ? rightSign : blankSign); cell.add(new Chunk("49??\t\t\t", songfont_11)); cell.add("".equals(unitInfo.getEmployment()) ? rightSign : blankSign); cell.add(new Chunk("50", songfont_11)); cell.add(Chunk.NEWLINE); cell.add("".equals(unitInfo.getEmployment()) ? rightSign : blankSign); cell.add(new Chunk("51\t\t", songfont_11)); cell.add("??".equals(unitInfo.getEmployment()) ? rightSign : blankSign); cell.add(new Chunk("52??\t", songfont_11)); cell.add(Chunk.NEWLINE); cell.add("".equals(unitInfo.getOtherEmp()) ? rightSign : blankSign); cell.add(new Chunk("99", songfont_11)); cell.add(new Chunk("".equals(unitInfo.getOtherEmp()) ? unitInfo.getOtherEmp() : "________")); cell.setColspan(15); table1.addCell(cell); cell = new Cell(new Phrase(new Chunk("11?", songfont_11))); setLocal(cell); cell.setRowspan(2); table1.addCell(cell); cell = new Cell(new Phrase(new Chunk(countTol + "", songfont_11))); setLocal(cell); cell.setColspan(2); cell.setRowspan(2); table1.addCell(cell); cell = new Cell(new Phrase(new Chunk("12?", songfont_11))); cell.setColspan(5); table1.addCell(cell); cell = new Cell(new Phrase(new Chunk(countSec + "", songfont_11))); setLocal(cell); cell.setColspan(1); table1.addCell(cell); cell = new Cell(new Phrase(new Chunk("13?", songfont_11))); cell.setColspan(6); table1.addCell(cell); cell = new Cell(new Phrase(new Chunk(countThr + "", songfont_11))); cell.setColspan(1); setLocal(cell); table1.addCell(cell); cell = new Cell(new Phrase(new Chunk("14?", songfont_11))); cell.setColspan(5); table1.addCell(cell); cell = new Cell(new Phrase(new Chunk(countThir + "", songfont_11))); cell.setColspan(1); setLocal(cell); table1.addCell(cell); cell = new Cell(new Phrase(new Chunk("15?", songfont_11))); cell.setColspan(6); table1.addCell(cell); cell = new Cell(new Phrase(new Chunk("0", songfont_11))); cell.setColspan(1); setLocal(cell); table1.addCell(cell); document.add(table1); document.add(Chunk.NEXTPAGE); p = new Paragraph(); p.setAlignment(1); p.add(new Chunk(" (" + rank.getSysInfoName() + ")?", new Font(songFont, 16.0F, 0))); document.add(p); Table table2 = new Table(14); table2.setWidth(120.0F); table2.setWidths(new int[] { 8, 13, 5, 12, 3, 8, 5, 5, 5, 13, 5, 5, 5, 5 }); cell = new Cell(new Phrase(new Chunk("01??", songfont_11))); setLocal(cell); cell.setColspan(2); table2.addCell(cell); cell = new Cell(new Chunk(rank.getSysInfoName() == null ? "" : rank.getSysInfoName(), songfont_11)); cell.setColspan(7); table2.addCell(cell); table2.addCell(new Phrase(new Chunk("02?", songfont_11))); cell = new Cell(new Chunk(rank.getSysInfoId() == null ? "" : rank.getSysInfoId(), songfont_11)); cell.setColspan(4); table2.addCell(cell); cell = new Cell(new Phrase(new Chunk("03", songfont_11))); setLocal(cell); cell.setRowspan(2); table2.addCell(cell); cell = new Cell(new Phrase(new Chunk("", songfont_11))); setLocal(cell); table2.addCell(cell); cell = new Cell("1".equals(systemManager.getBusType()) ? rightSign : blankSign); cell.add(new Chunk("1\t", songfont_11)); cell.add("2".equals(systemManager.getBusType()) ? rightSign : blankSign); cell.add(new Chunk("2\t", songfont_11)); cell.add("3".equals(systemManager.getBusType()) ? rightSign : blankSign); cell.add(new Chunk("3?\t", songfont_11)); cell.add("4".equals(systemManager.getBusType()) ? rightSign : blankSign); cell.add(new Chunk("4\t\n", songfont_11)); cell.add("5".equals(systemManager.getBusType()) ? rightSign : blankSign); cell.add(new Chunk("5?\t", songfont_11)); cell.add("9".equals(systemManager.getBusType()) ? rightSign : blankSign); cell.add(new Chunk("9", songfont_11)); cell.add(new Chunk( systemManager.getOtherBusType() != null ? systemManager.getOtherBusType() : "________", songfontUnderLine_11)); cell.setColspan(12); table2.addCell(cell); cell = new Cell(new Phrase(new Chunk("??", songfont_11))); setLocal(cell); table2.addCell(cell); cell = new Cell(new Chunk(systemManager.getBusDescription(), songfont_11)); cell.setColspan(12); table2.addCell(cell); cell = new Cell(new Phrase(new Chunk("04?", songfont_11))); setLocal(cell); cell.setRowspan(2); table2.addCell(cell); cell = new Cell(new Phrase(new Chunk("?", songfont_11))); setLocal(cell); table2.addCell(cell); cell = new Cell("10".equals(systemManager.getSerArea()) ? rightSign : blankSign); cell.add(new Chunk("10\t", songfont_11)); cell.add(new Chunk("11".equals(systemManager.getSerArea()) ? rightSign : blankSign)); cell.add(new Chunk("11??", songfont_11)); cell.add(new Chunk(systemManager.getProTotal() != null ? systemManager.getProTotal() + "" : "________", songfontUnderLine_11)); cell.add(new Chunk("\t", songfont_11)); cell.add("20".equals(systemManager.getSerArea()) ? rightSign : blankSign); cell.add(new Chunk("20??\t\n", songfont_11)); cell.add("21".equals(systemManager.getSerArea()) ? rightSign : blankSign); cell.add(new Chunk("21? ", songfont_11)); cell.add( new Chunk(systemManager.getCityTotal() != null ? systemManager.getCityTotal() + "" : "________", songfontUnderLine_11)); cell.add(new Chunk("\t", songfont_11)); cell.add("30".equals(systemManager.getSerArea()) ? rightSign : blankSign); cell.add(new Chunk("30?\t", songfont_11)); cell.add(new Chunk("99".equals(systemManager.getSerArea()) ? rightSign : blankSign)); cell.add(new Chunk("99", songfont_11)); cell.add(new Chunk(systemManager.getOtherArea() != null ? systemManager.getOtherArea() : "________", songfontUnderLine_11)); cell.setColspan(12); table2.addCell(cell); cell = new Cell(new Phrase(new Chunk("?", songfont_11))); setLocal(cell); table2.addCell(cell); cell = new Cell("1".equals(systemManager.getSerObj()) ? rightSign : blankSign); cell.add(new Chunk("1?? ", songfont_11)); cell.add("2".equals(systemManager.getSerObj()) ? rightSign : blankSign); cell.add(new Chunk("2 ", songfont_11)); cell.add("3".equals(systemManager.getSerObj()) ? rightSign : blankSign); cell.add(new Chunk("3? ", songfont_11)); cell.add("9".equals(systemManager.getSerObj()) ? rightSign : blankSign); cell.add(new Chunk("9", songfont_11)); cell.add(new Chunk(systemManager.getOtherObj() != null ? systemManager.getOtherObj() : "________", songfontUnderLine_11)); cell.setColspan(12); table2.addCell(cell); cell = new Cell(new Phrase(new Chunk("05?", songfont_11))); setLocal(cell); cell.setRowspan(2); table2.addCell(cell); cell = new Cell(new Phrase(new Chunk("", songfont_11))); setLocal(cell); table2.addCell(cell); cell = new Cell("1".equals(rank.getRankCoveArea()) ? rightSign : blankSign); cell.add(new Chunk("1\t", songfont_11)); cell.add("2".equals(rank.getRankCoveArea()) ? rightSign : blankSign); cell.add(new Chunk("2\t", songfont_11)); cell.add("3".equals(rank.getRankCoveArea()) ? rightSign : blankSign); cell.add(new Chunk("3\t", songfont_11)); cell.add("4".equals(rank.getRankCoveArea()) ? rightSign : blankSign); cell.add(new Chunk("9", songfont_11)); cell.add(new Chunk(rank.getRankOthArea() != null ? rank.getRankOthArea() : "________", songfontUnderLine_11)); cell.setColspan(12); table2.addCell(cell); cell = new Cell(new Phrase(new Chunk("", songfont_11))); setLocal(cell); table2.addCell(cell); cell = new Cell("1".equals(rank.getRankNetworkProp()) ? rightSign : blankSign); cell.add(new Chunk("1\t", songfont_11)); cell.add("2".equals(rank.getRankNetworkProp()) ? rightSign : blankSign); cell.add(new Chunk("2?\t", songfont_11)); cell.add("3".equals(rank.getRankNetworkProp()) ? rightSign : blankSign); cell.add(new Chunk("9", songfont_11)); cell.add(new Chunk(rank.getRankOthNetworkProp() != null ? rank.getRankOthNetworkProp() : "________", songfontUnderLine_11)); cell.setColspan(12); table2.addCell(cell); cell = new Cell(new Phrase(new Chunk("06?", songfont_11))); setLocal(cell); cell.setColspan(2); table2.addCell(cell); cell = new Cell("1".equals(rank.getRankSysConn()) ? rightSign : blankSign); cell.add(new Chunk("1\t", songfont_11)); cell.add("2".equals(rank.getRankSysConn()) ? rightSign : blankSign); cell.add(new Chunk("2??\t\n", songfont_11)); cell.add("3".equals(rank.getRankSysConn()) ? rightSign : blankSign); cell.add(new Chunk("3??\t", songfont_11)); cell.add("4".equals(rank.getRankSysConn()) ? rightSign : blankSign); cell.add(new Chunk("9", songfont_11)); cell.add(new Chunk(rank.getRankOtherSysConn() != null ? rank.getRankOtherSysConn() : "________", songfontUnderLine_11)); cell.setColspan(12); table2.addCell(cell); cell = new Cell(new Phrase(new Chunk("07?", songfont_11))); cell.setColspan(2); cell.setRowspan(8); setLocal(cell); table2.addCell(cell); cell = new Cell(new Phrase(new Chunk("??", songfont_11))); setLocal(cell); cell.setRowspan(2); table2.addCell(cell); cell = new Cell(new Phrase(new Chunk("?", songfont_11))); setLocal(cell); cell.setRowspan(2); cell.setColspan(2); table2.addCell(cell); cell = new Cell(new Phrase(new Chunk("?", songfont_11))); setLocal(cell); cell.setRowspan(2); table2.addCell(cell); cell = new Cell(new Phrase(new Chunk("?", songfont_11))); setLocal(cell); cell.setColspan(8); table2.addCell(cell); cell = new Cell(new Phrase(new Chunk(" ", songfont_11))); setLocal(cell); cell.setColspan(2); table2.addCell(cell); cell = new Cell(new Phrase(new Chunk(" ", songfont_11))); setLocal(cell); cell.setColspan(2); table2.addCell(cell); cell = new Cell(new Phrase(new Chunk("? ", songfont_11))); setLocal(cell); cell.setColspan(4); table2.addCell(cell); for (int i = 1; i <= 6; i++) { table2.addCell(new Phrase(new Chunk(i + "", songfont_11))); switch (i) { case 1: cell = new Cell(new Chunk("?", songfont_11)); cell.setColspan(2); table2.addCell(cell); table2.addCell(new Phrase(new Chunk(rank.getRankSecCount(), songfont_11))); cell = new Cell(("100".equals(rank.getRankSecUse())) ? rightSign : blankSign); setLocal(cell); cell.setColspan(2); table2.addCell(cell); cell = new Cell(("0".equals(rank.getRankSecUse())) ? rightSign : blankSign); setLocal(cell); cell.setColspan(2); table2.addCell(cell); cell = new Cell(("3".equals(rank.getRankSecUse())) ? rightSign : blankSign); setLocal(cell); cell.add(new Chunk( (rank.getPartRankSecUse() != null ? rank.getPartRankSecUse() : "________") + "%", songfontUnderLine_11)); cell.setColspan(4); table2.addCell(cell); break; case 2: cell = new Cell(new Chunk("?", songfont_11)); cell.setColspan(2); table2.addCell(cell); table2.addCell(new Phrase(new Chunk(rank.getRankNetCount(), songfont_11))); cell = new Cell(("100".equals(rank.getRankNetUse())) ? rightSign : blankSign); setLocal(cell); cell.setColspan(2); table2.addCell(cell); cell = new Cell(("0".equals(rank.getRankNetUse())) ? rightSign : blankSign); setLocal(cell); cell.setColspan(2); table2.addCell(cell); cell = new Cell(("3".equals(rank.getRankNetUse())) ? rightSign : blankSign); setLocal(cell); cell.add(new Chunk( (rank.getPartRankNetUse() != null ? rank.getPartRankNetUse() : "________") + "%", songfontUnderLine_11)); cell.setColspan(4); table2.addCell(cell); break; case 3: cell = new Cell(new Chunk("?", songfont_11)); cell.setColspan(2); table2.addCell(cell); table2.addCell(new Phrase(new Chunk(rank.getRankSysCount(), songfont_11))); cell = new Cell(("100".equals(rank.getRankSysUse())) ? rightSign : blankSign); setLocal(cell); cell.setColspan(2); table2.addCell(cell); cell = new Cell(("0".equals(rank.getRankSysUse())) ? rightSign : blankSign); setLocal(cell); cell.setColspan(2); table2.addCell(cell); cell = new Cell(("3".equals(rank.getRankSysUse())) ? rightSign : blankSign); setLocal(cell); cell.add(new Chunk( (rank.getPartRankSysUse() != null ? rank.getPartRankSysUse() : "________") + "%", songfontUnderLine_11)); cell.setColspan(4); table2.addCell(cell); break; case 4: cell = new Cell(new Chunk("?", songfont_11)); cell.setColspan(2); table2.addCell(cell); table2.addCell(new Phrase(new Chunk(rank.getRankSqlCount(), songfont_11))); cell = new Cell(("100".equals(rank.getRankSqlUse())) ? rightSign : blankSign); setLocal(cell); cell.setColspan(2); table2.addCell(cell); cell = new Cell(("0".equals(rank.getRankSqlUse())) ? rightSign : blankSign); setLocal(cell); cell.setColspan(2); table2.addCell(cell); cell = new Cell(("3".equals(rank.getRankSqlUse())) ? rightSign : blankSign); setLocal(cell); cell.add(new Chunk( (rank.getPartRankSqlUse() != null ? rank.getPartRankSqlUse() : "________") + "%", songfontUnderLine_11)); cell.setColspan(4); table2.addCell(cell); break; case 5: cell = new Cell(new Chunk("?", songfont_11)); cell.setColspan(2); table2.addCell(cell); table2.addCell(new Phrase(new Chunk(rank.getRankSerCount(), songfont_11))); cell = new Cell(("100".equals(rank.getRankSerUse())) ? rightSign : blankSign); setLocal(cell); cell.setColspan(2); table2.addCell(cell); cell = new Cell(("0".equals(rank.getRankSerUse())) ? rightSign : blankSign); setLocal(cell); cell.setColspan(2); table2.addCell(cell); cell = new Cell(("3".equals(rank.getRankSerUse())) ? rightSign : blankSign); setLocal(cell); cell.add(new Chunk( (rank.getPartRankSerUse() != null ? rank.getPartRankSerUse() : "________") + "%", songfontUnderLine_11)); cell.setColspan(4); table2.addCell(cell); break; case 6: cell = new Cell(new Chunk("", songfont_11)); cell.add(new Chunk((rank.getRankOthProd() != null ? rank.getRankOthProd() : "________"), songfontUnderLine_11)); cell.setColspan(2); table2.addCell(cell); table2.addCell(new Phrase(new Chunk(rank.getRankOthProdCount(), songfont_11))); cell = new Cell(("100".equals(rank.getRankOthProdUse())) ? rightSign : blankSign); setLocal(cell); cell.setColspan(2); table2.addCell(cell); cell = new Cell(("0".equals(rank.getRankOthProdUse())) ? rightSign : blankSign); setLocal(cell); cell.setColspan(2); table2.addCell(cell); cell = new Cell(("3".equals(rank.getRankOthProdUse())) ? rightSign : blankSign); setLocal(cell); cell.add(new Chunk( (rank.getPartRankOthProdUse() != null ? rank.getPartRankOthProdUse() : "________") + "%", songfontUnderLine_11)); cell.setColspan(4); table2.addCell(cell); break; } } cell = new Cell(new Phrase(new Chunk("08?", songfont_11))); cell.setColspan(2); cell.setRowspan(10); setLocal(cell); table2.addCell(cell); cell = new Cell(new Phrase(new Chunk("??", songfont_11))); setLocal(cell); cell.setRowspan(2); table2.addCell(cell); cell = new Cell(new Phrase(new Chunk("?", songfont_11))); setLocal(cell); cell.setRowspan(2); cell.setColspan(3); table2.addCell(cell); cell = new Cell(new Phrase(new Chunk("?", songfont_11))); setLocal(cell); cell.setColspan(8); table2.addCell(cell); cell = new Cell(new Phrase(new Chunk("??", songfont_11))); setLocal(cell); cell.setColspan(3); table2.addCell(cell); cell = new Cell(new Phrase(new Chunk("? ", songfont_11))); setLocal(cell); cell.setColspan(2); table2.addCell(cell); cell = new Cell(new Phrase(new Chunk("?", songfont_11))); setLocal(cell); cell.setColspan(3); table2.addCell(cell); table2.addCell(new Phrase(new Chunk("1", songfont_11))); table2.addCell(new Phrase(new Chunk("", songfont_11))); cell = new Cell("1".equals(rank.getRankIfGradeEval()) ? rightSign : blankSign); setLocal(cell); cell.add(new Chunk("", new Font(songFont, 9.0F, 0))); cell.add(("0".equals(rank.getRankIfGradeEval())) ? rightSign : blankSign); setLocal(cell); cell.add(new Chunk("", new Font(songFont, 9.0F, 0))); cell.setColspan(2); table2.addCell(cell); cell = new Cell("1".equals(rank.getRankSerGradeType()) ? rightSign : blankSign); setLocal(cell); cell.setColspan(3); table2.addCell(cell); cell = new Cell("2".equals(rank.getRankSerGradeType()) ? rightSign : blankSign); setLocal(cell); cell.setColspan(2); table2.addCell(cell); cell = new Cell("3".equals(rank.getRankSerGradeType()) ? rightSign : blankSign); setLocal(cell); cell.setColspan(3); table2.addCell(cell); table2.addCell(new Phrase(new Chunk("2", songfont_11))); table2.addCell(new Phrase(new Chunk("", songfont_11))); cell = new Cell("1".equals(rank.getRankIfRiskEval()) ? rightSign : blankSign); setLocal(cell); cell.add(new Chunk("", new Font(songFont, 9.0F, 0))); cell.add(("0".equals(rank.getRankIfRiskEval())) ? rightSign : blankSign); setLocal(cell); cell.add(new Chunk("", new Font(songFont, 9.0F, 0))); cell.setColspan(2); table2.addCell(cell); cell = new Cell("1".equals(rank.getRankSerRiskType()) ? rightSign : blankSign); setLocal(cell); cell.setColspan(3); table2.addCell(cell); cell = new Cell("2".equals(rank.getRankSerRiskType()) ? rightSign : blankSign); setLocal(cell); cell.setColspan(2); table2.addCell(cell); cell = new Cell("3".equals(rank.getRankSerRiskType()) ? rightSign : blankSign); setLocal(cell); cell.setColspan(3); table2.addCell(cell); table2.addCell(new Phrase(new Chunk("3", songfont_11))); table2.addCell(new Phrase(new Chunk("???", songfont_11))); cell = new Cell("1".equals(rank.getRankIfSuffReco()) ? rightSign : blankSign); setLocal(cell); cell.add(new Chunk("", new Font(songFont, 9.0F, 0))); cell.add(("0".equals(rank.getRankIfSuffReco())) ? rightSign : blankSign); setLocal(cell); cell.add(new Chunk("", new Font(songFont, 9.0F, 0))); cell.setColspan(2); table2.addCell(cell); cell = new Cell("1".equals(rank.getRankIfSuffRecoType()) ? rightSign : blankSign); setLocal(cell); cell.setColspan(3); table2.addCell(cell); cell = new Cell("2".equals(rank.getRankIfSuffRecoType()) ? rightSign : blankSign); setLocal(cell); cell.setColspan(2); table2.addCell(cell); cell = new Cell("3".equals(rank.getRankIfSuffRecoType()) ? rightSign : blankSign); setLocal(cell); cell.setColspan(3); table2.addCell(cell); table2.addCell(new Phrase(new Chunk("4", songfont_11))); table2.addCell(new Phrase(new Chunk("?", songfont_11))); cell = new Cell("1".equals(rank.getRankIfResponse()) ? rightSign : blankSign); setLocal(cell); cell.add(new Chunk("", new Font(songFont, 9.0F, 0))); cell.add(("0".equals(rank.getRankIfResponse())) ? rightSign : blankSign); setLocal(cell); cell.add(new Chunk("", new Font(songFont, 9.0F, 0))); cell.setColspan(2); table2.addCell(cell); cell = new Cell("1".equals(rank.getRankResponseType()) ? rightSign : blankSign); setLocal(cell); cell.setColspan(3); table2.addCell(cell); cell = new Cell("2".equals(rank.getRankResponseType()) ? rightSign : blankSign); setLocal(cell); cell.setColspan(2); table2.addCell(cell); cell = new Cell("3".equals(rank.getRankResponseType()) ? rightSign : blankSign); setLocal(cell); cell.setColspan(3); table2.addCell(cell); table2.addCell(new Phrase(new Chunk("5", songfont_11))); table2.addCell(new Phrase(new Chunk("?", songfont_11))); cell = new Cell("1".equals(rank.getRankIfSysInte()) ? rightSign : blankSign); setLocal(cell); cell.add(new Chunk("", new Font(songFont, 9.0F, 0))); cell.add(("0".equals(rank.getRankIfSysInte())) ? rightSign : blankSign); setLocal(cell); cell.add(new Chunk("", new Font(songFont, 9.0F, 0))); cell.setColspan(2); table2.addCell(cell); cell = new Cell("1".equals(rank.getRankSysInteType()) ? rightSign : blankSign); setLocal(cell); cell.setColspan(3); table2.addCell(cell); cell = new Cell("2".equals(rank.getRankSysInteType()) ? rightSign : blankSign); setLocal(cell); cell.setColspan(2); table2.addCell(cell); cell = new Cell("3".equals(rank.getRankSysInteType()) ? rightSign : blankSign); setLocal(cell); cell.setColspan(3); table2.addCell(cell); table2.addCell(new Phrase(new Chunk("6", songfont_11))); table2.addCell(new Phrase(new Chunk("", songfont_11))); cell = new Cell("1".equals(rank.getRankIfSecCon()) ? rightSign : blankSign); setLocal(cell); cell.add(new Chunk("", new Font(songFont, 9.0F, 0))); cell.add(("0".equals(rank.getRankIfSecCon())) ? rightSign : blankSign); setLocal(cell); cell.add(new Chunk("", new Font(songFont, 9.0F, 0))); cell.setColspan(2); table2.addCell(cell); cell = new Cell("1".equals(rank.getRankSecConypeType()) ? rightSign : blankSign); setLocal(cell); cell.setColspan(3); table2.addCell(cell); cell = new Cell("2".equals(rank.getRankSecConypeType()) ? rightSign : blankSign); setLocal(cell); cell.setColspan(2); table2.addCell(cell); cell = new Cell("3".equals(rank.getRankSecConypeType()) ? rightSign : blankSign); setLocal(cell); cell.setColspan(3); table2.addCell(cell); table2.addCell(new Phrase(new Chunk("7", songfont_11))); table2.addCell(new Phrase(new Chunk("", songfont_11))); cell = new Cell("1".equals(rank.getRankIfSecTrain()) ? rightSign : blankSign); setLocal(cell); cell.add(new Chunk("", new Font(songFont, 9.0F, 0))); cell.add(("0".equals(rank.getRankIfSecTrain())) ? rightSign : blankSign); setLocal(cell); cell.add(new Chunk("", new Font(songFont, 9.0F, 0))); cell.setColspan(2); table2.addCell(cell); cell = new Cell("1".equals(rank.getRankSecTrainType()) ? rightSign : blankSign); setLocal(cell); cell.setColspan(3); table2.addCell(cell); cell = new Cell("2".equals(rank.getRankSecTrainType()) ? rightSign : blankSign); setLocal(cell); cell.setColspan(2); table2.addCell(cell); cell = new Cell("3".equals(rank.getRankSecTrainType()) ? rightSign : blankSign); setLocal(cell); cell.setColspan(3); table2.addCell(cell); table2.addCell(new Phrase(new Chunk("8", songfont_11))); cell = new Cell(new Chunk("", songfont_11)); cell.add(new Chunk((rank.getRankOthSerName() != null ? rank.getRankOthSerName() : "________"), songfontUnderLine_11)); table2.addCell(cell); cell = new Cell("1".equals(rank.getRankIfOthSer()) ? rightSign : blankSign); setLocal(cell); cell.add(new Chunk("", new Font(songFont, 9.0F, 0))); cell.add(("0".equals(rank.getRankIfOthSer())) ? rightSign : blankSign); setLocal(cell); cell.add(new Chunk("", new Font(songFont, 9.0F, 0))); cell.setColspan(2); table2.addCell(cell); cell = new Cell("1".equals(rank.getRankOthUseType()) ? rightSign : blankSign); setLocal(cell); cell.setColspan(3); table2.addCell(cell); cell = new Cell("2".equals(rank.getRankOthUseType()) ? rightSign : blankSign); setLocal(cell); cell.setColspan(2); table2.addCell(cell); cell = new Cell("3".equals(rank.getRankOthUseType()) ? rightSign : blankSign); setLocal(cell); cell.setColspan(3); table2.addCell(cell); cell = new Cell(new Phrase(new Chunk("09????", songfont_11))); cell.setColspan(2); table2.addCell(cell); cell = new Cell(new Phrase(new Chunk(rank.getRankEvalUnitName(), songfont_11))); cell.setColspan(12); table2.addCell(cell); cell = new Cell(new Phrase(new Chunk("10?", songfont_11))); cell.setColspan(2); table2.addCell(cell); SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd"); cell = new Cell(new Phrase(new Chunk(format.format(rank.getRankUseDate()), songfont_11))); cell.setColspan(12); table2.addCell(cell); cell = new Cell(new Phrase(new Chunk("11?", songfont_11))); cell.setColspan(2); table2.addCell(cell); cell = new Cell("1".equals(rank.getRankFlag()) ? rightSign : blankSign); cell.add(new Chunk("", songfont_11)); cell.add("0".equals(rank.getRankFlag()) ? rightSign : blankSign); cell.add(new Chunk("?", songfont_11)); cell.setColspan(12); table2.addCell(cell); cell = new Cell(new Phrase(new Chunk("12??", songfont_11))); cell.setColspan(2); table2.addCell(cell); cell = new Cell(new Phrase(new Chunk(rank.getRankParentSysName(), songfont_11))); cell.setColspan(12); table2.addCell(cell); cell = new Cell(new Phrase(new Chunk("13????", songfont_11))); cell.setColspan(2); table2.addCell(cell); cell = new Cell(new Phrase(new Chunk(rank.getRankParentUnitName(), songfont_11))); cell.setColspan(12); table2.addCell(cell); document.add(table2); document.add(Chunk.NEXTPAGE); p = new Paragraph(); p.setAlignment(1); p.add(new Chunk("(" + systemManager.getSysName() + ")?", new Font(songFont, 16.0F, 0))); document.add(p); Table table3 = new Table(2); table3.setWidth(110.0F); table3.setWidths(new int[] { 40, 70 }); cell = new Cell(new Phrase(new Chunk("01??", songfont_11))); table3.addCell(cell); cell = new Cell("".equals(rank.getRankGrade()) ? rightSign : blankSign); cell.add(new Chunk("", songfont_11)); cell.add("".equals(rank.getRankGrade()) ? rightSign : blankSign); cell.add(new Chunk("", songfont_11)); cell.add("".equals(rank.getRankGrade()) ? rightSign : blankSign); cell.add(new Chunk("", songfont_11)); cell.add("".equals(rank.getRankGrade()) ? rightSign : blankSign); cell.add(new Chunk("", songfont_11)); cell.add("".equals(rank.getRankGrade()) ? rightSign : blankSign); cell.add(new Chunk("", songfont_11)); table3.addCell(cell); cell = new Cell(new Phrase(new Chunk("02", songfont_11))); table3.addCell(cell); cell = new Cell(new Chunk(format.format(rank.getRankTime()), songfont_11)); table3.addCell(cell); cell = new Cell(new Phrase(new Chunk("03", songfont_11))); table3.addCell(cell); cell = new Cell(new Phrase( new Chunk("1".equals(rank.getRankJudge()) ? "" : "", songfont_11))); table3.addCell(cell); cell = new Cell(new Phrase(new Chunk("04?", songfont_11))); table3.addCell(cell); cell = new Cell("1".equals(rank.getRankIsDep()) ? rightSign : blankSign); cell.add(new Chunk("", songfont_11)); cell.add("0".equals(rank.getRankIsDep()) ? rightSign : blankSign); cell.add(new Chunk("", songfont_11)); table3.addCell(cell); cell = new Cell(new Phrase(new Chunk("05??", songfont_11))); table3.addCell(cell); cell = new Cell( new Phrase(new Chunk(rank.getRankDepName() == null ? "" : rank.getRankDepName(), songfont_11))); table3.addCell(cell); cell = new Cell(new Phrase(new Chunk("06", songfont_11))); table3.addCell(cell); cell = new Cell("1".equals(rank.getRankDepJudge()) ? rightSign : blankSign); cell.add(new Chunk("", songfont_11)); cell.add("0".equals(rank.getRankDepJudge()) ? rightSign : blankSign); cell.add(new Chunk("", songfont_11)); table3.addCell(cell); cell = new Cell(new Phrase(new Chunk("07", songfont_11))); table3.addCell(cell); cell = new Cell(new Phrase(new Chunk("1".equals(rank.getRankDoc()) ? rightSign : blankSign))); cell.add(new Chunk("", songfont_11)); cell.add("0".equals(rank.getRankDoc()) ? rightSign : blankSign); cell.add(new Chunk("\t", songfont_11)); cell.add(new Chunk("??" + (rank.getRankAccess() == null ? "" : rank.getRankAccess()), songfont_11)); table3.addCell(cell); cell = new Cell(new Phrase(new Chunk("", songfont_11))); cell.add(new Chunk(rank.getRankInformant())); table3.addCell(cell); cell = new Cell(new Phrase(new Chunk("", songfont_11))); cell.add(new Chunk(format.format(rank.getRankDate()))); table3.addCell(cell); document.add(table3); p = new Paragraph(); p.setAlignment(1); p.add(new Chunk( " ", songfont_11)); document.add(p); document.add(Chunk.NEXTPAGE); p = new Paragraph(); p.setAlignment(1); p.add(new Chunk(" " + systemManager.getSysName() + " ??????", songfont_11)); document.add(p); if (null == null) { Table table4 = new Table(2); table4.setWidth(110.0F); table4.setWidths(new int[] { 40, 70 }); table4.addCell(new Phrase(new Chunk("01?", songfont_11))); cell = new Cell("1".equals(rank.getRankTopStruct()) ? rightSign : blankSign); cell.add(new Chunk("", songfont_11)); cell.add("0".equals(rank.getRankTopStruct()) ? rightSign : blankSign); cell.add(new Chunk("\t??", songfont_11)); cell.add(new Chunk(rank.getRankTopRelAcc() != null ? rank.getRankTopRelAcc() : "________", songfont_11)); table4.addCell(cell); table4.addCell(new Phrase(new Chunk("02??", songfont_11))); cell = new Cell("1".equals(rank.getRankSysManage()) ? rightSign : blankSign); cell.add(new Chunk("", songfont_11)); cell.add("0".equals(rank.getRankSysManage()) ? rightSign : blankSign); cell.add(new Chunk("\t??", songfont_11)); cell.add(new Chunk(rank.getRankSysManRel() != null ? rank.getRankSysManRel() : "________", songfont_11)); table4.addCell(cell); table4.addCell(new Phrase(new Chunk( "03?", songfont_11))); cell = new Cell("1".equals(rank.getRankSysPlan()) ? rightSign : blankSign); cell.add(new Chunk("", songfont_11)); cell.add("0".equals(rank.getRankSysPlan()) ? rightSign : blankSign); cell.add(new Chunk("\t??", songfont_11)); cell.add(new Chunk(rank.getRankSysPlanRel() != null ? rank.getRankSysPlanRel() : "________", songfont_11)); table4.addCell(cell); table4.addCell(new Phrase(new Chunk( "04???????", songfont_11))); cell = new Cell("1".equals(rank.getRankSysLicense()) ? rightSign : blankSign); cell.add(new Chunk("", songfont_11)); cell.add("0".equals(rank.getRankSysLicense()) ? rightSign : blankSign); cell.add(new Chunk("\t??", songfont_11)); cell.add(new Chunk(rank.getRankSysLiceRel() != null ? rank.getRankSysLiceRel() : "________", songfont_11)); table4.addCell(cell); table4.addCell(new Phrase(new Chunk("05", songfont_11))); cell = new Cell("1".equals(rank.getRankSysReport()) ? rightSign : blankSign); cell.add(new Chunk("", songfont_11)); cell.add("0".equals(rank.getRankSysReport()) ? rightSign : blankSign); cell.add(new Chunk("\t??", songfont_11)); cell.add(new Chunk(rank.getRankSysReportRel() != null ? rank.getRankSysReportRel() : "________", songfont_11)); table4.addCell(cell); table4.addCell(new Phrase(new Chunk("06", songfont_11))); cell = new Cell("1".equals(rank.getRankPeerRev()) ? rightSign : blankSign); cell.add(new Chunk("", songfont_11)); cell.add("0".equals(rank.getRankPeerRev()) ? rightSign : blankSign); cell.add(new Chunk("\t??", songfont_11)); cell.add(new Chunk(rank.getRankPeerRevRel() != null ? rank.getRankPeerRevRel() : "________", songfont_11)); table4.addCell(cell); table4.addCell(new Phrase(new Chunk("07??", songfont_11))); cell = new Cell("1".equals(rank.getRankSuperOpin()) ? rightSign : blankSign); cell.add(new Chunk("", songfont_11)); cell.add("0".equals(rank.getRankSuperOpin()) ? rightSign : blankSign); cell.add(new Chunk("\t??", songfont_11)); cell.add(new Chunk(rank.getRankSuperOpinRel() != null ? rank.getRankSuperOpinRel() : "________", songfont_11)); table4.addCell(cell); document.add(table4); document.close(); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return 1; }
From source file:com.virtusa.akura.student.controller.MessageBoardController.java
License:Open Source License
/** * Merge many pdf files into one file.//from w ww. j a va 2 s . co m * * @param streamOfPDFFiles - a list of inputStreams * @param outputStream - an instance of outputStream * @param paginate - a boolean * @throws AkuraAppException - The exception details that occurred when processing */ public static void concatPDFs(List<InputStream> streamOfPDFFiles, OutputStream outputStream, boolean paginate) throws AkuraAppException { final int fontSize = 8, leftRightAlignment = 8; final int min = 0; final int max = 5; final int size = 300; final int xAxis = -150; final int pageHeight = 550; final int pageHieghtfromBottom = 16; final int pageRecHeight = 580; final int recHeightFromBottom = 14; Document document = new Document(PageSize.A4); try { List<InputStream> pdfs = streamOfPDFFiles; List<PdfReader> readers = new ArrayList<PdfReader>(); int totalPages = 0; Iterator<InputStream> iteratorPDFs = pdfs.iterator(); // Create Readers for the pdfs. while (iteratorPDFs.hasNext()) { InputStream pdf = iteratorPDFs.next(); PdfReader pdfReader = new PdfReader(pdf); readers.add(pdfReader); totalPages += pdfReader.getNumberOfPages(); } // Create a writer for the output stream PdfWriter writer = null; BaseFont bf = null; try { writer = PdfWriter.getInstance(document, outputStream); document.open(); bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); } catch (DocumentException e) { e.printStackTrace(); } PdfContentByte cb = writer.getDirectContent(); // Holds the PDF data PdfImportedPage page; int currentPageNumber = 0; int pageOfCurrentReaderPDF = 0; Iterator<PdfReader> iteratorPDFReader = readers.iterator(); // Loop through the PDF files and add to the output. while (iteratorPDFReader.hasNext()) { PdfReader pdfReader = iteratorPDFReader.next(); // Create a new page in the target for each source page. while (pageOfCurrentReaderPDF < pdfReader.getNumberOfPages()) { if (currentPageNumber != 2) { document.newPage(); } pageOfCurrentReaderPDF++; currentPageNumber++; page = writer.getImportedPage(pdfReader, pageOfCurrentReaderPDF); if (currentPageNumber == 1) { cb.addTemplate(page, 0, xAxis); } else if (currentPageNumber != 2) { cb.addTemplate(page, 0, 0); } // Code for pagination. if (paginate) { cb.beginText(); cb.setFontAndSize(bf, fontSize); cb.showTextAligned(PdfContentByte.ALIGN_CENTER, " " + AkuraWebConstant.REPORT_GPL, size, max, min); cb.newlineText(); cb.endText(); if (currentPageNumber != 2) { int pageNo = currentPageNumber; if (currentPageNumber != 1) { pageNo = currentPageNumber - 1; } // write the page number inside a rectangle. cb.fillStroke(); cb.rectangle(leftRightAlignment, recHeightFromBottom, pageRecHeight, leftRightAlignment); cb.beginText(); cb.showTextAligned(PdfContentByte.ALIGN_LEFT, PAGE + pageNo, pageHeight, pageHieghtfromBottom, 0); cb.endText(); cb.stroke(); } } } pageOfCurrentReaderPDF = 0; } outputStream.flush(); document.close(); outputStream.close(); } catch (IOException e) { e.printStackTrace(); } finally { if (document.isOpen()) { document.close(); } try { if (outputStream != null) { outputStream.close(); } } catch (IOException ioe) { ioe.printStackTrace(); } } }
From source file:corner.orm.tapestry.pdf.PdfUtils.java
License:Apache License
/** * /*www. ja v a2s . c o m*/ * @return */ public static final BaseFont createSongLightBaseFont() { BaseFont bfChinese; try { bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.EMBEDDED); return bfChinese; } catch (DocumentException e) { throw new PdfSystemException(e); } catch (IOException e) { throw new PdfSystemException(e); } }
From source file:cz.incad.kramerius.pdf.utils.pdf.FontMap.java
License:Open Source License
private Font createArialFont(File fontDirectory) throws DocumentException, IOException { File fontFile = new File(fontDirectory.getAbsolutePath(), "ext_ontheflypdf_ArialCE.ttf"); BaseFont bf = BaseFont.createFont(fontFile.getAbsolutePath(), BaseFont.CP1250, true); return new Font(bf); }
From source file:cz.incad.kramerius.pdf.utils.pdf.FontMap.java
License:Open Source License
private Font createGentiumFont(File fontDirectory) throws DocumentException, IOException { File fontFile = new File(fontDirectory.getAbsolutePath(), "GentiumPlus-R.ttf"); BaseFont bf = BaseFont.createFont(fontFile.getAbsolutePath(), BaseFont.CP1250, true); return new Font(bf); }
From source file:de.tr1.cooperator.manager.web.CreateSubscriberListAction.java
License:Open Source License
/** * This method is called by the struts-framework if the submit-button is pressed. * It creates a PDF-File and puts in into the output-stream of the response. */// ww w .j a va 2s.c om public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { CreateSubscriberListForm myForm = (CreateSubscriberListForm) form; boolean bSortByName; if (myForm.getSortBy().equals(myForm.SORTBYPN)) bSortByName = false; else bSortByName = true; //create Collection for the results... Event eEvent = EventManager.getInstance().getEventByID(myForm.getEventID()); Collection cSubscriberList = UserManager.getInstance().getUsersByCollection(eEvent.getSubscriberList()); Collection cExamResults = EventResultManager.getInstance().getResults(eEvent.getID()); Iterator cSubscriberListIT = cSubscriberList.iterator(); Collection cSubscriberResultList = new ArrayList(); while (cSubscriberListIT.hasNext()) { User CurUser = (User) cSubscriberListIT.next(); String UserPNR = CurUser.getPersonalNumber(); Iterator cExamResultsIT = cExamResults.iterator(); ExamResult curExamResult = null; String ResultUserPNR = null; while (cExamResultsIT.hasNext()) { curExamResult = (ExamResult) cExamResultsIT.next(); ResultUserPNR = curExamResult.getUserPersonalNumber(); if (UserPNR.equals(ResultUserPNR)) break; } if (UserPNR.equals(ResultUserPNR)) { if (bSortByName) { UserResultSortByName URS = new UserResultSortByName(CurUser, "" + curExamResult.getResult()); cSubscriberResultList.add(URS); } else { UserResultSortByPersonalNumber URS = new UserResultSortByPersonalNumber(CurUser, "" + curExamResult.getResult()); cSubscriberResultList.add(URS); } } else { if (bSortByName) { UserResultSortByName URS = new UserResultSortByName(CurUser, "-"); cSubscriberResultList.add(URS); } else { UserResultSortByPersonalNumber URS = new UserResultSortByPersonalNumber(CurUser, "-"); cSubscriberResultList.add(URS); } } } //sort List Collections.sort((List) cSubscriberResultList); BaseFont bf; //36pt = 0.5inch Document document = new Document(PageSize.A4, 36, 36, 72, 72); try { bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); } catch (Exception e) { Log.addLog("CreateSubscriberListAction: Error creating BaseFont: " + e); //2do: add ErrorMessage and return to inputFormular! return mapping.findForward("GeneralFailure"); } //calculate the number of cols and their width int cols = 0; ArrayList alWidth = new ArrayList(); float boldItalicFactor = 1.2f; if (myForm.getShowNumber()) alWidth.add(new Float(boldItalicFactor * bf.getWidthPoint(TABLEHEADER_NUMBER, TABLEHEADER_FONTSIZE))); if (myForm.getShowPersonalNumber()) alWidth.add(new Float( boldItalicFactor * bf.getWidthPoint(TABLEHEADER_PERSONALNUMBER, TABLEHEADER_FONTSIZE))); if (myForm.getShowName()) alWidth.add(new Float(boldItalicFactor * bf.getWidthPoint(TABLEHEADER_NAME, TABLEHEADER_FONTSIZE))); if (myForm.getShowEmail()) alWidth.add(new Float(boldItalicFactor * bf.getWidthPoint(TABLEHEADER_EMAIL, TABLEHEADER_FONTSIZE))); if (myForm.getShowResult()) alWidth.add(new Float(boldItalicFactor * bf.getWidthPoint(TABLEHEADER_RESULT, TABLEHEADER_FONTSIZE))); if (myForm.getAddInfoField()) alWidth.add(new Float(boldItalicFactor * bf.getWidthPoint(TABLEHEADER_INFO, TABLEHEADER_FONTSIZE))); if (myForm.getAddSignField()) alWidth.add(new Float(boldItalicFactor * bf.getWidthPoint(TABLEHEADER_SIGN, TABLEHEADER_FONTSIZE))); cols = alWidth.size(); float totalWidth = 0; //calculate the whole length Iterator alIterator = alWidth.iterator(); for (; alIterator.hasNext(); totalWidth += ((Float) alIterator.next()).floatValue()) ; //calculate relativ width for the table float[] width = new float[cols]; alIterator = alWidth.iterator(); int i = 0; while (alIterator.hasNext()) { float pixLength = ((Float) alIterator.next()).floatValue(); //alWidthRelativ.add( new Float( pixLength/totalWidth ) ); width[i] = pixLength / totalWidth; i++; } //needed for the shrink (enlarge?) float shrinkFactor; try { //1st: set correct outputstream PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream()); //1.5st: set content-stuff response.setContentType("application/pdf"); //2nd: set EventManager for PageEvents to Helper writer.setPageEvent( new CreateSubscriberListActionHelper(myForm.getHeaderLeft(), myForm.getHeaderRight())); //3rd: open document for editing the content document.open(); //4th: add content Phrase pInfoText = new Phrase(myForm.getInfoText(), new Font(bf, 12, Font.BOLD)); document.add(pInfoText); //PdfPTable( cols ) PdfPTable table = new PdfPTable(width); float documentWidth = document.right() - document.left(); if (documentWidth < totalWidth) { table.setTotalWidth(documentWidth); shrinkFactor = documentWidth / totalWidth; } else { table.setTotalWidth(totalWidth); shrinkFactor = 1; } table.setLockedWidth(true); Font headerFont = new Font(bf, TABLEHEADER_FONTSIZE * shrinkFactor, Font.BOLDITALIC); Font cellFont = new Font(bf, TABLECELL_FONTSIZE * shrinkFactor, Font.NORMAL); if (myForm.getShowNumber()) table.addCell(new Phrase(TABLEHEADER_NUMBER, headerFont)); if (myForm.getShowPersonalNumber()) table.addCell(new Phrase(TABLEHEADER_PERSONALNUMBER, headerFont)); if (myForm.getShowName()) table.addCell(new Phrase(TABLEHEADER_NAME, headerFont)); if (myForm.getShowEmail()) table.addCell(new Phrase(TABLEHEADER_EMAIL, headerFont)); if (myForm.getShowResult()) table.addCell(new Phrase(TABLEHEADER_RESULT, headerFont)); if (myForm.getAddInfoField()) table.addCell(new Phrase(TABLEHEADER_INFO, headerFont)); if (myForm.getAddSignField()) table.addCell(new Phrase(TABLEHEADER_SIGN, headerFont)); //fill table Iterator iSRL = cSubscriberResultList.iterator(); int counter = 1; while (iSRL.hasNext()) { UserResult curResult = (UserResult) iSRL.next(); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); if (myForm.getShowNumber()) table.addCell(new Phrase("" + counter++, cellFont)); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); if (myForm.getShowPersonalNumber()) table.addCell(new Phrase(curResult.getPersonalNumber(), cellFont)); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); if (myForm.getShowName()) table.addCell(new Phrase(curResult.getSurname() + ", " + curResult.getFirstName(), cellFont)); if (myForm.getShowEmail()) table.addCell(new Phrase(curResult.getEmailAddress(), cellFont)); if (myForm.getShowResult()) table.addCell(new Phrase(curResult.getResult(), cellFont)); if (myForm.getAddInfoField()) table.addCell(new Phrase("", cellFont)); if (myForm.getAddSignField()) table.addCell(new Phrase("", cellFont)); } //set how many rows are header... table.setHeaderRows(1); document.add(table); //5th: close document, write the output to the stream... document.close(); } catch (Exception de) { Log.addLog("CreateSubscriberListAction: Error creating PDF: " + de); } //we dont need to return a forward, because we write directly to the outputstream! return null; }
From source file:de.tr1.cooperator.manager.web.CreateSubscriberListActionHelper.java
License:Open Source License
/** * The first thing to do when the document is opened, is to define the BaseFont, * get the Direct Content object and create the template that will hold the final * number of pages.//from www . ja v a2 s . co m * @see com.lowagie.text.pdf.PdfPageEventHelper#onOpenDocument(com.lowagie.text.pdf.PdfWriter, com.lowagie.text.Document) */ public void onOpenDocument(PdfWriter writer, Document document) { try { bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); cb = writer.getDirectContent(); // initialization of the header table tHeader = new PdfPTable(2); Phrase p = new Phrase(); tHeader.getDefaultCell().setBorder(Rectangle.NO_BORDER); tHeader.addCell(sHeaderLeft); tHeader.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); tHeader.addCell(sHeaderRight); template = cb.createTemplate(50, 50); } catch (DocumentException de) { } catch (IOException ioe) { } }