List of usage examples for com.lowagie.text.pdf PdfPCell setFixedHeight
public void setFixedHeight(float fixedHeight)
From source file:fr.opensagres.poi.xwpf.converter.pdf.internal.elements.StylableDocumentSection.java
License:Open Source License
public static SectionPdfPTable createLayoutTable(float width, float height, List<StyleColumnProperties> columnPropertiesList) { // create one row table which will layout section text int colCount = columnPropertiesList.size(); int relativeWidths[] = new int[colCount]; SectionPdfPTable table = new SectionPdfPTable(colCount); // add cells/*from w w w .j a va 2 s . c om*/ for (int i = 0; i < colCount; i++) { PdfPCell cell = new PdfPCell(); cell.setBorder(Table.NO_BORDER); cell.setPadding(0.0f); cell.setColumn(createColumnText()); cell.setFixedHeight(height >= 0.0f ? height : -1.0f); // apply styles to cell StyleColumnProperties columnProperties = columnPropertiesList.get(i); relativeWidths[i] = columnProperties.getRelWidth(); cell.setPaddingLeft( columnProperties.getStartIndent() != null ? columnProperties.getStartIndent() : 0.0f); cell.setPaddingRight(columnProperties.getEndIndent() != null ? columnProperties.getEndIndent() : 0.0f); table.addCell(cell); } replaceTableCells(table); // set width try { table.setWidths(relativeWidths); } catch (DocumentException e) { throw new XWPFConverterException(e); } table.setTotalWidth(width); table.setLockedWidth(true); return table; }
From source file:ilarkesto.integration.itext.Paragraph.java
License:Open Source License
@Override public Element getITextElement() { com.lowagie.text.Paragraph p = new com.lowagie.text.Paragraph(); float maxSize = 0; for (AParagraphElement element : getElements()) { if (element instanceof TextChunk) { TextChunk textChunk = (TextChunk) element; FontStyle fontStyle = textChunk.getFontStyle(); FontSelector fontSelector = createFontSelector(fontStyle.getFont(), fontStyle); String text = textChunk.getText(); Phrase phrase = fontSelector.process(text); p.add(phrase);/*from www . j a v a 2s. co m*/ float size = (fontStyle.getSize() * 1.1f) + 1f; if (size > maxSize) maxSize = PdfBuilder.mmToPoints(size); } else if (element instanceof Image) { Image image = (Image) element; com.lowagie.text.Image itextImage; try { itextImage = image.getITextElement(); } catch (Exception ex) { log.warn("Including image failed:", image, ex); continue; } if (image.getAlign() != null) { itextImage.setAlignment(Image.convertAlign(image.getAlign()) | com.lowagie.text.Image.TEXTWRAP); p.add(itextImage); } else { Chunk chunk = new Chunk(itextImage, 0, 0); p.add(chunk); float size = image.getHeight() + 3; if (size > maxSize) maxSize = size; } } else { throw new RuntimeException("Unsupported paragraph element: " + element.getClass().getName()); } } p.setLeading(maxSize); p.setSpacingBefore(PdfBuilder.mmToPoints(spacingTop)); p.setSpacingAfter(PdfBuilder.mmToPoints(spacingBottom)); if (align != null) p.setAlignment(convertAlign(align)); if (height <= 0) return p; // wrap in table PdfPCell cell = new PdfPCell(); cell.setBorder(0); cell.setFixedHeight(PdfBuilder.mmToPoints(height)); cell.addElement(p); PdfPTable table = new PdfPTable(1); table.setWidthPercentage(100); table.addCell(cell); return table; }
From source file:it.eng.spagobi.engines.documentcomposition.exporterUtils.PdfCreator.java
License:Mozilla Public License
public FileOutputStream createPdfFile(FileOutputStream fileOutputStream, Map<String, DocumentContainer> documentsMap, boolean defaultStyle) throws MalformedURLException, IOException, DocumentException { logger.debug("IN"); Document document = new Document(PageSize.A4.rotate()); Rectangle rect = document.getPageSize(); docWidth = rect.getWidth();/* www.j a v a 2 s . c o m*/ docHeight = rect.getHeight(); logger.debug("document size width: " + docWidth + " height: " + docHeight); //PdfWriter writer=PdfWriter.getInstance(document,new FileOutputStream("C:/comp/SpagoBIProva.pdf")); PdfWriter writer = PdfWriter.getInstance(document, fileOutputStream); document.open(); int documentsNumber = documentsMap.keySet().size(); int columnnsNumber = 2; if (defaultStyle == true) { logger.debug("use default style"); int cellsCounter = 0; PdfPTable table = new PdfPTable(columnnsNumber); table.setWidthPercentage(100); for (Iterator iterator = documentsMap.keySet().iterator(); iterator.hasNext();) { String label = (String) iterator.next(); DocumentContainer docContainer = documentsMap.get(label); byte[] content = docContainer.getContent(); if (content != null) { Image img = null; try { img = Image.getInstance(content); table.addCell(img); } catch (Exception e) { logger.debug("Trying to evaluate response as a PDF file... "); table.addCell(""); // try { // PdfReader reader = new PdfReader(content); // PdfImportedPage page = writer.getImportedPage(reader, 1); // writer.addPage(page); // table.addCell(""); // } catch (Exception x) { // logger.error("Error in inserting image for document " + label, e); // logger.error("Error in inserting pdf file for document " + label, x); // table.addCell(""); // } } } cellsCounter++; } // if cell counter is not pair make it pair if (cellsCounter % 2 != 0) { table.addCell(""); } document.add(table); } else { // ************* NO DEFAULT STYLE ***************** logger.debug("No default style"); // I want to calculate total height of scaled heights!! //int totalScaledHeight=calculateTotaleScaledHeights(documentsMap, defaultStyle); // run on all documents for (Iterator iterator = documentsMap.keySet().iterator(); iterator.hasNext();) { String label = (String) iterator.next(); logger.debug("document with label " + label); DocumentContainer docContainer = documentsMap.get(label); MetadataStyle style = docContainer.getStyle(); // one table for each image, set at absolute position PdfPTable table = new PdfPTable(1); // width and height specified for the container by style attribute int widthStyle = style.getWidth(); int heightStyle = style.getHeight(); logger.debug("style for document width: " + widthStyle + " height: " + heightStyle); // width and height for the table scaled to the document size int tableWidth = calculatePxSize(docWidth, widthStyle, videoWidth); int tableHeight = calculatePxSize(docHeight, heightStyle, videoHeight); logger.debug("table for document width: " + tableWidth + " height: " + tableHeight); // x and y position as specified for the container by the style attribute int yStyle = style.getY(); int xStyle = style.getX(); // width and height scaled to the document size int xPos = (calculatePxPos(docWidth, xStyle, videoWidth)); int yPos = (int) docHeight - (calculatePxPos(docHeight, yStyle, videoHeight)); logger.debug("Table position at x: " + xPos + " y: " + yPos); // get the image byte[] content = docContainer.getContent(); if (content != null) { Image img = null; try { img = Image.getInstance(content); } catch (Exception e) { logger.debug("Trying to evaluate response as a PDF file... "); try { PdfReader reader = new PdfReader(content); PdfContentByte cb = writer.getDirectContent(); PdfImportedPage page = writer.getImportedPage(reader, 1); float[] tm = getTransformationMatrix(page, xPos, yPos, tableWidth, tableHeight); cb.addTemplate(page, tm[0], tm[1], tm[2], tm[3], tm[4], tm[5]); } catch (Exception x) { logger.error("Error in inserting image for document " + label, e); logger.error("Error in inserting pdf file for document " + label, x); } continue; } //if it is a REPORT and has more than one page, too large, you have to resize the image, but how to understand it? // if image size is more than double of the container size cut the first part,otherwise scale it if (docContainer.getDocumentType().equals("REPORT")) { boolean cutImageWIdth = isToCutWidth(img, tableWidth); boolean cutImageHeight = isToCutHeight(img, tableWidth); if (cutImageWIdth == true || cutImageHeight == true) { logger.debug( "Report will be cut to width " + tableWidth + " and height " + tableHeight); try { img = cutImage(content, cutImageHeight, cutImageWIdth, tableHeight, tableWidth, (int) img.getWidth(), (int) img.getHeight()); } catch (Exception e) { logger.error( "Error in image cut, cutt will be ignored and image will be drawn anyway ", e); } } } // this is percentage to resize // The image must be size within the cell int percToResize = percentageToResize((int) img.getWidth(), (int) img.getHeight(), tableWidth, tableHeight); logger.debug("image will be scaled of percentage " + percToResize); img.scalePercent(percToResize); PdfPCell cell = new PdfPCell(img); cell.setNoWrap(true); cell.setFixedHeight(tableHeight); cell.setBorderWidth(0); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_CENTER); table.addCell(cell); //table.setWidthPercentage(tableWidthPerc); table.setTotalWidth(tableWidth); table.setLockedWidth(true); } else { // TODO: setALT! } logger.debug("Add table"); table.writeSelectedRows(0, -1, xPos, yPos, writer.getDirectContent()); logger.debug("Document added"); } } document.close(); logger.debug("OUT"); return fileOutputStream; }
From source file:jdbreport.model.io.pdf.itext2.PdfWriter.java
License:Apache License
private PdfPCell writeCell(ReportModel model, jdbreport.model.Cell srcCell, int row, int col) throws BadElementException, IOException, SaveReportException { CellStyle style = model.getStyles(srcCell.getStyleId()); java.awt.Rectangle rect = model.getCellRect(row, col, true, true); float h = Math.round((float) Units.PT.setYPixels((int) rect.getHeight())); float w = Math.round((float) Units.PT.setXPixels((int) rect.getWidth())); PdfPCell pdfCell = null; if (srcCell.getPicture() != null) { java.awt.Image awtImage = srcCell.getPicture().getImage(); com.lowagie.text.Image image = awtImageToImage(awtImage, srcCell, w, h); pdfCell = new PdfPCell(image); } else {// w ww. j av a2s . c o m String text = null; if (srcCell.getValue() instanceof CellValue<?>) { StringWriter strWriter = new StringWriter(); PrintWriter printWriter = new PrintWriter(strWriter); if (!((CellValue<?>) srcCell.getValue()).write(printWriter, model, row, col, this, ReportBook.PDF)) { java.awt.Image awtImage = ((CellValue<?>) srcCell.getValue()).getAsImage(model, row, col); if (awtImage != null) { com.lowagie.text.Image image = awtImageToImage(awtImage, srcCell, w, h); pdfCell = new PdfPCell(image); } } else { text = strWriter.getBuffer().toString(); } } else { if (jdbreport.model.Cell.TEXT_HTML.equals(srcCell.getContentType())) { pdfCell = new PdfPCell(); writeHTMLText(model.getStyles(srcCell.getStyleId()), srcCell, pdfCell); } else { text = model.getCellText(srcCell); } } if (pdfCell == null) { pdfCell = new PdfPCell(); } if (text != null && text.length() > 0) { com.lowagie.text.Font font; if (fonts.containsKey(style.getId())) { font = fonts.get(style.getId()); } else { font = getFontMapper().styleToPdf(style); fonts.put(style.getId(), font); } Paragraph p; if (font != null) { p = new Paragraph(text, font); } else { p = new Paragraph(text); } pdfCell.setPhrase(p); pdfCell.setPadding(1); pdfCell.setLeading(0f, 1.1f); } else { pdfCell.setPadding(0); } } pdfCell.setFixedHeight(h); pdfCell.setBackgroundColor(style.getBackground()); pdfCell.setHorizontalAlignment(toPdfHAlignment(style.getHorizontalAlignment())); pdfCell.setVerticalAlignment(toPdfVAlignment(style.getVerticalAlignment())); if (style.getAngle() != 0) { pdfCell.setRotation(roundAngle(style.getAngle())); } assignBorders(style, pdfCell); pdfCell.setNoWrap(!style.isWrapLine()); if (srcCell.getColSpan() > 0) { pdfCell.setColspan(srcCell.getColSpan() + 1); } if (srcCell.getRowSpan() > 0) { pdfCell.setRowspan(srcCell.getRowSpan() + 1); } return pdfCell; }
From source file:open.dolphin.hiro.PrescriptionPDFMaker.java
/** * ??//from w w w . j a v a 2s . c o m */ public String output() { BufferedOutputStream bos; PdfWriter pw = null; Document document = null; try { Date dateNow = new Date(); // ID String patientId = pkg.getPatientId(); // ??? String name = pkg.getPatientName(); name = name.replaceAll(" ", ""); name = name.replaceAll("", ""); String iNum; // ?? String piNum = null; // ? String rNum = null; // ?? String piNum2 = null; // ? String rNum2 = null; // ?? String div = ""; // ? String payRatio = ""; // ? String mNum = ""; // ??? char[] iNumC = new char[8]; // ??? char[] piNumC = new char[8]; // ?? char[] rNumC = new char[7]; // ?? char[] piNumC2 = new char[8]; // ?? char[] rNumC2 = new char[7]; // ?? DecimalFormat df = new DecimalFormat("#0.#"); // ?? String paymentRatio = ""; // ? String paymentRatio2 = ""; // ? if (pkg.getApplyedInsurance().getInsuranceNumber() != null) { // ?? iNum = pkg.getApplyedInsurance().getInsuranceNumber(); // ? null ?? if (iNum.toLowerCase().startsWith("z") || iNum.equals("9999")) { iNum = null; } // if (pkg.getApplyedInsurance().getPVTPublicInsuranceItem() != null) { PVTPublicInsuranceItemModel[] pubItems = pkg.getApplyedInsurance().getPVTPublicInsuranceItem(); for (int i = 0; i < pubItems.length; i++) { PVTPublicInsuranceItemModel pm = pubItems[i]; if (i == 0) { // ? piNum = pm.getProvider(); piNum = ("mikinyu".equals(piNum)) ? "" : piNum; // ?? rNum = pm.getRecipient(); rNum = ("mikinyu".equals(rNum)) ? "" : rNum; // ??? paymentRatio = pm.getPaymentRatio(); } else if (i == 1) { piNum2 = pm.getProvider(); piNum2 = ("mikinyu".equals(piNum2)) ? "" : piNum2; rNum2 = pm.getRecipient(); rNum2 = ("mikinyu".equals(rNum2)) ? "" : rNum2; paymentRatio2 = pm.getPaymentRatio(); break; } } } // ? ?? ? StringBuilder sb = new StringBuilder(); // ? ? if (pkg.getApplyedInsurance().getClientGroup() != null && !pkg.getApplyedInsurance().getClientGroup().equals("??")) { sb.append(pkg.getApplyedInsurance().getClientGroup()).append(""); } // ?? if (pkg.getApplyedInsurance().getClientNumber() != null && !pkg.getApplyedInsurance().getClientNumber().equals("??")) { sb.append(pkg.getApplyedInsurance().getClientNumber()); } mNum = sb.length() > 0 ? sb.toString() : ""; // if ("?".equals(pkg.getApplyedInsurance().getInsuranceClass())) { div = ""; payRatio = paymentRatio; } else { // ? div = "true".equals(pkg.getApplyedInsurance().getFamilyClass()) ? "?" : ""; payRatio = pkg.getApplyedInsurance().getPayOutRatio(); } if (payRatio != null && !("".equals(payRatio))) { payRatio = df.format(Double.valueOf(payRatio) * 10); } if (DEBUG) { System.err.println("iNum=" + iNum); System.err.println("piNum=" + piNum); System.err.println("rNum=" + rNum); System.err.println("piNum2=" + piNum2); System.err.println("rNum2=" + rNum2); System.err.println("mNum=" + mNum); System.err.println("?=" + div); System.err.println("=" + payRatio); } // ??? iNumC = partitionPadRL(iNum, 8, "R"); // ?? piNumC = partitionPadRL(piNum, 8, "L"); // ? rNumC = partitionPadRL(rNum, 7, "L"); // ?? piNumC2 = partitionPadRL(piNum2, 8, "L"); // ?2 rNumC2 = partitionPadRL(rNum2, 7, "L"); // ??2 } /***** *****/ document = new Document(PageSize.A5, 10, 10, 2, 2); // @002 2009/11/17 // ?PDF???????? if (getDocumentDir() == null) { StringBuilder sb = new StringBuilder(); sb.append(System.getProperty("user.dir")); sb.append(File.separator); sb.append(DIR_NAME); setDocumentDir(sb.toString()); } File dir = new File(getDocumentDir()); dir.mkdir(); // ??(?-ID_???_.pdf) StringBuilder sb = new StringBuilder(); sb.append(FILE_NAME_PRE); sb.append(patientId).append("_").append(name).append("_"); sb.append(new SimpleDateFormat("yyyyMMddHHmmss").format(dateNow)); sb.append(FILE_EXTENTION); setFileName(sb.toString()); sb = new StringBuilder(); if (getDocumentDir() != null) { sb.append(getDocumentDir()); sb.append(File.separator); } sb.append(getFileName()); pathToPDF = sb.toString(); //minagawa^ ???water mark?????????? byte[]??? ByteArrayOutputStream byteo = new ByteArrayOutputStream(); bos = new BufferedOutputStream(byteo); //minagawa$ pw = PdfWriter.getInstance(document, bos); // font setting bfm = BaseFont.createFont(FONT_HEISEI_MIN3, CODE_UNIJIS_H, BaseFont.NOT_EMBEDDED); bfg = BaseFont.createFont(FONT_HEISEI_KAKU5, CODE_UNIJIS_H, BaseFont.NOT_EMBEDDED); min_6 = new Font(bfm, 6); min_7 = new Font(bfm, 7); min_8 = new Font(bfm, 8); min_9 = new Font(bfm, 9); min_10 = new Font(bfm, 10); min_12 = new Font(bfm, 12); min_14 = new Font(bfm, 14); min_15 = new Font(bfm, 15); min_4 = new Font(bfm, 4); // @009 // document.open(); document.addAuthor(pkg.getPhysicianName()); document.addTitle(PROPERTY_TITLE); document.addSubject(PROPERTY_SUB_TITLE); // ??? List<PdfPTable> list = createPrescriptionTbl2(); Iterator<PdfPTable> ite = list.iterator(); // ? int pageNo = 0; int totalPageNo = list.size(); // ????????? do { PdfPTable ptbl = new PdfPTable(1); ptbl.setWidthPercentage(100f); ptbl.getDefaultCell().setPadding(0f); PdfPCell pcell = new PdfPCell(new Paragraph(REPORT_TITLE, min_15)); pcell.setBorder(Table.NO_BORDER); setAlignCenter(pcell); ptbl.addCell(pcell); pcell = new PdfPCell(new Paragraph(REPORT_SUB_TITLE, min_7)); pcell.setBorder(Table.NO_BORDER); setAlignCenter(pcell); ptbl.addCell(pcell); document.add(ptbl); ptbl = new PdfPTable(3); ptbl.setWidthPercentage(100f); ptbl.getDefaultCell().setPadding(0f); ptbl.getDefaultCell().setBorder(Table.NO_BORDER); float[] widths = { 43.5f, 2f, 54.5f }; ptbl.setWidths(widths); // ? pcell = new PdfPCell(new Paragraph(patientId, min_9)); pcell.setBorder(Table.NO_BORDER); pcell.setColspan(10); ptbl.addCell(pcell); PdfPTable ptblL = new PdfPTable(9); ptblL.setSpacingBefore(10f); ptblL.setWidthPercentage(100f); float[] widthsL = { 33, 8, 8, 8, 8, 8, 8, 8, 8 }; ptblL.setWidths(widthsL); ptblL.getDefaultCell().setPadding(0f); pcell = new PdfPCell(new Paragraph("?", min_7)); pcell.setMinimumHeight(CELL_HIGHT_0); setAlignJustifiedAll(pcell); setAlignMiddle(pcell); pcell.setBorderWidth(LINE_WIDTH_1); ptblL.addCell(pcell); pcell = new PdfPCell(new Paragraph(String.valueOf(piNumC[0]), min_14)); pcell.setBorderWidth(LINE_WIDTH_1); pcell.setPadding(0f); setAlignCenterMiddle(pcell); ptblL.addCell(pcell); pcell = new PdfPCell(new Paragraph(String.valueOf(piNumC[1]), min_14)); pcell.setBorderWidth(LINE_WIDTH_1); pcell.setBorderWidthRight(LINE_WIDTH_3); pcell.setPadding(0f); setAlignCenterMiddle(pcell); ptblL.addCell(pcell); pcell = new PdfPCell(new Paragraph(String.valueOf(piNumC[2]), min_14)); pcell.setBorderWidth(LINE_WIDTH_1); pcell.setBorderWidthLeft(LINE_WIDTH_3); pcell.setPadding(0f); setAlignCenterMiddle(pcell); ptblL.addCell(pcell); pcell = new PdfPCell(new Paragraph(String.valueOf(piNumC[3]), min_14)); pcell.setBorderWidth(LINE_WIDTH_1); pcell.setBorderWidthRight(LINE_WIDTH_3); pcell.setPadding(0f); setAlignCenterMiddle(pcell); ptblL.addCell(pcell); pcell = new PdfPCell(new Paragraph(String.valueOf(piNumC[4]), min_14)); pcell.setBorderWidth(LINE_WIDTH_2); pcell.setBorderWidthRight(LINE_WIDTH_1); pcell.setBorderWidthLeft(LINE_WIDTH_3); pcell.setPadding(0f); setAlignCenterMiddle(pcell); ptblL.addCell(pcell); pcell = new PdfPCell(new Paragraph(String.valueOf(piNumC[5]), min_14)); pcell.setBorderWidth(LINE_WIDTH_1); pcell.setBorderWidthTop(LINE_WIDTH_2); pcell.setBorderWidthBottom(LINE_WIDTH_2); pcell.setPadding(0f); setAlignCenterMiddle(pcell); ptblL.addCell(pcell); pcell = new PdfPCell(new Paragraph(String.valueOf(piNumC[6]), min_14)); pcell.setBorderWidth(LINE_WIDTH_2); pcell.setBorderWidthRight(LINE_WIDTH_3); pcell.setBorderWidthLeft(LINE_WIDTH_1); pcell.setPadding(0f); setAlignCenterMiddle(pcell); ptblL.addCell(pcell); pcell = new PdfPCell(new Paragraph(String.valueOf(piNumC[7]), min_14)); pcell.setBorderWidth(LINE_WIDTH_1); pcell.setBorderWidthLeft(LINE_WIDTH_3); pcell.setPadding(0f); setAlignCenterMiddle(pcell); ptblL.addCell(pcell); pcell = new PdfPCell(new Paragraph("???", min_7)); pcell.setPaddingTop(0.3f); setAlignJustifiedAll(pcell); pcell.setBorderWidth(LINE_WIDTH_1); ptblL.addCell(pcell); pcell = new PdfPCell(new Paragraph(String.valueOf(rNumC[0]), min_14)); pcell.setBorderWidth(LINE_WIDTH_1); pcell.setPadding(0f); setAlignCenterMiddle(pcell); ptblL.addCell(pcell); pcell = new PdfPCell(new Paragraph(String.valueOf(rNumC[1]), min_14)); pcell.setBorderWidth(LINE_WIDTH_1); pcell.setPadding(0f); setAlignCenterMiddle(pcell); ptblL.addCell(pcell); pcell = new PdfPCell(new Paragraph(String.valueOf(rNumC[2]), min_14)); pcell.setBorderWidth(LINE_WIDTH_1); pcell.setBorderWidthRight(LINE_WIDTH_3); pcell.setPadding(0f); setAlignCenterMiddle(pcell); ptblL.addCell(pcell); pcell = new PdfPCell(new Paragraph(String.valueOf(rNumC[3]), min_14)); pcell.setBorderWidth(LINE_WIDTH_1); pcell.setBorderWidthLeft(LINE_WIDTH_3); pcell.setPadding(0f); setAlignCenterMiddle(pcell); ptblL.addCell(pcell); pcell = new PdfPCell(new Paragraph(String.valueOf(rNumC[4]), min_14)); pcell.setBorderWidth(LINE_WIDTH_1); pcell.setPadding(0f); setAlignCenterMiddle(pcell); ptblL.addCell(pcell); pcell = new PdfPCell(new Paragraph(String.valueOf(rNumC[5]), min_14)); pcell.setBorderWidth(LINE_WIDTH_1); pcell.setBorderWidthRight(LINE_WIDTH_3); pcell.setPadding(0f); setAlignCenterMiddle(pcell); ptblL.addCell(pcell); pcell = new PdfPCell(new Paragraph(String.valueOf(rNumC[6]), min_14)); pcell.setBorderWidth(LINE_WIDTH_1); pcell.setBorderWidthLeft(LINE_WIDTH_3); pcell.setPadding(0f); setAlignCenterMiddle(pcell); ptblL.addCell(pcell); pcell = new PdfPCell(); pcell.setBorderWidth(LINE_WIDTH_0); ptblL.addCell(pcell); PdfPTable patientTbl = new PdfPTable(2); patientTbl.setWidthPercentage(100f); float[] widthsPa = { 7.8f, 92.2f }; patientTbl.setWidths(widthsPa); patientTbl.getDefaultCell().setPadding(0f); patientTbl.getDefaultCell().setBorder(Table.NO_BORDER); PdfPCell pcellP = new PdfPCell(new Paragraph("", min_7)); pcellP.setBorderWidth(LINE_WIDTH_1); setAlignCenterMiddle(pcellP); patientTbl.addCell(pcellP); // PdfPTable desc = new PdfPTable(5); desc.setWidthPercentage(100f); float[] widthsD = { 28.5f, 41.5f, 7, 16, 7 }; desc.setWidths(widthsD); // ???(??) PdfPCell patientInfo = new PdfPCell(new Paragraph("???", min_7)); patientInfo.setBorderWidth(LINE_WIDTH_1); setAlignJustifiedAll(patientInfo); setAlignMiddle(patientInfo); desc.addCell(patientInfo); PdfPTable nameTbl = new PdfPTable(1); nameTbl.setWidthPercentage(100f); nameTbl.setSpacingAfter(3f); PdfPCell nameCell = new PdfPCell(new Paragraph(pkg.getPatientKana(), min_7)); nameCell.setBorderWidth(LINE_WIDTH_0); nameTbl.addCell(nameCell); nameCell = new PdfPCell(new Paragraph(pkg.getPatientName(), min_9)); nameCell.setBorderWidth(LINE_WIDTH_0); nameTbl.addCell(nameCell); patientInfo = new PdfPCell(nameTbl); patientInfo.setColspan(4); patientInfo.setBorderWidth(LINE_WIDTH_1); desc.addCell(patientInfo); // patientInfo = new PdfPCell(new Paragraph("", min_7)); patientInfo.setBorderWidth(LINE_WIDTH_1); setAlignJustifiedAll(patientInfo); desc.addCell(patientInfo); String birthDay = ModelUtils.convertToGengo(pkg.getPatientBirthday()); patientInfo = new PdfPCell(new Paragraph(birthDay, min_9)); patientInfo.setBorderWidth(LINE_WIDTH_1); patientInfo.setColspan(3); patientInfo.setPaddingTop(0.5f); setAlignMiddle(patientInfo); desc.addCell(patientInfo); patientInfo = new PdfPCell(new Paragraph(pkg.getPatientSex(), min_8)); patientInfo.setBorderWidth(LINE_WIDTH_1); setAlignCenter(patientInfo); desc.addCell(patientInfo); // patientInfo = new PdfPCell(new Paragraph("", min_7)); patientInfo.setBorderWidth(LINE_WIDTH_1); setAlignJustifiedAll(patientInfo); setAlignMiddle(patientInfo); desc.addCell(patientInfo); patientInfo = new PdfPCell(new Paragraph(div, min_8)); patientInfo.setBorderWidth(LINE_WIDTH_1); setAlignMiddle(patientInfo); desc.addCell(patientInfo); patientInfo = new PdfPCell(new Paragraph("?", min_7)); patientInfo.setBorderWidth(LINE_WIDTH_1); setAlignMiddle(patientInfo); desc.addCell(patientInfo); patientInfo = new PdfPCell(new Paragraph(payRatio, min_9)); setAlignRightMiddle(patientInfo); patientInfo.setBorderWidth(LINE_WIDTH_0); desc.addCell(patientInfo); patientInfo = new PdfPCell(new Paragraph("", min_7)); patientInfo.setBorderWidth(LINE_WIDTH_0); patientInfo.setVerticalAlignment(Element.ALIGN_BOTTOM); setAlignRight(patientInfo); desc.addCell(patientInfo); patientTbl.addCell(desc); pcell = new PdfPCell(patientTbl); pcell.setColspan(9); pcell.setBorderWidth(LINE_WIDTH_1); ptblL.addCell(pcell); // pcell = new PdfPCell(new Paragraph("", min_7)); pcell.setBorderWidth(LINE_WIDTH_1); setAlignJustifiedAll(pcell); setAlignMiddle(pcell); ptblL.addCell(pcell); // @003 2010/02/15 ??????????????? String issueDate = ModelUtils.convertToGengo( ModelUtils.getDateAsFormatString(pkg.getIssuanceDate(), IInfoModel.DATE_WITHOUT_TIME)); pcell = new PdfPCell(new Paragraph(issueDate, min_9)); pcell.setBorderWidth(LINE_WIDTH_1); pcell.setPaddingTop(0.5f); setAlignMiddle(pcell); pcell.setColspan(8); ptblL.addCell(pcell); ptbl.addCell(ptblL); ptbl.addCell(""); PdfPTable ptblR = new PdfPTable(10); ptblR.setSpacingBefore(10f); ptblR.setWidthPercentage(100f); float[] widthsR = { 30, 7, 7, 7, 7, 7, 7, 7, 7, 14 }; ptblR.setWidths(widthsR); pcell = new PdfPCell(new Paragraph("??", min_7)); pcell.setMinimumHeight(CELL_HIGHT_0); pcell.setBorderWidth(LINE_WIDTH_1); setAlignJustifiedAll(pcell); setAlignMiddle(pcell); ptblR.addCell(pcell); pcell = new PdfPCell(new Paragraph(String.valueOf(iNumC[0]), min_14)); pcell.setBorderWidth(LINE_WIDTH_1); pcell.setPadding(CELL_PADDING_0); setAlignCenterMiddle(pcell); ptblR.addCell(pcell); pcell = new PdfPCell(new Paragraph(String.valueOf(iNumC[1]), min_14)); pcell.setBorderWidth(LINE_WIDTH_1); pcell.setBorderWidthRight(LINE_WIDTH_2); pcell.setPadding(CELL_PADDING_0); setAlignCenterMiddle(pcell); ptblR.addCell(pcell); pcell = new PdfPCell(new Paragraph(String.valueOf(iNumC[2]), min_14)); pcell.setBorderWidth(LINE_WIDTH_1); pcell.setPadding(CELL_PADDING_0); setAlignCenterMiddle(pcell); ptblR.addCell(pcell); pcell = new PdfPCell(new Paragraph(String.valueOf(iNumC[3]), min_14)); pcell.setBorderWidth(LINE_WIDTH_1); pcell.setBorderWidthRight(LINE_WIDTH_2); pcell.setPadding(CELL_PADDING_0); setAlignCenterMiddle(pcell); ptblR.addCell(pcell); pcell = new PdfPCell(new Paragraph(String.valueOf(iNumC[4]), min_14)); pcell.setBorderWidth(LINE_WIDTH_1); pcell.setBorderWidthTop(LINE_WIDTH_2); pcell.setBorderWidthBottom(LINE_WIDTH_2); pcell.setPadding(CELL_PADDING_0); setAlignCenterMiddle(pcell); ptblR.addCell(pcell); pcell = new PdfPCell(new Paragraph(String.valueOf(iNumC[5]), min_14)); pcell.setBorderWidth(LINE_WIDTH_1); pcell.setBorderWidthTop(LINE_WIDTH_2); pcell.setBorderWidthBottom(LINE_WIDTH_2); pcell.setPadding(CELL_PADDING_0); setAlignCenterMiddle(pcell); ptblR.addCell(pcell); pcell = new PdfPCell(new Paragraph(String.valueOf(iNumC[6]), min_14)); pcell.setBorderWidth(LINE_WIDTH_2); pcell.setBorderWidthLeft(LINE_WIDTH_1); pcell.setPadding(CELL_PADDING_0); setAlignCenterMiddle(pcell); ptblR.addCell(pcell); pcell = new PdfPCell(new Paragraph(String.valueOf(iNumC[7]), min_14)); pcell.setBorderWidth(LINE_WIDTH_1); pcell.setPadding(CELL_PADDING_0); setAlignCenterMiddle(pcell); ptblR.addCell(pcell); pcell = new PdfPCell(); pcell.setBorderWidth(LINE_WIDTH_0); ptblR.addCell(pcell); pcell = new PdfPCell( new Paragraph("?????", min_7)); pcell.setPaddingTop(0.3f); pcell.setBorderWidth(LINE_WIDTH_1); setAlignJustifiedAll(pcell); setAlignMiddle(pcell); ptblR.addCell(pcell); pcell = new PdfPCell(new Paragraph(mNum, min_9)); pcell.setBorderWidth(LINE_WIDTH_1); pcell.setColspan(9); setAlignMiddle(pcell); ptblR.addCell(pcell); //FacilityModel facility = getPhysician().getFacilityModel(); String facilityName = pkg.getInstitutionName(); // ?? //String facilityZipCode = facility.getZipCode(); // ? String facilityAddress = pkg.getInstitutionAddress(); // ? String facilityTelNo = pkg.getInstitutionTelephone(); // ? //minagawa^ ????? String drName = pkg.getPhysicianName(); //minagawa$ if (pkg.isChkUseDrugInfo()) { // ?? drName = pkg.getPhysicianName(); } // ********** @008 2010/06/18 ********** // 20104? String prefNo = " "; // ?? 2? String grade = " "; // ? 1? String institution = " "; // 7? if ((pkg.getInstitutionNumber() != null) && (pkg.getInstitutionNumber().length() > 9)) { prefNo = pkg.getInstitutionNumber().substring(0, 2); grade = pkg.getInstitutionNumber().substring(2, 3); institution = pkg.getInstitutionNumber().substring(3, 10); } // ********** @008 2010/06/18 ********** PdfPTable medOrgTbl = new PdfPTable(3); medOrgTbl.setWidthPercentage(100f); float[] widthsM = { 30, 55, 15 }; medOrgTbl.setWidths(widthsM); PdfPCell medOrgCell = new PdfPCell(new Paragraph("??\n", min_7)); medOrgCell.setBorderWidth(LINE_WIDTH_0); setAlignJustifiedAll(medOrgCell); medOrgTbl.addCell(medOrgCell); medOrgCell = new PdfPCell(new Paragraph(facilityAddress, min_8)); medOrgCell.setBorderWidth(LINE_WIDTH_0); medOrgCell.setColspan(2); setAlignMiddle(medOrgCell); medOrgTbl.addCell(medOrgCell); medOrgCell = new PdfPCell(new Paragraph("????", min_7)); medOrgCell.setBorderWidth(LINE_WIDTH_0); setAlignJustifiedAll(medOrgCell); medOrgCell.setPaddingTop(CELL_PADDING_0); // @008 medOrgCell.setPaddingBottom(CELL_PADDING_0); // @008 medOrgTbl.addCell(medOrgCell); medOrgCell = new PdfPCell(new Paragraph(facilityName, min_8)); medOrgCell.setBorderWidth(LINE_WIDTH_0); medOrgCell.setColspan(2); medOrgCell.setPaddingTop(CELL_PADDING_0); // @008 medOrgCell.setPaddingBottom(CELL_PADDING_0); // @008 medOrgTbl.addCell(medOrgCell); medOrgCell = new PdfPCell(); medOrgCell.setBorder(Table.NO_BORDER); medOrgCell.setColspan(3); medOrgCell.setPaddingTop(CELL_PADDING_0); // @008 medOrgCell.setPaddingBottom(CELL_PADDING_0); // @008 medOrgTbl.addCell(medOrgCell); medOrgCell = new PdfPCell(new Paragraph("?", min_7)); medOrgCell.setBorderWidth(LINE_WIDTH_0); setAlignJustifiedAll(medOrgCell); setAlignMiddle(medOrgCell); medOrgCell.setPaddingTop(CELL_PADDING_0); // @008 medOrgTbl.addCell(medOrgCell); medOrgCell = new PdfPCell(new Paragraph(facilityTelNo, min_9)); medOrgCell.setBorderWidth(LINE_WIDTH_0); setAlignMiddle(medOrgCell); medOrgCell.setColspan(2); medOrgCell.setPaddingTop(CELL_PADDING_0); // @008 medOrgTbl.addCell(medOrgCell); medOrgCell = new PdfPCell(new Paragraph("????", min_7)); medOrgCell.setBorderWidth(LINE_WIDTH_0); setAlignJustifiedAll(medOrgCell); setAlignMiddle(medOrgCell); medOrgCell.setPaddingTop(CELL_PADDING_0); // @008 medOrgTbl.addCell(medOrgCell); medOrgCell = new PdfPCell(new Paragraph(drName, min_10)); medOrgCell.setBorderWidth(LINE_WIDTH_0); setAlignMiddle(medOrgCell); medOrgCell.setPaddingTop(CELL_PADDING_0); // @008 medOrgTbl.addCell(medOrgCell); medOrgCell = new PdfPCell(new Paragraph("?", min_8)); medOrgCell.setBorderWidth(LINE_WIDTH_0); setAlignMiddle(medOrgCell); medOrgCell.setPaddingTop(CELL_PADDING_0); // @008 medOrgTbl.addCell(medOrgCell); pcell = new PdfPCell(medOrgTbl); pcell.setBorder(Table.NO_BORDER); pcell.setColspan(10); pcell.setPaddingBottom(CELL_PADDING_1); ptblR.addCell(pcell); // ********** @008 2010/06/18 ********** // 20104? PdfPTable medCodeTbl = new PdfPTable(13); medCodeTbl.setWidthPercentage(100f); float[] widthsCode = { 17, 8, 8, 15, 8, 17, 8, 8, 8, 8, 8, 8, 8 }; medCodeTbl.setWidths(widthsCode); // ?? PdfPCell medCodeCell = new PdfPCell(new Paragraph("?\n?", min_6)); medCodeCell.setBorderWidth(LINE_WIDTH_1); setAlignCenterMiddle(medCodeCell); medCodeCell.setPaddingTop(CELL_PADDING_0); medCodeTbl.addCell(medCodeCell); medCodeCell = new PdfPCell(new Paragraph(String.valueOf(prefNo.charAt(0)), min_14)); medCodeCell.setBorderWidth(LINE_WIDTH_1); setAlignCenterMiddle(medCodeCell); medCodeCell.setPaddingTop(CELL_PADDING_0); medCodeTbl.addCell(medCodeCell); medCodeCell = new PdfPCell(new Paragraph(String.valueOf(prefNo.charAt(1)), min_14)); medCodeCell.setBorderWidth(LINE_WIDTH_1); setAlignCenterMiddle(medCodeCell); medCodeCell.setPaddingTop(CELL_PADDING_0); medCodeTbl.addCell(medCodeCell); medCodeCell = new PdfPCell(new Paragraph("\n?", min_6)); medCodeCell.setBorderWidth(LINE_WIDTH_1); setAlignCenterMiddle(medCodeCell); medCodeCell.setPaddingTop(CELL_PADDING_0); medCodeTbl.addCell(medCodeCell); medCodeCell = new PdfPCell(new Paragraph(String.valueOf(grade.charAt(0)), min_14)); medCodeCell.setBorderWidth(LINE_WIDTH_1); setAlignCenterMiddle(medCodeCell); medCodeCell.setPaddingTop(CELL_PADDING_0); medCodeTbl.addCell(medCodeCell); medCodeCell = new PdfPCell(new Paragraph("", min_6)); medCodeCell.setBorderWidth(LINE_WIDTH_1); setAlignCenterMiddle(medCodeCell); medCodeCell.setPaddingTop(CELL_PADDING_0); medCodeTbl.addCell(medCodeCell); medCodeCell = new PdfPCell(new Paragraph(String.valueOf(institution.charAt(0)), min_14)); medCodeCell.setBorderWidth(LINE_WIDTH_1); setAlignCenterMiddle(medCodeCell); medCodeCell.setPaddingTop(CELL_PADDING_0); medCodeTbl.addCell(medCodeCell); medCodeCell = new PdfPCell(new Paragraph(String.valueOf(institution.charAt(1)), min_14)); medCodeCell.setBorderWidth(LINE_WIDTH_1); setAlignCenterMiddle(medCodeCell); medCodeCell.setPaddingTop(CELL_PADDING_0); medCodeTbl.addCell(medCodeCell); medCodeCell = new PdfPCell(new Paragraph(String.valueOf(institution.charAt(2)), min_14)); medCodeCell.setBorderWidth(LINE_WIDTH_1); setAlignCenterMiddle(medCodeCell); medCodeCell.setPaddingTop(CELL_PADDING_0); medCodeTbl.addCell(medCodeCell); medCodeCell = new PdfPCell(new Paragraph(String.valueOf(institution.charAt(3)), min_14)); medCodeCell.setBorderWidth(LINE_WIDTH_1); setAlignCenterMiddle(medCodeCell); medCodeCell.setPaddingTop(CELL_PADDING_0); medCodeTbl.addCell(medCodeCell); medCodeCell = new PdfPCell(new Paragraph(String.valueOf(institution.charAt(4)), min_14)); medCodeCell.setBorderWidth(LINE_WIDTH_1); setAlignCenterMiddle(medCodeCell); medCodeCell.setPaddingTop(CELL_PADDING_0); medCodeTbl.addCell(medCodeCell); medCodeCell = new PdfPCell(new Paragraph(String.valueOf(institution.charAt(5)), min_14)); medCodeCell.setBorderWidth(LINE_WIDTH_1); setAlignCenterMiddle(medCodeCell); medCodeCell.setPaddingTop(CELL_PADDING_0); medCodeTbl.addCell(medCodeCell); medCodeCell = new PdfPCell(new Paragraph(String.valueOf(institution.charAt(6)), min_14)); medCodeCell.setBorderWidth(LINE_WIDTH_1); setAlignCenterMiddle(medCodeCell); medCodeCell.setPaddingTop(CELL_PADDING_0); medCodeTbl.addCell(medCodeCell); pcell = new PdfPCell(medCodeTbl); pcell.setBorder(Table.NO_BORDER); pcell.setColspan(10); pcell.setPaddingBottom(CELL_PADDING_1); ptblR.addCell(pcell); // ********** @008 2010/06/18 ********** ptbl.addCell(ptblR); // ?? PdfPTable termTbl = new PdfPTable(3); termTbl.setWidthPercentage(100f); float[] widthsT = { 14.8f, 26, 59.2f }; termTbl.setWidths(widthsT); termTbl.getDefaultCell().setPadding(0f); PdfPCell termCell = new PdfPCell(new Paragraph("??\n", min_7)); termCell.setBorderWidth(LINE_WIDTH_1); termCell.setPaddingTop(0.3f); setAlignJustifiedAll(termCell); termTbl.addCell(termCell); // ********* @009 2010/07/01 ********* String periodDate = "?"; if (pkg.getPeriod() != null) { periodDate = ModelUtils.convertToGengo( ModelUtils.getDateAsFormatString(pkg.getPeriod(), IInfoModel.DATE_WITHOUT_TIME)); } termCell = new PdfPCell(new Paragraph(periodDate, min_8)); // ********* @009 2010/07/01 ********* termCell.setBorderWidth(LINE_WIDTH_1); termCell.setBorderWidthRight(LINE_WIDTH_0); setAlignMiddle(termCell); termTbl.addCell(termCell); termCell = new PdfPCell(new Paragraph( "???????????????????", min_6)); termCell.setBorderWidth(LINE_WIDTH_1); termCell.setBorderWidthLeft(LINE_WIDTH_0); setAlignMiddle(termCell); termTbl.addCell(termCell); pcell = new PdfPCell(termTbl); pcell.setBorder(Table.NO_BORDER); pcell.setColspan(3); ptbl.addCell(pcell); document.add(ptbl); // ptbl = new PdfPTable(2); ptbl.setWidthPercentage(100f); ptbl.getDefaultCell().setPadding(0f); ptbl.getDefaultCell().setBorder(Table.NO_BORDER); float[] widthsPre = { 3.5f, 96.5f }; ptbl.setWidths(widthsPre); pcell = new PdfPCell( new Paragraph("", min_7)); pcell.setBorderWidth(LINE_WIDTH_1); setAlignCenterMiddle(pcell); ptbl.addCell(pcell); // @005 2010/02/26 // ?? // PdfPTable outLineTbl = new PdfPTable(1); PdfPCell outLineCell; // ? // @005 2010/02/26 // PdfPTable prescriptionTbl; // if (ite.hasNext()) { prescriptionTbl = ite.next(); } else { prescriptionTbl = new PdfPTable(1); } // @005 2010/02/26 // ?? outLineCell = new PdfPCell(prescriptionTbl); outLineCell.setFixedHeight(200f); outLineCell.setBorderWidth(LINE_WIDTH_0); outLineTbl.addCell(outLineCell); if (totalPageNo > 1) { pageNo++; outLineCell = new PdfPCell( new Paragraph((String.valueOf(pageNo) + "?" + String.valueOf(totalPageNo)), min_10)); setAlignRight(outLineCell); outLineCell.setFixedHeight(12f); // @010 outLineCell.setBorderWidth(LINE_WIDTH_1); // @010 outLineTbl.addCell(outLineCell); } // @005 2010/02/26 PdfPCell prescriptionCell = new PdfPCell(outLineTbl); prescriptionCell.setFixedHeight(215f); prescriptionCell.setBorderWidth(LINE_WIDTH_1); ptbl.addCell(prescriptionCell); // pcell = new PdfPCell(new Paragraph("", min_7)); pcell.setBorderWidth(LINE_WIDTH_1); setAlignCenterMiddle(pcell); ptbl.addCell(pcell); // PdfPTable noteTbl = new PdfPTable(5); // @010 noteTbl.setWidthPercentage(100f); float[] widthsN = { 11, 4, 34, 4, 47 }; // @010 noteTbl.setWidths(widthsN); noteTbl.getDefaultCell().setPadding(0f); noteTbl.getDefaultCell().setBorder(Table.NO_BORDER); String address = (pkg.getPatientAddress() == null) ? "" : pkg.getPatientAddress(); String patientName = pkg.getPatientName(); String addressName = "?" + address + "\n???" + patientName; String useDrugInfo = "??" + pkg.getDrugLicenseNumber() + "(" + pkg.getPhysicianName() + ")"; StringBuilder postInfo = new StringBuilder(); // if (pkg.isChkHomeMedical()) { postInfo.append(NOTES_HOME_MEDICAL + "\n"); } if (pkg.isChkPatientInfo()) { // ????? postInfo.append(addressName); } if (postInfo.length() > 0) { // postInfo.append("\n"); } if (pkg.isChkUseDrugInfo()) { // ?? postInfo.append(useDrugInfo); } // @010 20124 --> PdfPCell noteCell = new PdfPCell(new Paragraph("???", min_7)); noteCell.setBorderWidth(LINE_WIDTH_0); noteCell.setBorderWidthBottom(LINE_WIDTH_1); noteCell.setMinimumHeight(CELL_HIGHT_2); setAlignTop(noteCell); noteTbl.addCell(noteCell); noteCell = new PdfPCell(new Paragraph("", min_15));//min_15 noteCell.setBorderWidth(LINE_WIDTH_0); noteCell.setBorderWidthBottom(LINE_WIDTH_1); noteCell.setPadding(0f); setAlignRight(noteCell); noteTbl.addCell(noteCell); noteCell = new PdfPCell(new Paragraph( "??????????\n?????????????", min_6)); noteCell.setBorderWidth(LINE_WIDTH_0); noteCell.setBorderWidthBottom(LINE_WIDTH_1); noteTbl.addCell(noteCell); noteCell = new PdfPCell(new Paragraph("", min_15));//min_15 noteCell.setBorderWidth(LINE_WIDTH_0); noteCell.setBorderWidthBottom(LINE_WIDTH_1); noteCell.setBorderWidthRight(LINE_WIDTH_1); noteCell.setPadding(0f); setAlignLeft(noteCell); noteTbl.addCell(noteCell); //minagawa^ ???? 47 noteCell = new PdfPCell(); noteCell.setBorderWidth(LINE_WIDTH_0); noteTbl.addCell(noteCell); //minagawa noteCell = new PdfPCell(new Paragraph(postInfo.toString(), min_7)); // ???????? noteCell.setColspan(widthsN.length); noteCell.setMinimumHeight(40f); noteCell.setBorderWidth(LINE_WIDTH_0); noteTbl.addCell(noteCell); // <-- 20124 @010 pcell = new PdfPCell(noteTbl); pcell.setBorderWidth(LINE_WIDTH_1); ptbl.addCell(pcell); document.add(ptbl); // ?? ptbl = new PdfPTable(2); ptbl.setWidthPercentage(100f); float[] widthsOther = { 58, 42 }; ptbl.setWidths(widthsOther); ptbl.getDefaultCell().setPadding(0f); ptbl.getDefaultCell().setBorder(Table.NO_BORDER); // ptblL = new PdfPTable(3); ptblL.setWidthPercentage(100f); float[] widthsPh = { 28, 65, 7 }; ptblL.setWidths(widthsPh); ptblL.getDefaultCell().setPadding(0f); ptblL.getDefaultCell().setBorder(Table.NO_BORDER); PdfPCell pcellL = new PdfPCell(new Paragraph("", min_7)); pcellL.setMinimumHeight(CELL_HIGHT_0); pcellL.setBorderWidth(LINE_WIDTH_1); setAlignJustifiedAll(pcellL); setAlignMiddle(pcellL); ptblL.addCell(pcellL); pcellL = new PdfPCell(new Paragraph("?", min_8)); pcellL.setBorderWidth(LINE_WIDTH_1); setAlignMiddle(pcellL); pcellL.setColspan(2); ptblL.addCell(pcellL); pcellL = new PdfPCell(new Paragraph("??\n??\n??", min_7)); pcellL.setPaddingTop(0.2f); pcellL.setBorderWidth(LINE_WIDTH_1); pcellL.setBorderWidthBottom(LINE_WIDTH_0); setAlignJustifiedAll(pcellL); ptblL.addCell(pcellL); pcellL = new PdfPCell(); pcellL.setBorderWidth(LINE_WIDTH_0); pcellL.setBorderWidthRight(LINE_WIDTH_1); pcellL.setColspan(2); ptblL.addCell(pcellL); pcellL = new PdfPCell(new Paragraph("?\n???", min_7)); pcellL.setPaddingTop(0.2f); pcellL.setBorderWidth(LINE_WIDTH_1); pcellL.setBorderWidthTop(LINE_WIDTH_0); setAlignJustifiedAll(pcellL); ptblL.addCell(pcellL); pcellL = new PdfPCell(); pcellL.setBorderWidth(LINE_WIDTH_0); pcellL.setBorderWidthBottom(LINE_WIDTH_1); ptblL.addCell(pcellL); pcellL = new PdfPCell(new Paragraph("?", min_8)); pcellL.setBorderWidth(LINE_WIDTH_1); pcellL.setBorderWidthTop(LINE_WIDTH_0); pcellL.setBorderWidthLeft(LINE_WIDTH_0); setAlignJustifiedAll(pcellL); setAlignMiddle(pcellL); ptblL.addCell(pcellL); ptbl.addCell(ptblL); ptblR = new PdfPTable(9); ptblR.setWidthPercentage(100f); float[] widthsPu = { 33, 8, 8, 8, 8, 8, 8, 8, 8 }; ptblR.setWidths(widthsPu); ptblR.getDefaultCell().setPadding(0f); PdfPCell pcellR = new PdfPCell(new Paragraph("?", min_7)); pcellR.setMinimumHeight(CELL_HIGHT_0); setAlignJustifiedAll(pcellR); setAlignMiddle(pcellR); pcellR.setBorderWidth(LINE_WIDTH_1); ptblR.addCell(pcellR); pcellR = new PdfPCell(new Paragraph(String.valueOf(piNumC2[0]), min_14)); // @006 pcellR.setBorderWidth(LINE_WIDTH_1); pcellR.setPadding(0f); setAlignCenterMiddle(pcellR); ptblR.addCell(pcellR); pcellR = new PdfPCell(new Paragraph(String.valueOf(piNumC2[1]), min_14)); // @006 pcellR.setBorderWidth(LINE_WIDTH_1); pcellR.setBorderWidthRight(LINE_WIDTH_3); pcellR.setPadding(0f); setAlignCenterMiddle(pcellR); ptblR.addCell(pcellR); pcellR = new PdfPCell(new Paragraph(String.valueOf(piNumC2[2]), min_14)); // @006 pcellR.setBorderWidth(LINE_WIDTH_1); pcellR.setBorderWidthLeft(LINE_WIDTH_3); pcellR.setPadding(0f); setAlignCenterMiddle(pcellR); ptblR.addCell(pcellR); pcellR = new PdfPCell(new Paragraph(String.valueOf(piNumC2[3]), min_14)); // @006 pcellR.setBorderWidth(LINE_WIDTH_1); pcellR.setBorderWidthRight(LINE_WIDTH_3); pcellR.setPadding(0f); setAlignCenterMiddle(pcellR); ptblR.addCell(pcellR); pcellR = new PdfPCell(new Paragraph(String.valueOf(piNumC2[4]), min_14)); // @006 pcellR.setBorderWidth(LINE_WIDTH_2); pcellR.setBorderWidthRight(LINE_WIDTH_1); pcellR.setBorderWidthLeft(LINE_WIDTH_3); pcellR.setPadding(0f); setAlignCenterMiddle(pcellR); ptblR.addCell(pcellR); pcellR = new PdfPCell(new Paragraph(String.valueOf(piNumC2[5]), min_14)); // @006 pcellR.setBorderWidth(LINE_WIDTH_1); pcellR.setBorderWidthTop(LINE_WIDTH_2); pcellR.setBorderWidthBottom(LINE_WIDTH_2); pcellR.setPadding(0f); setAlignCenterMiddle(pcellR); ptblR.addCell(pcellR); pcellR = new PdfPCell(new Paragraph(String.valueOf(piNumC2[6]), min_14)); // @006 pcellR.setBorderWidth(LINE_WIDTH_2); pcellR.setBorderWidthRight(LINE_WIDTH_3); pcellR.setBorderWidthLeft(LINE_WIDTH_1); pcellR.setPadding(0f); setAlignCenterMiddle(pcellR); ptblR.addCell(pcellR); pcellR = new PdfPCell(new Paragraph(String.valueOf(piNumC2[7]), min_14)); // @006 pcellR.setBorderWidth(LINE_WIDTH_1); pcellR.setBorderWidthLeft(LINE_WIDTH_3); pcellR.setPadding(0f); setAlignCenterMiddle(pcellR); ptblR.addCell(pcellR); pcellR = new PdfPCell(new Paragraph("???", min_7)); pcellR.setPaddingTop(0.3f); setAlignJustifiedAll(pcellR); pcellR.setBorderWidth(LINE_WIDTH_1); ptblR.addCell(pcellR); pcellR = new PdfPCell(new Paragraph(String.valueOf(rNumC2[0]), min_14)); // @006 pcellR.setBorderWidth(LINE_WIDTH_1); pcellR.setPadding(0f); setAlignCenterMiddle(pcellR); ptblR.addCell(pcellR); pcellR = new PdfPCell(new Paragraph(String.valueOf(rNumC2[1]), min_14)); // @006 pcellR.setBorderWidth(LINE_WIDTH_1); pcellR.setPadding(0f); setAlignCenterMiddle(pcellR); ptblR.addCell(pcellR); pcellR = new PdfPCell(new Paragraph(String.valueOf(rNumC2[2]), min_14)); // @006 pcellR.setBorderWidth(LINE_WIDTH_1); pcellR.setBorderWidthRight(LINE_WIDTH_3); pcellR.setPadding(0f); setAlignCenterMiddle(pcellR); ptblR.addCell(pcellR); pcellR = new PdfPCell(new Paragraph(String.valueOf(rNumC2[3]), min_14)); // @006 pcellR.setBorderWidth(LINE_WIDTH_1); pcellR.setBorderWidthLeft(LINE_WIDTH_3); pcellR.setPadding(0f); setAlignCenterMiddle(pcellR); ptblR.addCell(pcellR); pcellR = new PdfPCell(new Paragraph(String.valueOf(rNumC2[4]), min_14)); // @006 pcellR.setBorderWidth(LINE_WIDTH_1); pcellR.setPadding(0f); setAlignCenterMiddle(pcellR); ptblR.addCell(pcellR); pcellR = new PdfPCell(new Paragraph(String.valueOf(rNumC2[5]), min_14)); // @006 pcellR.setBorderWidth(LINE_WIDTH_1); pcellR.setBorderWidthRight(LINE_WIDTH_3); pcellR.setPadding(0f); setAlignCenterMiddle(pcellR); ptblR.addCell(pcellR); pcellR = new PdfPCell(new Paragraph(String.valueOf(rNumC2[6]), min_14)); // @006 pcellR.setBorderWidth(LINE_WIDTH_1); pcellR.setBorderWidthLeft(LINE_WIDTH_3); pcellR.setPadding(0f); setAlignCenterMiddle(pcellR); ptblR.addCell(pcellR); pcellR = new PdfPCell(); pcellR.setBorderWidth(LINE_WIDTH_0); ptblR.addCell(pcellR); pcellR = new PdfPCell(); pcellR.setBorderWidth(LINE_WIDTH_0); pcellR.setColspan(9); ptblR.addCell(pcellR); ptbl.addCell(ptblR); document.add(ptbl); ptbl = new PdfPTable(2); ptbl.setWidthPercentage(100f); float[] widthsMed = { 3.5f, 96.5f }; ptbl.setWidths(widthsMed); ptbl.setSpacingBefore(3f); ptbl.getDefaultCell().setPadding(0f); ptbl.getDefaultCell().setBorder(Table.NO_BORDER); pcell = new PdfPCell(new Paragraph("????", min_7)); pcell.setBorderWidth(LINE_WIDTH_1); setAlignCenter(pcell); ptbl.addCell(pcell); ptblR = new PdfPTable(3); ptblR.setWidthPercentage(100f); float[] widthsPm = { 60, 20, 20 }; ptblR.setWidths(widthsPm); ptblR.getDefaultCell().setPadding(0f); ptblR.getDefaultCell().setBorder(Table.NO_BORDER); // ???????? PdfPTable pointTbl = new PdfPTable(7); pointTbl.setWidthPercentage(100f); float[] widthsPo = { 7, 15.5f, 15.5f, 15.5f, 15.5f, 15.5f, 15.5f }; pointTbl.setWidths(widthsPo); pointTbl.getDefaultCell().setPadding(0f); pointTbl.getDefaultCell().setBorder(Table.NO_BORDER); PdfPCell pointCell = new PdfPCell(new Paragraph("", min_7)); pointCell.setBorderWidth(LINE_WIDTH_1); setAlignCenterMiddle(pointCell); pointTbl.addCell(pointCell); pointCell = new PdfPCell(new Paragraph("", min_7)); pointCell.setBorderWidth(LINE_WIDTH_1); setAlignCenterMiddle(pointCell); pointTbl.addCell(pointCell); pointCell = new PdfPCell(new Paragraph("", min_7)); pointCell.setBorderWidth(LINE_WIDTH_1); setAlignCenterMiddle(pointCell); pointTbl.addCell(pointCell); pointCell = new PdfPCell(new Paragraph("?", min_7)); pointCell.setBorderWidth(LINE_WIDTH_1); setAlignCenterMiddle(pointCell); pointTbl.addCell(pointCell); pointCell = new PdfPCell(new Paragraph("", min_7)); pointCell.setBorderWidth(LINE_WIDTH_1); setAlignCenterMiddle(pointCell); pointTbl.addCell(pointCell); pointCell = new PdfPCell(new Paragraph("?", min_7)); pointCell.setBorderWidth(LINE_WIDTH_1); setAlignCenterMiddle(pointCell); pointTbl.addCell(pointCell); pointCell = new PdfPCell(new Paragraph("", min_7)); pointCell.setBorderWidth(LINE_WIDTH_1); setAlignCenterMiddle(pointCell); pointTbl.addCell(pointCell); // ? PdfPCell blankCell = new PdfPCell(); blankCell.setBorderWidth(LINE_WIDTH_1); pointTbl.addCell(blankCell); pointTbl.addCell(blankCell); pointTbl.addCell(blankCell); pointTbl.addCell(blankCell); pointTbl.addCell(blankCell); pointTbl.addCell(blankCell); pointTbl.addCell(blankCell); ptblR.addCell(pointTbl); // ? PdfPTable feeTbl = new PdfPTable(2); feeTbl.setWidthPercentage(100f); float[] widthsF = { 50, 50 }; feeTbl.setWidths(widthsF); feeTbl.getDefaultCell().setPadding(0f); feeTbl.getDefaultCell().setBorder(Table.NO_BORDER); PdfPCell feeCell = new PdfPCell(new Paragraph(" ", min_7)); feeCell.setBorderWidth(LINE_WIDTH_1); setAlignCenter(feeCell); feeTbl.addCell(feeCell); feeCell = new PdfPCell(new Paragraph(" ", min_7)); feeCell.setBorderWidth(LINE_WIDTH_1); setAlignCenter(feeCell); feeTbl.addCell(feeCell); feeCell = new PdfPCell(); feeCell.setBorderWidth(LINE_WIDTH_1); feeCell.setMinimumHeight(CELL_HIGHT_1); feeTbl.addCell(feeCell); feeTbl.addCell(feeCell); // ?etc.. PdfPTable feeTblSub = new PdfPTable(4); feeTblSub.setWidthPercentage(100f); float[] widthsSub = { 28, 16, 28, 28 }; feeTblSub.setWidths(widthsSub); feeTblSub.getDefaultCell().setPadding(0f); feeTblSub.getDefaultCell().setBorder(Table.NO_BORDER); PdfPCell feeCellSub = new PdfPCell(new Paragraph("?", min_7)); feeCellSub.setBorderWidth(LINE_WIDTH_1); setAlignCenter(feeCellSub); feeTblSub.addCell(feeCellSub); feeCellSub = new PdfPCell(new Paragraph("", min_7)); feeCellSub.setBorderWidth(LINE_WIDTH_1); setAlignCenter(feeCellSub); feeTblSub.addCell(feeCellSub); feeCellSub = new PdfPCell(new Paragraph(" ", min_7)); feeCellSub.setBorderWidth(LINE_WIDTH_1); setAlignCenter(feeCellSub); feeTblSub.addCell(feeCellSub); feeCellSub = new PdfPCell(new Paragraph("? ", min_7)); feeCellSub.setBorderWidth(LINE_WIDTH_1); setAlignCenter(feeCellSub); feeTblSub.addCell(feeCellSub); // ? feeCellSub = new PdfPCell(); feeCellSub.setBorderWidth(LINE_WIDTH_1); feeCellSub.setMinimumHeight(CELL_HIGHT_1); feeTblSub.addCell(feeCellSub); feeTblSub.addCell(feeCellSub); feeTblSub.addCell(feeCellSub); feeTblSub.addCell(feeCellSub); feeCell = new PdfPCell(feeTblSub); feeCell.setBorder(Table.NO_BORDER); feeCell.setColspan(2); feeTbl.addCell(feeCell); // etc..? pcellR = new PdfPCell(feeTbl); pcellR.setPadding(0f); pcellR.setColspan(2); pcellR.setBorder(Table.NO_BORDER); ptblR.addCell(pcellR); // noteTbl = new PdfPTable(2); noteTbl.setWidthPercentage(100f); float[] widthsNote = { 5.3f, 94.7f }; noteTbl.setWidths(widthsNote); noteTbl.getDefaultCell().setPadding(0f); noteTbl.getDefaultCell().setBorder(Table.NO_BORDER); noteCell = new PdfPCell(new Paragraph("", min_7)); noteCell.setBorderWidth(LINE_WIDTH_1); setAlignCenterMiddle(noteCell); noteTbl.addCell(noteCell); noteCell = new PdfPCell(); noteCell.setBorderWidth(LINE_WIDTH_1); noteTbl.addCell(noteCell); pcell = new PdfPCell(noteTbl); pcell.setBorderWidth(LINE_WIDTH_0); pcell.setPadding(0f); pcell.setColspan(2); ptblR.addCell(pcell); // ? PdfPTable sumTbl = new PdfPTable(1); sumTbl.setWidthPercentage(100f); sumTbl.getDefaultCell().setPadding(0f); sumTbl.getDefaultCell().setBorder(Table.NO_BORDER); PdfPCell sumCell = new PdfPCell(new Paragraph("?", min_7)); sumCell.setBorderWidth(LINE_WIDTH_1); setAlignCenter(sumCell); sumTbl.addCell(sumCell); sumCell = new PdfPCell(); sumCell.setBorderWidth(LINE_WIDTH_1); sumCell.setMinimumHeight(CELL_HIGHT_1); sumTbl.addCell(sumCell); ptblR.addCell(sumTbl); pcell = new PdfPCell(ptblR); pcell.setBorderWidth(LINE_WIDTH_0); pcell.setPadding(0f); ptbl.addCell(pcell); document.add(ptbl); // if (ite.hasNext()) { document.newPage(); } } while (ite.hasNext()); document.close(); bos.close(); // pdf content bytes byte[] pdfbytes = byteo.toByteArray(); // ????? File???? //if (!ClientContext.is5mTest()) { if (!Project.isTester()) { FileOutputStream fout = new FileOutputStream(pathToPDF); FileChannel channel = fout.getChannel(); ByteBuffer bytebuff = ByteBuffer.wrap(pdfbytes); while (bytebuff.hasRemaining()) { channel.write(bytebuff); } channel.close(); return pathToPDF; } // ??? water Mark ?? PdfReader pdfReader = new PdfReader(pdfbytes); PdfStamper pdfStamper = new PdfStamper(pdfReader, new FileOutputStream(pathToPDF)); Image image = Image.getInstance(ClientContext.getImageResource("water-mark.png")); for (int i = 1; i <= pdfReader.getNumberOfPages(); i++) { PdfContentByte content = pdfStamper.getUnderContent(i); image.scaleAbsolute(PageSize.A5.getWidth(), PageSize.A5.getHeight()); image.setAbsolutePosition(0.0f, 0.0f); content.addImage(image); } pdfStamper.close(); return pathToPDF; } catch (DocumentException e) { e.printStackTrace(System.err); throw new RuntimeException(e.getMessage()); } catch (IOException e) { e.printStackTrace(System.err); throw new RuntimeException(e.getMessage()); } catch (Exception e) { e.printStackTrace(System.err); throw new RuntimeException(e.getMessage()); } finally { if (document != null && document.isOpen()) { document.close(); } } }
From source file:open.dolphin.msg.ServerPrescriptionPDFMaker.java
/** * ??/*from w w w .ja va 2 s.c o m*/ */ public String output() { BufferedOutputStream bos; PdfWriter pw = null; Document document = null; try { Date dateNow = new Date(); // ID String patientId = pkg.getPatientId(); // ??? String name = pkg.getPatientName(); name = name.replaceAll(" ", ""); name = name.replaceAll("", ""); String iNum; // ?? String piNum = null; // ? String rNum = null; // ?? String piNum2 = null; // ? String rNum2 = null; // ?? String div = ""; // ? String payRatio = ""; // ? String mNum = ""; // ??? char[] iNumC = new char[8]; // ??? char[] piNumC = new char[8]; // ?? char[] rNumC = new char[7]; // ?? char[] piNumC2 = new char[8]; // ?? char[] rNumC2 = new char[7]; // ?? DecimalFormat df = new DecimalFormat("#0.#"); // ?? String paymentRatio = ""; // ? String paymentRatio2 = ""; // ? if (pkg.getApplyedInsurance().getInsuranceNumber() != null) { // ?? iNum = pkg.getApplyedInsurance().getInsuranceNumber(); // ? null ?? if (iNum.toLowerCase().startsWith("z") || iNum.equals("9999")) { iNum = null; } // if (pkg.getApplyedInsurance().getPVTPublicInsuranceItem() != null) { PVTPublicInsuranceItemModel[] pubItems = pkg.getApplyedInsurance().getPVTPublicInsuranceItem(); for (int i = 0; i < pubItems.length; i++) { PVTPublicInsuranceItemModel pm = pubItems[i]; if (i == 0) { // ? piNum = pm.getProvider(); piNum = ("mikinyu".equals(piNum)) ? "" : piNum; // ?? rNum = pm.getRecipient(); rNum = ("mikinyu".equals(rNum)) ? "" : rNum; // ??? paymentRatio = pm.getPaymentRatio(); } else if (i == 1) { piNum2 = pm.getProvider(); piNum2 = ("mikinyu".equals(piNum2)) ? "" : piNum2; rNum2 = pm.getRecipient(); rNum2 = ("mikinyu".equals(rNum2)) ? "" : rNum2; paymentRatio2 = pm.getPaymentRatio(); break; } } } // ? ?? ? StringBuilder sb = new StringBuilder(); // ? ? if (pkg.getApplyedInsurance().getClientGroup() != null && !pkg.getApplyedInsurance().getClientGroup().equals("??")) { sb.append(pkg.getApplyedInsurance().getClientGroup()).append(""); } // ?? if (pkg.getApplyedInsurance().getClientNumber() != null && !pkg.getApplyedInsurance().getClientNumber().equals("??")) { sb.append(pkg.getApplyedInsurance().getClientNumber()); } mNum = sb.length() > 0 ? sb.toString() : ""; // if ("?".equals(pkg.getApplyedInsurance().getInsuranceClass())) { div = ""; payRatio = paymentRatio; } else { // ? div = "true".equals(pkg.getApplyedInsurance().getFamilyClass()) ? "?" : ""; payRatio = pkg.getApplyedInsurance().getPayOutRatio(); } if (payRatio != null && !("".equals(payRatio))) { payRatio = df.format(Double.valueOf(payRatio) * 10); } if (DEBUG) { System.err.println("iNum=" + iNum); System.err.println("piNum=" + piNum); System.err.println("rNum=" + rNum); System.err.println("piNum2=" + piNum2); System.err.println("rNum2=" + rNum2); System.err.println("mNum=" + mNum); System.err.println("?=" + div); System.err.println("=" + payRatio); } // ??? iNumC = partitionPadRL(iNum, 8, "R"); // ?? piNumC = partitionPadRL(piNum, 8, "L"); // ? rNumC = partitionPadRL(rNum, 7, "L"); // ?? piNumC2 = partitionPadRL(piNum2, 8, "L"); // ?2 rNumC2 = partitionPadRL(rNum2, 7, "L"); // ??2 } /***** *****/ document = new Document(PageSize.A5, 10, 10, 2, 2); // ?PDF?welcome-content if (getDocumentDir() == null) { StringBuilder sb = new StringBuilder(); sb.append(System.getProperty("jboss.home.dir")); sb.append(File.separator); sb.append(DIR_NAME); setDocumentDir(sb.toString()); } File dir = new File(getDocumentDir()); dir.mkdir(); // ??(ID_.pdf) StringBuilder sb = new StringBuilder(); sb.append(patientId).append("_"); sb.append(new SimpleDateFormat("yyyyMMddHHmmss").format(dateNow)); sb.append(FILE_EXTENTION); setFileName(sb.toString()); sb = new StringBuilder(); sb.append(getDocumentDir()); sb.append(File.separator); sb.append(getFileName()); pathToPDF = sb.toString(); //minagawa^ ???water mark?????????? byte[]??? ByteArrayOutputStream byteo = new ByteArrayOutputStream(); bos = new BufferedOutputStream(byteo); //minagawa$ pw = PdfWriter.getInstance(document, bos); // font setting bfm = BaseFont.createFont(FONT_HEISEI_MIN3, CODE_UNIJIS_H, BaseFont.NOT_EMBEDDED); bfg = BaseFont.createFont(FONT_HEISEI_KAKU5, CODE_UNIJIS_H, BaseFont.NOT_EMBEDDED); min_6 = new Font(bfm, 6); min_7 = new Font(bfm, 7); min_8 = new Font(bfm, 8); min_9 = new Font(bfm, 9); min_10 = new Font(bfm, 10); min_12 = new Font(bfm, 12); min_14 = new Font(bfm, 14); min_15 = new Font(bfm, 15); min_4 = new Font(bfm, 4); // @009 // document.open(); document.addAuthor(pkg.getPhysicianName()); document.addTitle(PROPERTY_TITLE); document.addSubject(PROPERTY_SUB_TITLE); // ??? List<PdfPTable> list = createPrescriptionTbl2(); Iterator<PdfPTable> ite = list.iterator(); // ? int pageNo = 0; int totalPageNo = list.size(); // ????????? do { PdfPTable ptbl = new PdfPTable(1); ptbl.setWidthPercentage(100f); ptbl.getDefaultCell().setPadding(0f); PdfPCell pcell = new PdfPCell(new Paragraph(REPORT_TITLE, min_15)); pcell.setBorder(Table.NO_BORDER); setAlignCenter(pcell); ptbl.addCell(pcell); pcell = new PdfPCell(new Paragraph(REPORT_SUB_TITLE, min_7)); pcell.setBorder(Table.NO_BORDER); setAlignCenter(pcell); ptbl.addCell(pcell); document.add(ptbl); ptbl = new PdfPTable(3); ptbl.setWidthPercentage(100f); ptbl.getDefaultCell().setPadding(0f); ptbl.getDefaultCell().setBorder(Table.NO_BORDER); float[] widths = { 43.5f, 2f, 54.5f }; ptbl.setWidths(widths); // ? pcell = new PdfPCell(new Paragraph(patientId, min_9)); pcell.setBorder(Table.NO_BORDER); pcell.setColspan(10); ptbl.addCell(pcell); PdfPTable ptblL = new PdfPTable(9); ptblL.setSpacingBefore(10f); ptblL.setWidthPercentage(100f); float[] widthsL = { 33, 8, 8, 8, 8, 8, 8, 8, 8 }; ptblL.setWidths(widthsL); ptblL.getDefaultCell().setPadding(0f); pcell = new PdfPCell(new Paragraph("?", min_7)); pcell.setMinimumHeight(CELL_HIGHT_0); setAlignJustifiedAll(pcell); setAlignMiddle(pcell); pcell.setBorderWidth(LINE_WIDTH_1); ptblL.addCell(pcell); pcell = new PdfPCell(new Paragraph(String.valueOf(piNumC[0]), min_14)); pcell.setBorderWidth(LINE_WIDTH_1); pcell.setPadding(0f); setAlignCenterMiddle(pcell); ptblL.addCell(pcell); pcell = new PdfPCell(new Paragraph(String.valueOf(piNumC[1]), min_14)); pcell.setBorderWidth(LINE_WIDTH_1); pcell.setBorderWidthRight(LINE_WIDTH_3); pcell.setPadding(0f); setAlignCenterMiddle(pcell); ptblL.addCell(pcell); pcell = new PdfPCell(new Paragraph(String.valueOf(piNumC[2]), min_14)); pcell.setBorderWidth(LINE_WIDTH_1); pcell.setBorderWidthLeft(LINE_WIDTH_3); pcell.setPadding(0f); setAlignCenterMiddle(pcell); ptblL.addCell(pcell); pcell = new PdfPCell(new Paragraph(String.valueOf(piNumC[3]), min_14)); pcell.setBorderWidth(LINE_WIDTH_1); pcell.setBorderWidthRight(LINE_WIDTH_3); pcell.setPadding(0f); setAlignCenterMiddle(pcell); ptblL.addCell(pcell); pcell = new PdfPCell(new Paragraph(String.valueOf(piNumC[4]), min_14)); pcell.setBorderWidth(LINE_WIDTH_2); pcell.setBorderWidthRight(LINE_WIDTH_1); pcell.setBorderWidthLeft(LINE_WIDTH_3); pcell.setPadding(0f); setAlignCenterMiddle(pcell); ptblL.addCell(pcell); pcell = new PdfPCell(new Paragraph(String.valueOf(piNumC[5]), min_14)); pcell.setBorderWidth(LINE_WIDTH_1); pcell.setBorderWidthTop(LINE_WIDTH_2); pcell.setBorderWidthBottom(LINE_WIDTH_2); pcell.setPadding(0f); setAlignCenterMiddle(pcell); ptblL.addCell(pcell); pcell = new PdfPCell(new Paragraph(String.valueOf(piNumC[6]), min_14)); pcell.setBorderWidth(LINE_WIDTH_2); pcell.setBorderWidthRight(LINE_WIDTH_3); pcell.setBorderWidthLeft(LINE_WIDTH_1); pcell.setPadding(0f); setAlignCenterMiddle(pcell); ptblL.addCell(pcell); pcell = new PdfPCell(new Paragraph(String.valueOf(piNumC[7]), min_14)); pcell.setBorderWidth(LINE_WIDTH_1); pcell.setBorderWidthLeft(LINE_WIDTH_3); pcell.setPadding(0f); setAlignCenterMiddle(pcell); ptblL.addCell(pcell); pcell = new PdfPCell(new Paragraph("???", min_7)); pcell.setPaddingTop(0.3f); setAlignJustifiedAll(pcell); pcell.setBorderWidth(LINE_WIDTH_1); ptblL.addCell(pcell); pcell = new PdfPCell(new Paragraph(String.valueOf(rNumC[0]), min_14)); pcell.setBorderWidth(LINE_WIDTH_1); pcell.setPadding(0f); setAlignCenterMiddle(pcell); ptblL.addCell(pcell); pcell = new PdfPCell(new Paragraph(String.valueOf(rNumC[1]), min_14)); pcell.setBorderWidth(LINE_WIDTH_1); pcell.setPadding(0f); setAlignCenterMiddle(pcell); ptblL.addCell(pcell); pcell = new PdfPCell(new Paragraph(String.valueOf(rNumC[2]), min_14)); pcell.setBorderWidth(LINE_WIDTH_1); pcell.setBorderWidthRight(LINE_WIDTH_3); pcell.setPadding(0f); setAlignCenterMiddle(pcell); ptblL.addCell(pcell); pcell = new PdfPCell(new Paragraph(String.valueOf(rNumC[3]), min_14)); pcell.setBorderWidth(LINE_WIDTH_1); pcell.setBorderWidthLeft(LINE_WIDTH_3); pcell.setPadding(0f); setAlignCenterMiddle(pcell); ptblL.addCell(pcell); pcell = new PdfPCell(new Paragraph(String.valueOf(rNumC[4]), min_14)); pcell.setBorderWidth(LINE_WIDTH_1); pcell.setPadding(0f); setAlignCenterMiddle(pcell); ptblL.addCell(pcell); pcell = new PdfPCell(new Paragraph(String.valueOf(rNumC[5]), min_14)); pcell.setBorderWidth(LINE_WIDTH_1); pcell.setBorderWidthRight(LINE_WIDTH_3); pcell.setPadding(0f); setAlignCenterMiddle(pcell); ptblL.addCell(pcell); pcell = new PdfPCell(new Paragraph(String.valueOf(rNumC[6]), min_14)); pcell.setBorderWidth(LINE_WIDTH_1); pcell.setBorderWidthLeft(LINE_WIDTH_3); pcell.setPadding(0f); setAlignCenterMiddle(pcell); ptblL.addCell(pcell); pcell = new PdfPCell(); pcell.setBorderWidth(LINE_WIDTH_0); ptblL.addCell(pcell); PdfPTable patientTbl = new PdfPTable(2); patientTbl.setWidthPercentage(100f); float[] widthsPa = { 7.8f, 92.2f }; patientTbl.setWidths(widthsPa); patientTbl.getDefaultCell().setPadding(0f); patientTbl.getDefaultCell().setBorder(Table.NO_BORDER); PdfPCell pcellP = new PdfPCell(new Paragraph("", min_7)); pcellP.setBorderWidth(LINE_WIDTH_1); setAlignCenterMiddle(pcellP); patientTbl.addCell(pcellP); // PdfPTable desc = new PdfPTable(5); desc.setWidthPercentage(100f); float[] widthsD = { 28.5f, 41.5f, 7, 16, 7 }; desc.setWidths(widthsD); // ???(??) PdfPCell patientInfo = new PdfPCell(new Paragraph("???", min_7)); patientInfo.setBorderWidth(LINE_WIDTH_1); setAlignJustifiedAll(patientInfo); setAlignMiddle(patientInfo); desc.addCell(patientInfo); PdfPTable nameTbl = new PdfPTable(1); nameTbl.setWidthPercentage(100f); nameTbl.setSpacingAfter(3f); PdfPCell nameCell = new PdfPCell(new Paragraph(pkg.getPatientKana(), min_7)); nameCell.setBorderWidth(LINE_WIDTH_0); nameTbl.addCell(nameCell); nameCell = new PdfPCell(new Paragraph(pkg.getPatientName(), min_9)); nameCell.setBorderWidth(LINE_WIDTH_0); nameTbl.addCell(nameCell); patientInfo = new PdfPCell(nameTbl); patientInfo.setColspan(4); patientInfo.setBorderWidth(LINE_WIDTH_1); desc.addCell(patientInfo); // patientInfo = new PdfPCell(new Paragraph("", min_7)); patientInfo.setBorderWidth(LINE_WIDTH_1); setAlignJustifiedAll(patientInfo); desc.addCell(patientInfo); String birthDay = ModelUtils.convertToGengo(pkg.getPatientBirthday()); patientInfo = new PdfPCell(new Paragraph(birthDay, min_9)); patientInfo.setBorderWidth(LINE_WIDTH_1); patientInfo.setColspan(3); patientInfo.setPaddingTop(0.5f); setAlignMiddle(patientInfo); desc.addCell(patientInfo); patientInfo = new PdfPCell(new Paragraph(pkg.getPatientSex(), min_8)); patientInfo.setBorderWidth(LINE_WIDTH_1); setAlignCenter(patientInfo); desc.addCell(patientInfo); // patientInfo = new PdfPCell(new Paragraph("", min_7)); patientInfo.setBorderWidth(LINE_WIDTH_1); setAlignJustifiedAll(patientInfo); setAlignMiddle(patientInfo); desc.addCell(patientInfo); patientInfo = new PdfPCell(new Paragraph(div, min_8)); patientInfo.setBorderWidth(LINE_WIDTH_1); setAlignMiddle(patientInfo); desc.addCell(patientInfo); patientInfo = new PdfPCell(new Paragraph("?", min_7)); patientInfo.setBorderWidth(LINE_WIDTH_1); setAlignMiddle(patientInfo); desc.addCell(patientInfo); patientInfo = new PdfPCell(new Paragraph(payRatio, min_9)); setAlignRightMiddle(patientInfo); patientInfo.setBorderWidth(LINE_WIDTH_0); desc.addCell(patientInfo); patientInfo = new PdfPCell(new Paragraph("", min_7)); patientInfo.setBorderWidth(LINE_WIDTH_0); patientInfo.setVerticalAlignment(Element.ALIGN_BOTTOM); setAlignRight(patientInfo); desc.addCell(patientInfo); patientTbl.addCell(desc); pcell = new PdfPCell(patientTbl); pcell.setColspan(9); pcell.setBorderWidth(LINE_WIDTH_1); ptblL.addCell(pcell); // pcell = new PdfPCell(new Paragraph("", min_7)); pcell.setBorderWidth(LINE_WIDTH_1); setAlignJustifiedAll(pcell); setAlignMiddle(pcell); ptblL.addCell(pcell); // @003 2010/02/15 ??????????????? String issueDate = ModelUtils.convertToGengo( ModelUtils.getDateAsFormatString(pkg.getIssuanceDate(), IInfoModel.DATE_WITHOUT_TIME)); pcell = new PdfPCell(new Paragraph(issueDate, min_9)); pcell.setBorderWidth(LINE_WIDTH_1); pcell.setPaddingTop(0.5f); setAlignMiddle(pcell); pcell.setColspan(8); ptblL.addCell(pcell); ptbl.addCell(ptblL); ptbl.addCell(""); PdfPTable ptblR = new PdfPTable(10); ptblR.setSpacingBefore(10f); ptblR.setWidthPercentage(100f); float[] widthsR = { 30, 7, 7, 7, 7, 7, 7, 7, 7, 14 }; ptblR.setWidths(widthsR); pcell = new PdfPCell(new Paragraph("??", min_7)); pcell.setMinimumHeight(CELL_HIGHT_0); pcell.setBorderWidth(LINE_WIDTH_1); setAlignJustifiedAll(pcell); setAlignMiddle(pcell); ptblR.addCell(pcell); pcell = new PdfPCell(new Paragraph(String.valueOf(iNumC[0]), min_14)); pcell.setBorderWidth(LINE_WIDTH_1); pcell.setPadding(CELL_PADDING_0); setAlignCenterMiddle(pcell); ptblR.addCell(pcell); pcell = new PdfPCell(new Paragraph(String.valueOf(iNumC[1]), min_14)); pcell.setBorderWidth(LINE_WIDTH_1); pcell.setBorderWidthRight(LINE_WIDTH_2); pcell.setPadding(CELL_PADDING_0); setAlignCenterMiddle(pcell); ptblR.addCell(pcell); pcell = new PdfPCell(new Paragraph(String.valueOf(iNumC[2]), min_14)); pcell.setBorderWidth(LINE_WIDTH_1); pcell.setPadding(CELL_PADDING_0); setAlignCenterMiddle(pcell); ptblR.addCell(pcell); pcell = new PdfPCell(new Paragraph(String.valueOf(iNumC[3]), min_14)); pcell.setBorderWidth(LINE_WIDTH_1); pcell.setBorderWidthRight(LINE_WIDTH_2); pcell.setPadding(CELL_PADDING_0); setAlignCenterMiddle(pcell); ptblR.addCell(pcell); pcell = new PdfPCell(new Paragraph(String.valueOf(iNumC[4]), min_14)); pcell.setBorderWidth(LINE_WIDTH_1); pcell.setBorderWidthTop(LINE_WIDTH_2); pcell.setBorderWidthBottom(LINE_WIDTH_2); pcell.setPadding(CELL_PADDING_0); setAlignCenterMiddle(pcell); ptblR.addCell(pcell); pcell = new PdfPCell(new Paragraph(String.valueOf(iNumC[5]), min_14)); pcell.setBorderWidth(LINE_WIDTH_1); pcell.setBorderWidthTop(LINE_WIDTH_2); pcell.setBorderWidthBottom(LINE_WIDTH_2); pcell.setPadding(CELL_PADDING_0); setAlignCenterMiddle(pcell); ptblR.addCell(pcell); pcell = new PdfPCell(new Paragraph(String.valueOf(iNumC[6]), min_14)); pcell.setBorderWidth(LINE_WIDTH_2); pcell.setBorderWidthLeft(LINE_WIDTH_1); pcell.setPadding(CELL_PADDING_0); setAlignCenterMiddle(pcell); ptblR.addCell(pcell); pcell = new PdfPCell(new Paragraph(String.valueOf(iNumC[7]), min_14)); pcell.setBorderWidth(LINE_WIDTH_1); pcell.setPadding(CELL_PADDING_0); setAlignCenterMiddle(pcell); ptblR.addCell(pcell); pcell = new PdfPCell(); pcell.setBorderWidth(LINE_WIDTH_0); ptblR.addCell(pcell); pcell = new PdfPCell( new Paragraph("?????", min_7)); pcell.setPaddingTop(0.3f); pcell.setBorderWidth(LINE_WIDTH_1); setAlignJustifiedAll(pcell); setAlignMiddle(pcell); ptblR.addCell(pcell); pcell = new PdfPCell(new Paragraph(mNum, min_9)); pcell.setBorderWidth(LINE_WIDTH_1); pcell.setColspan(9); setAlignMiddle(pcell); ptblR.addCell(pcell); //FacilityModel facility = getPhysician().getFacilityModel(); String facilityName = pkg.getInstitutionName(); // ?? //String facilityZipCode = facility.getZipCode(); // ? String facilityAddress = pkg.getInstitutionAddress(); // ? String facilityTelNo = pkg.getInstitutionTelephone(); // ? //minagawa^ ????? String drName = pkg.getPhysicianName(); //minagawa$ if (pkg.isChkUseDrugInfo()) { // ?? drName = pkg.getPhysicianName(); } // ********** @008 2010/06/18 ********** // 20104? String prefNo = " "; // ?? 2? String grade = " "; // ? 1? String institution = " "; // 7? if ((pkg.getInstitutionNumber() != null) && (pkg.getInstitutionNumber().length() > 9)) { prefNo = pkg.getInstitutionNumber().substring(0, 2); grade = pkg.getInstitutionNumber().substring(2, 3); institution = pkg.getInstitutionNumber().substring(3, 10); } // ********** @008 2010/06/18 ********** PdfPTable medOrgTbl = new PdfPTable(3); medOrgTbl.setWidthPercentage(100f); float[] widthsM = { 30, 55, 15 }; medOrgTbl.setWidths(widthsM); PdfPCell medOrgCell = new PdfPCell(new Paragraph("??\n", min_7)); medOrgCell.setBorderWidth(LINE_WIDTH_0); setAlignJustifiedAll(medOrgCell); medOrgTbl.addCell(medOrgCell); medOrgCell = new PdfPCell(new Paragraph(facilityAddress, min_8)); medOrgCell.setBorderWidth(LINE_WIDTH_0); medOrgCell.setColspan(2); setAlignMiddle(medOrgCell); medOrgTbl.addCell(medOrgCell); medOrgCell = new PdfPCell(new Paragraph("????", min_7)); medOrgCell.setBorderWidth(LINE_WIDTH_0); setAlignJustifiedAll(medOrgCell); medOrgCell.setPaddingTop(CELL_PADDING_0); // @008 medOrgCell.setPaddingBottom(CELL_PADDING_0); // @008 medOrgTbl.addCell(medOrgCell); medOrgCell = new PdfPCell(new Paragraph(facilityName, min_8)); medOrgCell.setBorderWidth(LINE_WIDTH_0); medOrgCell.setColspan(2); medOrgCell.setPaddingTop(CELL_PADDING_0); // @008 medOrgCell.setPaddingBottom(CELL_PADDING_0); // @008 medOrgTbl.addCell(medOrgCell); medOrgCell = new PdfPCell(); medOrgCell.setBorder(Table.NO_BORDER); medOrgCell.setColspan(3); medOrgCell.setPaddingTop(CELL_PADDING_0); // @008 medOrgCell.setPaddingBottom(CELL_PADDING_0); // @008 medOrgTbl.addCell(medOrgCell); medOrgCell = new PdfPCell(new Paragraph("?", min_7)); medOrgCell.setBorderWidth(LINE_WIDTH_0); setAlignJustifiedAll(medOrgCell); setAlignMiddle(medOrgCell); medOrgCell.setPaddingTop(CELL_PADDING_0); // @008 medOrgTbl.addCell(medOrgCell); medOrgCell = new PdfPCell(new Paragraph(facilityTelNo, min_9)); medOrgCell.setBorderWidth(LINE_WIDTH_0); setAlignMiddle(medOrgCell); medOrgCell.setColspan(2); medOrgCell.setPaddingTop(CELL_PADDING_0); // @008 medOrgTbl.addCell(medOrgCell); medOrgCell = new PdfPCell(new Paragraph("????", min_7)); medOrgCell.setBorderWidth(LINE_WIDTH_0); setAlignJustifiedAll(medOrgCell); setAlignMiddle(medOrgCell); medOrgCell.setPaddingTop(CELL_PADDING_0); // @008 medOrgTbl.addCell(medOrgCell); medOrgCell = new PdfPCell(new Paragraph(drName, min_10)); medOrgCell.setBorderWidth(LINE_WIDTH_0); setAlignMiddle(medOrgCell); medOrgCell.setPaddingTop(CELL_PADDING_0); // @008 medOrgTbl.addCell(medOrgCell); medOrgCell = new PdfPCell(new Paragraph("?", min_8)); medOrgCell.setBorderWidth(LINE_WIDTH_0); setAlignMiddle(medOrgCell); medOrgCell.setPaddingTop(CELL_PADDING_0); // @008 medOrgTbl.addCell(medOrgCell); pcell = new PdfPCell(medOrgTbl); pcell.setBorder(Table.NO_BORDER); pcell.setColspan(10); pcell.setPaddingBottom(CELL_PADDING_1); ptblR.addCell(pcell); // ********** @008 2010/06/18 ********** // 20104? PdfPTable medCodeTbl = new PdfPTable(13); medCodeTbl.setWidthPercentage(100f); float[] widthsCode = { 17, 8, 8, 15, 8, 17, 8, 8, 8, 8, 8, 8, 8 }; medCodeTbl.setWidths(widthsCode); // ?? PdfPCell medCodeCell = new PdfPCell(new Paragraph("?\n?", min_6)); medCodeCell.setBorderWidth(LINE_WIDTH_1); setAlignCenterMiddle(medCodeCell); medCodeCell.setPaddingTop(CELL_PADDING_0); medCodeTbl.addCell(medCodeCell); medCodeCell = new PdfPCell(new Paragraph(String.valueOf(prefNo.charAt(0)), min_14)); medCodeCell.setBorderWidth(LINE_WIDTH_1); setAlignCenterMiddle(medCodeCell); medCodeCell.setPaddingTop(CELL_PADDING_0); medCodeTbl.addCell(medCodeCell); medCodeCell = new PdfPCell(new Paragraph(String.valueOf(prefNo.charAt(1)), min_14)); medCodeCell.setBorderWidth(LINE_WIDTH_1); setAlignCenterMiddle(medCodeCell); medCodeCell.setPaddingTop(CELL_PADDING_0); medCodeTbl.addCell(medCodeCell); medCodeCell = new PdfPCell(new Paragraph("\n?", min_6)); medCodeCell.setBorderWidth(LINE_WIDTH_1); setAlignCenterMiddle(medCodeCell); medCodeCell.setPaddingTop(CELL_PADDING_0); medCodeTbl.addCell(medCodeCell); medCodeCell = new PdfPCell(new Paragraph(String.valueOf(grade.charAt(0)), min_14)); medCodeCell.setBorderWidth(LINE_WIDTH_1); setAlignCenterMiddle(medCodeCell); medCodeCell.setPaddingTop(CELL_PADDING_0); medCodeTbl.addCell(medCodeCell); medCodeCell = new PdfPCell(new Paragraph("", min_6)); medCodeCell.setBorderWidth(LINE_WIDTH_1); setAlignCenterMiddle(medCodeCell); medCodeCell.setPaddingTop(CELL_PADDING_0); medCodeTbl.addCell(medCodeCell); medCodeCell = new PdfPCell(new Paragraph(String.valueOf(institution.charAt(0)), min_14)); medCodeCell.setBorderWidth(LINE_WIDTH_1); setAlignCenterMiddle(medCodeCell); medCodeCell.setPaddingTop(CELL_PADDING_0); medCodeTbl.addCell(medCodeCell); medCodeCell = new PdfPCell(new Paragraph(String.valueOf(institution.charAt(1)), min_14)); medCodeCell.setBorderWidth(LINE_WIDTH_1); setAlignCenterMiddle(medCodeCell); medCodeCell.setPaddingTop(CELL_PADDING_0); medCodeTbl.addCell(medCodeCell); medCodeCell = new PdfPCell(new Paragraph(String.valueOf(institution.charAt(2)), min_14)); medCodeCell.setBorderWidth(LINE_WIDTH_1); setAlignCenterMiddle(medCodeCell); medCodeCell.setPaddingTop(CELL_PADDING_0); medCodeTbl.addCell(medCodeCell); medCodeCell = new PdfPCell(new Paragraph(String.valueOf(institution.charAt(3)), min_14)); medCodeCell.setBorderWidth(LINE_WIDTH_1); setAlignCenterMiddle(medCodeCell); medCodeCell.setPaddingTop(CELL_PADDING_0); medCodeTbl.addCell(medCodeCell); medCodeCell = new PdfPCell(new Paragraph(String.valueOf(institution.charAt(4)), min_14)); medCodeCell.setBorderWidth(LINE_WIDTH_1); setAlignCenterMiddle(medCodeCell); medCodeCell.setPaddingTop(CELL_PADDING_0); medCodeTbl.addCell(medCodeCell); medCodeCell = new PdfPCell(new Paragraph(String.valueOf(institution.charAt(5)), min_14)); medCodeCell.setBorderWidth(LINE_WIDTH_1); setAlignCenterMiddle(medCodeCell); medCodeCell.setPaddingTop(CELL_PADDING_0); medCodeTbl.addCell(medCodeCell); medCodeCell = new PdfPCell(new Paragraph(String.valueOf(institution.charAt(6)), min_14)); medCodeCell.setBorderWidth(LINE_WIDTH_1); setAlignCenterMiddle(medCodeCell); medCodeCell.setPaddingTop(CELL_PADDING_0); medCodeTbl.addCell(medCodeCell); pcell = new PdfPCell(medCodeTbl); pcell.setBorder(Table.NO_BORDER); pcell.setColspan(10); pcell.setPaddingBottom(CELL_PADDING_1); ptblR.addCell(pcell); // ********** @008 2010/06/18 ********** ptbl.addCell(ptblR); // ?? PdfPTable termTbl = new PdfPTable(3); termTbl.setWidthPercentage(100f); float[] widthsT = { 14.8f, 26, 59.2f }; termTbl.setWidths(widthsT); termTbl.getDefaultCell().setPadding(0f); PdfPCell termCell = new PdfPCell(new Paragraph("??\n", min_7)); termCell.setBorderWidth(LINE_WIDTH_1); termCell.setPaddingTop(0.3f); setAlignJustifiedAll(termCell); termTbl.addCell(termCell); // ********* @009 2010/07/01 ********* String periodDate = "?"; if (pkg.getPeriod() != null) { periodDate = ModelUtils.convertToGengo( ModelUtils.getDateAsFormatString(pkg.getPeriod(), IInfoModel.DATE_WITHOUT_TIME)); } termCell = new PdfPCell(new Paragraph(periodDate, min_8)); // ********* @009 2010/07/01 ********* termCell.setBorderWidth(LINE_WIDTH_1); termCell.setBorderWidthRight(LINE_WIDTH_0); setAlignMiddle(termCell); termTbl.addCell(termCell); termCell = new PdfPCell(new Paragraph( "???????????????????", min_6)); termCell.setBorderWidth(LINE_WIDTH_1); termCell.setBorderWidthLeft(LINE_WIDTH_0); setAlignMiddle(termCell); termTbl.addCell(termCell); pcell = new PdfPCell(termTbl); pcell.setBorder(Table.NO_BORDER); pcell.setColspan(3); ptbl.addCell(pcell); document.add(ptbl); // ptbl = new PdfPTable(2); ptbl.setWidthPercentage(100f); ptbl.getDefaultCell().setPadding(0f); ptbl.getDefaultCell().setBorder(Table.NO_BORDER); float[] widthsPre = { 3.5f, 96.5f }; ptbl.setWidths(widthsPre); pcell = new PdfPCell( new Paragraph("", min_7)); pcell.setBorderWidth(LINE_WIDTH_1); setAlignCenterMiddle(pcell); ptbl.addCell(pcell); // @005 2010/02/26 // ?? // PdfPTable outLineTbl = new PdfPTable(1); PdfPCell outLineCell; // ? // @005 2010/02/26 // PdfPTable prescriptionTbl; // if (ite.hasNext()) { prescriptionTbl = ite.next(); } else { prescriptionTbl = new PdfPTable(1); } // @005 2010/02/26 // ?? outLineCell = new PdfPCell(prescriptionTbl); outLineCell.setFixedHeight(200f); outLineCell.setBorderWidth(LINE_WIDTH_0); outLineTbl.addCell(outLineCell); if (totalPageNo > 1) { pageNo++; outLineCell = new PdfPCell( new Paragraph((String.valueOf(pageNo) + "?" + String.valueOf(totalPageNo)), min_10)); setAlignRight(outLineCell); outLineCell.setFixedHeight(12f); // @010 outLineCell.setBorderWidth(LINE_WIDTH_1); // @010 outLineTbl.addCell(outLineCell); } // @005 2010/02/26 PdfPCell prescriptionCell = new PdfPCell(outLineTbl); prescriptionCell.setFixedHeight(215f); prescriptionCell.setBorderWidth(LINE_WIDTH_1); ptbl.addCell(prescriptionCell); // pcell = new PdfPCell(new Paragraph("", min_7)); pcell.setBorderWidth(LINE_WIDTH_1); setAlignCenterMiddle(pcell); ptbl.addCell(pcell); // PdfPTable noteTbl = new PdfPTable(5); // @010 noteTbl.setWidthPercentage(100f); float[] widthsN = { 11, 4, 34, 4, 47 }; // @010 noteTbl.setWidths(widthsN); noteTbl.getDefaultCell().setPadding(0f); noteTbl.getDefaultCell().setBorder(Table.NO_BORDER); String address = (pkg.getPatientAddress() == null) ? "" : pkg.getPatientAddress(); String patientName = pkg.getPatientName(); String addressName = "?" + address + "\n???" + patientName; String useDrugInfo = "??" + pkg.getDrugLicenseNumber() + "(" + pkg.getPhysicianName() + ")"; StringBuilder postInfo = new StringBuilder(); // if (pkg.isChkHomeMedical()) { postInfo.append(NOTES_HOME_MEDICAL + "\n"); } if (pkg.isChkPatientInfo()) { // ????? postInfo.append(addressName); } if (postInfo.length() > 0) { // postInfo.append("\n"); } if (pkg.isChkUseDrugInfo()) { // ?? postInfo.append(useDrugInfo); } // @010 20124 --> PdfPCell noteCell = new PdfPCell(new Paragraph("???", min_7)); noteCell.setBorderWidth(LINE_WIDTH_0); noteCell.setBorderWidthBottom(LINE_WIDTH_1); noteCell.setMinimumHeight(CELL_HIGHT_2); setAlignTop(noteCell); noteTbl.addCell(noteCell); noteCell = new PdfPCell(new Paragraph("", min_15));//min_15 noteCell.setBorderWidth(LINE_WIDTH_0); noteCell.setBorderWidthBottom(LINE_WIDTH_1); noteCell.setPadding(0f); setAlignRight(noteCell); noteTbl.addCell(noteCell); noteCell = new PdfPCell(new Paragraph( "??????????\n?????????????", min_6)); noteCell.setBorderWidth(LINE_WIDTH_0); noteCell.setBorderWidthBottom(LINE_WIDTH_1); noteTbl.addCell(noteCell); noteCell = new PdfPCell(new Paragraph("", min_15));//min_15 noteCell.setBorderWidth(LINE_WIDTH_0); noteCell.setBorderWidthBottom(LINE_WIDTH_1); noteCell.setBorderWidthRight(LINE_WIDTH_1); noteCell.setPadding(0f); setAlignLeft(noteCell); noteTbl.addCell(noteCell); //minagawa^ ???? 47 noteCell = new PdfPCell(); noteCell.setBorderWidth(LINE_WIDTH_0); noteTbl.addCell(noteCell); //minagawa noteCell = new PdfPCell(new Paragraph(postInfo.toString(), min_7)); // ???????? noteCell.setColspan(widthsN.length); noteCell.setMinimumHeight(40f); noteCell.setBorderWidth(LINE_WIDTH_0); noteTbl.addCell(noteCell); // <-- 20124 @010 pcell = new PdfPCell(noteTbl); pcell.setBorderWidth(LINE_WIDTH_1); ptbl.addCell(pcell); document.add(ptbl); // ?? ptbl = new PdfPTable(2); ptbl.setWidthPercentage(100f); float[] widthsOther = { 58, 42 }; ptbl.setWidths(widthsOther); ptbl.getDefaultCell().setPadding(0f); ptbl.getDefaultCell().setBorder(Table.NO_BORDER); // ptblL = new PdfPTable(3); ptblL.setWidthPercentage(100f); float[] widthsPh = { 28, 65, 7 }; ptblL.setWidths(widthsPh); ptblL.getDefaultCell().setPadding(0f); ptblL.getDefaultCell().setBorder(Table.NO_BORDER); PdfPCell pcellL = new PdfPCell(new Paragraph("", min_7)); pcellL.setMinimumHeight(CELL_HIGHT_0); pcellL.setBorderWidth(LINE_WIDTH_1); setAlignJustifiedAll(pcellL); setAlignMiddle(pcellL); ptblL.addCell(pcellL); pcellL = new PdfPCell(new Paragraph("?", min_8)); pcellL.setBorderWidth(LINE_WIDTH_1); setAlignMiddle(pcellL); pcellL.setColspan(2); ptblL.addCell(pcellL); pcellL = new PdfPCell(new Paragraph("??\n??\n??", min_7)); pcellL.setPaddingTop(0.2f); pcellL.setBorderWidth(LINE_WIDTH_1); pcellL.setBorderWidthBottom(LINE_WIDTH_0); setAlignJustifiedAll(pcellL); ptblL.addCell(pcellL); pcellL = new PdfPCell(); pcellL.setBorderWidth(LINE_WIDTH_0); pcellL.setBorderWidthRight(LINE_WIDTH_1); pcellL.setColspan(2); ptblL.addCell(pcellL); pcellL = new PdfPCell(new Paragraph("?\n???", min_7)); pcellL.setPaddingTop(0.2f); pcellL.setBorderWidth(LINE_WIDTH_1); pcellL.setBorderWidthTop(LINE_WIDTH_0); setAlignJustifiedAll(pcellL); ptblL.addCell(pcellL); pcellL = new PdfPCell(); pcellL.setBorderWidth(LINE_WIDTH_0); pcellL.setBorderWidthBottom(LINE_WIDTH_1); ptblL.addCell(pcellL); pcellL = new PdfPCell(new Paragraph("?", min_8)); pcellL.setBorderWidth(LINE_WIDTH_1); pcellL.setBorderWidthTop(LINE_WIDTH_0); pcellL.setBorderWidthLeft(LINE_WIDTH_0); setAlignJustifiedAll(pcellL); setAlignMiddle(pcellL); ptblL.addCell(pcellL); ptbl.addCell(ptblL); ptblR = new PdfPTable(9); ptblR.setWidthPercentage(100f); float[] widthsPu = { 33, 8, 8, 8, 8, 8, 8, 8, 8 }; ptblR.setWidths(widthsPu); ptblR.getDefaultCell().setPadding(0f); PdfPCell pcellR = new PdfPCell(new Paragraph("?", min_7)); pcellR.setMinimumHeight(CELL_HIGHT_0); setAlignJustifiedAll(pcellR); setAlignMiddle(pcellR); pcellR.setBorderWidth(LINE_WIDTH_1); ptblR.addCell(pcellR); pcellR = new PdfPCell(new Paragraph(String.valueOf(piNumC2[0]), min_14)); // @006 pcellR.setBorderWidth(LINE_WIDTH_1); pcellR.setPadding(0f); setAlignCenterMiddle(pcellR); ptblR.addCell(pcellR); pcellR = new PdfPCell(new Paragraph(String.valueOf(piNumC2[1]), min_14)); // @006 pcellR.setBorderWidth(LINE_WIDTH_1); pcellR.setBorderWidthRight(LINE_WIDTH_3); pcellR.setPadding(0f); setAlignCenterMiddle(pcellR); ptblR.addCell(pcellR); pcellR = new PdfPCell(new Paragraph(String.valueOf(piNumC2[2]), min_14)); // @006 pcellR.setBorderWidth(LINE_WIDTH_1); pcellR.setBorderWidthLeft(LINE_WIDTH_3); pcellR.setPadding(0f); setAlignCenterMiddle(pcellR); ptblR.addCell(pcellR); pcellR = new PdfPCell(new Paragraph(String.valueOf(piNumC2[3]), min_14)); // @006 pcellR.setBorderWidth(LINE_WIDTH_1); pcellR.setBorderWidthRight(LINE_WIDTH_3); pcellR.setPadding(0f); setAlignCenterMiddle(pcellR); ptblR.addCell(pcellR); pcellR = new PdfPCell(new Paragraph(String.valueOf(piNumC2[4]), min_14)); // @006 pcellR.setBorderWidth(LINE_WIDTH_2); pcellR.setBorderWidthRight(LINE_WIDTH_1); pcellR.setBorderWidthLeft(LINE_WIDTH_3); pcellR.setPadding(0f); setAlignCenterMiddle(pcellR); ptblR.addCell(pcellR); pcellR = new PdfPCell(new Paragraph(String.valueOf(piNumC2[5]), min_14)); // @006 pcellR.setBorderWidth(LINE_WIDTH_1); pcellR.setBorderWidthTop(LINE_WIDTH_2); pcellR.setBorderWidthBottom(LINE_WIDTH_2); pcellR.setPadding(0f); setAlignCenterMiddle(pcellR); ptblR.addCell(pcellR); pcellR = new PdfPCell(new Paragraph(String.valueOf(piNumC2[6]), min_14)); // @006 pcellR.setBorderWidth(LINE_WIDTH_2); pcellR.setBorderWidthRight(LINE_WIDTH_3); pcellR.setBorderWidthLeft(LINE_WIDTH_1); pcellR.setPadding(0f); setAlignCenterMiddle(pcellR); ptblR.addCell(pcellR); pcellR = new PdfPCell(new Paragraph(String.valueOf(piNumC2[7]), min_14)); // @006 pcellR.setBorderWidth(LINE_WIDTH_1); pcellR.setBorderWidthLeft(LINE_WIDTH_3); pcellR.setPadding(0f); setAlignCenterMiddle(pcellR); ptblR.addCell(pcellR); pcellR = new PdfPCell(new Paragraph("???", min_7)); pcellR.setPaddingTop(0.3f); setAlignJustifiedAll(pcellR); pcellR.setBorderWidth(LINE_WIDTH_1); ptblR.addCell(pcellR); pcellR = new PdfPCell(new Paragraph(String.valueOf(rNumC2[0]), min_14)); // @006 pcellR.setBorderWidth(LINE_WIDTH_1); pcellR.setPadding(0f); setAlignCenterMiddle(pcellR); ptblR.addCell(pcellR); pcellR = new PdfPCell(new Paragraph(String.valueOf(rNumC2[1]), min_14)); // @006 pcellR.setBorderWidth(LINE_WIDTH_1); pcellR.setPadding(0f); setAlignCenterMiddle(pcellR); ptblR.addCell(pcellR); pcellR = new PdfPCell(new Paragraph(String.valueOf(rNumC2[2]), min_14)); // @006 pcellR.setBorderWidth(LINE_WIDTH_1); pcellR.setBorderWidthRight(LINE_WIDTH_3); pcellR.setPadding(0f); setAlignCenterMiddle(pcellR); ptblR.addCell(pcellR); pcellR = new PdfPCell(new Paragraph(String.valueOf(rNumC2[3]), min_14)); // @006 pcellR.setBorderWidth(LINE_WIDTH_1); pcellR.setBorderWidthLeft(LINE_WIDTH_3); pcellR.setPadding(0f); setAlignCenterMiddle(pcellR); ptblR.addCell(pcellR); pcellR = new PdfPCell(new Paragraph(String.valueOf(rNumC2[4]), min_14)); // @006 pcellR.setBorderWidth(LINE_WIDTH_1); pcellR.setPadding(0f); setAlignCenterMiddle(pcellR); ptblR.addCell(pcellR); pcellR = new PdfPCell(new Paragraph(String.valueOf(rNumC2[5]), min_14)); // @006 pcellR.setBorderWidth(LINE_WIDTH_1); pcellR.setBorderWidthRight(LINE_WIDTH_3); pcellR.setPadding(0f); setAlignCenterMiddle(pcellR); ptblR.addCell(pcellR); pcellR = new PdfPCell(new Paragraph(String.valueOf(rNumC2[6]), min_14)); // @006 pcellR.setBorderWidth(LINE_WIDTH_1); pcellR.setBorderWidthLeft(LINE_WIDTH_3); pcellR.setPadding(0f); setAlignCenterMiddle(pcellR); ptblR.addCell(pcellR); pcellR = new PdfPCell(); pcellR.setBorderWidth(LINE_WIDTH_0); ptblR.addCell(pcellR); pcellR = new PdfPCell(); pcellR.setBorderWidth(LINE_WIDTH_0); pcellR.setColspan(9); ptblR.addCell(pcellR); ptbl.addCell(ptblR); document.add(ptbl); ptbl = new PdfPTable(2); ptbl.setWidthPercentage(100f); float[] widthsMed = { 3.5f, 96.5f }; ptbl.setWidths(widthsMed); ptbl.setSpacingBefore(3f); ptbl.getDefaultCell().setPadding(0f); ptbl.getDefaultCell().setBorder(Table.NO_BORDER); pcell = new PdfPCell(new Paragraph("????", min_7)); pcell.setBorderWidth(LINE_WIDTH_1); setAlignCenter(pcell); ptbl.addCell(pcell); ptblR = new PdfPTable(3); ptblR.setWidthPercentage(100f); float[] widthsPm = { 60, 20, 20 }; ptblR.setWidths(widthsPm); ptblR.getDefaultCell().setPadding(0f); ptblR.getDefaultCell().setBorder(Table.NO_BORDER); // ???????? PdfPTable pointTbl = new PdfPTable(7); pointTbl.setWidthPercentage(100f); float[] widthsPo = { 7, 15.5f, 15.5f, 15.5f, 15.5f, 15.5f, 15.5f }; pointTbl.setWidths(widthsPo); pointTbl.getDefaultCell().setPadding(0f); pointTbl.getDefaultCell().setBorder(Table.NO_BORDER); PdfPCell pointCell = new PdfPCell(new Paragraph("", min_7)); pointCell.setBorderWidth(LINE_WIDTH_1); setAlignCenterMiddle(pointCell); pointTbl.addCell(pointCell); pointCell = new PdfPCell(new Paragraph("", min_7)); pointCell.setBorderWidth(LINE_WIDTH_1); setAlignCenterMiddle(pointCell); pointTbl.addCell(pointCell); pointCell = new PdfPCell(new Paragraph("", min_7)); pointCell.setBorderWidth(LINE_WIDTH_1); setAlignCenterMiddle(pointCell); pointTbl.addCell(pointCell); pointCell = new PdfPCell(new Paragraph("?", min_7)); pointCell.setBorderWidth(LINE_WIDTH_1); setAlignCenterMiddle(pointCell); pointTbl.addCell(pointCell); pointCell = new PdfPCell(new Paragraph("", min_7)); pointCell.setBorderWidth(LINE_WIDTH_1); setAlignCenterMiddle(pointCell); pointTbl.addCell(pointCell); pointCell = new PdfPCell(new Paragraph("?", min_7)); pointCell.setBorderWidth(LINE_WIDTH_1); setAlignCenterMiddle(pointCell); pointTbl.addCell(pointCell); pointCell = new PdfPCell(new Paragraph("", min_7)); pointCell.setBorderWidth(LINE_WIDTH_1); setAlignCenterMiddle(pointCell); pointTbl.addCell(pointCell); // ? PdfPCell blankCell = new PdfPCell(); blankCell.setBorderWidth(LINE_WIDTH_1); pointTbl.addCell(blankCell); pointTbl.addCell(blankCell); pointTbl.addCell(blankCell); pointTbl.addCell(blankCell); pointTbl.addCell(blankCell); pointTbl.addCell(blankCell); pointTbl.addCell(blankCell); ptblR.addCell(pointTbl); // ? PdfPTable feeTbl = new PdfPTable(2); feeTbl.setWidthPercentage(100f); float[] widthsF = { 50, 50 }; feeTbl.setWidths(widthsF); feeTbl.getDefaultCell().setPadding(0f); feeTbl.getDefaultCell().setBorder(Table.NO_BORDER); PdfPCell feeCell = new PdfPCell(new Paragraph(" ", min_7)); feeCell.setBorderWidth(LINE_WIDTH_1); setAlignCenter(feeCell); feeTbl.addCell(feeCell); feeCell = new PdfPCell(new Paragraph(" ", min_7)); feeCell.setBorderWidth(LINE_WIDTH_1); setAlignCenter(feeCell); feeTbl.addCell(feeCell); feeCell = new PdfPCell(); feeCell.setBorderWidth(LINE_WIDTH_1); feeCell.setMinimumHeight(CELL_HIGHT_1); feeTbl.addCell(feeCell); feeTbl.addCell(feeCell); // ?etc.. PdfPTable feeTblSub = new PdfPTable(4); feeTblSub.setWidthPercentage(100f); float[] widthsSub = { 28, 16, 28, 28 }; feeTblSub.setWidths(widthsSub); feeTblSub.getDefaultCell().setPadding(0f); feeTblSub.getDefaultCell().setBorder(Table.NO_BORDER); PdfPCell feeCellSub = new PdfPCell(new Paragraph("?", min_7)); feeCellSub.setBorderWidth(LINE_WIDTH_1); setAlignCenter(feeCellSub); feeTblSub.addCell(feeCellSub); feeCellSub = new PdfPCell(new Paragraph("", min_7)); feeCellSub.setBorderWidth(LINE_WIDTH_1); setAlignCenter(feeCellSub); feeTblSub.addCell(feeCellSub); feeCellSub = new PdfPCell(new Paragraph(" ", min_7)); feeCellSub.setBorderWidth(LINE_WIDTH_1); setAlignCenter(feeCellSub); feeTblSub.addCell(feeCellSub); feeCellSub = new PdfPCell(new Paragraph("? ", min_7)); feeCellSub.setBorderWidth(LINE_WIDTH_1); setAlignCenter(feeCellSub); feeTblSub.addCell(feeCellSub); // ? feeCellSub = new PdfPCell(); feeCellSub.setBorderWidth(LINE_WIDTH_1); feeCellSub.setMinimumHeight(CELL_HIGHT_1); feeTblSub.addCell(feeCellSub); feeTblSub.addCell(feeCellSub); feeTblSub.addCell(feeCellSub); feeTblSub.addCell(feeCellSub); feeCell = new PdfPCell(feeTblSub); feeCell.setBorder(Table.NO_BORDER); feeCell.setColspan(2); feeTbl.addCell(feeCell); // etc..? pcellR = new PdfPCell(feeTbl); pcellR.setPadding(0f); pcellR.setColspan(2); pcellR.setBorder(Table.NO_BORDER); ptblR.addCell(pcellR); // noteTbl = new PdfPTable(2); noteTbl.setWidthPercentage(100f); float[] widthsNote = { 5.3f, 94.7f }; noteTbl.setWidths(widthsNote); noteTbl.getDefaultCell().setPadding(0f); noteTbl.getDefaultCell().setBorder(Table.NO_BORDER); noteCell = new PdfPCell(new Paragraph("", min_7)); noteCell.setBorderWidth(LINE_WIDTH_1); setAlignCenterMiddle(noteCell); noteTbl.addCell(noteCell); noteCell = new PdfPCell(); noteCell.setBorderWidth(LINE_WIDTH_1); noteTbl.addCell(noteCell); pcell = new PdfPCell(noteTbl); pcell.setBorderWidth(LINE_WIDTH_0); pcell.setPadding(0f); pcell.setColspan(2); ptblR.addCell(pcell); // ? PdfPTable sumTbl = new PdfPTable(1); sumTbl.setWidthPercentage(100f); sumTbl.getDefaultCell().setPadding(0f); sumTbl.getDefaultCell().setBorder(Table.NO_BORDER); PdfPCell sumCell = new PdfPCell(new Paragraph("?", min_7)); sumCell.setBorderWidth(LINE_WIDTH_1); setAlignCenter(sumCell); sumTbl.addCell(sumCell); sumCell = new PdfPCell(); sumCell.setBorderWidth(LINE_WIDTH_1); sumCell.setMinimumHeight(CELL_HIGHT_1); sumTbl.addCell(sumCell); ptblR.addCell(sumTbl); pcell = new PdfPCell(ptblR); pcell.setBorderWidth(LINE_WIDTH_0); pcell.setPadding(0f); ptbl.addCell(pcell); document.add(ptbl); // if (ite.hasNext()) { document.newPage(); } } while (ite.hasNext()); document.close(); bos.close(); // pdf content bytes byte[] pdfbytes = byteo.toByteArray(); // ????? File???? //if (!ClientContext.is5mTest()) { FileOutputStream fout = new FileOutputStream(pathToPDF); FileChannel channel = fout.getChannel(); ByteBuffer bytebuff = ByteBuffer.wrap(pdfbytes); while (bytebuff.hasRemaining()) { channel.write(bytebuff); } channel.close(); //return pathToPDF; //} // // ??? water Mark ?? // PdfReader pdfReader = new PdfReader(pdfbytes); // PdfStamper pdfStamper = new PdfStamper(pdfReader,new FileOutputStream(pathToPDF)); // // Image image = Image.getInstance(ClientContext.getImageResource("water-mark.png")); // // for(int i=1; i<= pdfReader.getNumberOfPages(); i++){ // // PdfContentByte content = pdfStamper.getUnderContent(i); // // image.scaleAbsolute(PageSize.A5.getWidth(), PageSize.A5.getHeight()); // image.setAbsolutePosition(0.0f, 0.0f); // content.addImage(image); // } // // pdfStamper.close(); return getFileName(); //http://ip:8080/filename.pdf } catch (DocumentException e) { e.printStackTrace(System.err); throw new RuntimeException(e.getMessage()); } catch (IOException e) { e.printStackTrace(System.err); throw new RuntimeException(e.getMessage()); } catch (Exception e) { e.printStackTrace(System.err); throw new RuntimeException(e.getMessage()); } finally { if (document != null && document.isOpen()) { document.close(); } } }
From source file:org.areasy.common.doclet.document.Implementors.java
License:Open Source License
/** * Prints all known subclasses or implementing classes. * * @param title The label for the name list * @param names The names (classes or interfaces) * @throws Exception// w w w. j ava 2s . com */ public static void print(String title, String[] names) throws Exception { float[] widths = { (float) 6.0, (float) 94.0 }; PdfPTable table = new PdfPTable(widths); table.setWidthPercentage((float) 100); PdfPCell spacingCell = new CellNoBorderNoPadding(new Phrase("")); spacingCell.setFixedHeight((float) 12.0); spacingCell.setColspan(2); table.addCell(spacingCell); PdfPCell titleCell = new CellNoBorderNoPadding( new Paragraph((float) 20.0, title, Fonts.getFont(TEXT_FONT, BOLD, 10))); titleCell.setColspan(2); table.addCell(titleCell); PdfPCell leftCell = PDFUtility.createElementCell(5, new Phrase("")); Paragraph descPg = new Paragraph((float) 24.0); for (int i = names.length - 1; i > -1; i--) { String subclassName = DocletUtility.getQualifiedNameIfNecessary(names[i]); Phrase subclassPhrase = new LinkPhrase(names[i], subclassName, 10, true); descPg.add(subclassPhrase); if (i > 0) descPg.add(new Chunk(", ", Fonts.getFont(TEXT_FONT, BOLD, 12))); } table.addCell(leftCell); table.addCell(new CellNoBorderNoPadding(descPg)); table.addCell(spacingCell); Document.instance().add(table); }
From source file:org.areasy.common.doclet.document.Inherited.java
License:Open Source License
/** * Prints inherited methods and fields from superclasses * * @param supercls class source to get inherited fields and methods for. * @param show SHOW_METHODS or SHOW_FIELDS * @throws Exception//from w ww .j ava 2 s. c o m */ public static void print(ClassDoc supercls, int show) throws Exception { String type; FieldDoc[] fields = supercls.fields(); Arrays.sort(fields); if (supercls.isInterface()) type = "interface"; else type = "class"; // Create cell for additional spacing below PdfPCell spacingCell = new PdfPCell(); spacingCell.addElement(new Chunk(" ")); spacingCell.setFixedHeight((float) 4.0); spacingCell.setBorder(Rectangle.BOTTOM + Rectangle.LEFT + Rectangle.RIGHT); spacingCell.setBorderColor(Color.gray); if ((fields.length > 0) && (show == SHOW_FIELDS)) { Document.instance().add(new Paragraph((float) 6.0, " ")); PdfPTable table = new PdfPTable(1); table.setWidthPercentage((float) 100); Paragraph newLine = new Paragraph(); newLine.add(new Chunk("Fields inherited from " + type + " ", Fonts.getFont(TEXT_FONT, BOLD, 10))); newLine.add(new LinkPhrase(supercls.qualifiedTypeName(), null, 10, false)); table.addCell(new CustomPdfPCell(newLine, COLOR_INHERITED_SUMMARY)); Paragraph paraList = new Paragraph(); for (int i = 0; i < fields.length; i++) { paraList.add(new LinkPhrase(fields[i].qualifiedName(), fields[i].name(), 10, false)); if (i != (fields.length - 1)) paraList.add(new Chunk(", ", Fonts.getFont(TEXT_FONT, BOLD, 12))); } PdfPCell contentCell = new CellBorderPadding(paraList); float leading = (float) contentCell.getLeading() + (float) 1.1; contentCell.setLeading(leading, leading); table.addCell(contentCell); table.addCell(spacingCell); Document.instance().add(table); } MethodDoc[] meth = supercls.methods(); Arrays.sort(meth); if ((meth.length > 0) && (show == SHOW_METHODS)) { Document.instance().add(new Paragraph((float) 6.0, " ")); PdfPTable table = new CustomPdfPTable(); Paragraph newLine = new Paragraph(); newLine.add(new Chunk("Methods inherited from " + type + " ", Fonts.getFont(TEXT_FONT, BOLD, 10))); newLine.add(new LinkPhrase(supercls.qualifiedTypeName(), null, 10, false)); table.addCell(new CustomPdfPCell(newLine, COLOR_INHERITED_SUMMARY)); Paragraph paraList = new Paragraph(); for (int i = 0; i < meth.length; i++) { String methodLabel = meth[i].name(); // Do not list static initializers like "<clinit>" if (!methodLabel.startsWith("<")) { paraList.add(new LinkPhrase(supercls.qualifiedTypeName() + "." + meth[i].name(), meth[i].name(), 10, false)); if (i != (meth.length - 1)) paraList.add(new Chunk(", ", Fonts.getFont(CODE_FONT, 10))); } } PdfPCell contentCell = new CellBorderPadding(paraList); float leading = (float) contentCell.getLeading() + (float) 1.1; contentCell.setLeading(leading, leading); table.addCell(contentCell); table.addCell(spacingCell); Document.instance().add(table); } // Print inherited interfaces / class methods and fields recursively ClassDoc supersupercls = null; if (supercls.isClass()) supersupercls = supercls.superclass(); if (supersupercls != null) { String className = supersupercls.qualifiedName(); if (ifClassMustBePrinted(className)) Inherited.print(supersupercls, show); } ClassDoc[] interfaces = supercls.interfaces(); for (int i = 0; i < interfaces.length; i++) { supersupercls = interfaces[i]; String className = supersupercls.qualifiedName(); if (ifClassMustBePrinted(className)) Inherited.print(supersupercls, show); } }
From source file:org.areasy.common.doclet.document.Members.java
License:Open Source License
/** * Prints member information.//from w ww. jav a2s.c o m * * @param declaration The modifiers ("public static final.."). * @param returnType Phrase with the return type text (might be * a hyperlink) * @param parms Parameters of a method or constructor, null for a field. * @param thrownExceptions Exceptions of a method, null for a field or constructor. * @param isFirst True if it is the first field/method/constructor in the list. * @param isField True if it is a field. * @param isConstructor True if it is a constructor. * @throws Exception */ public static void printMember(String declaration, Phrase returnType, ProgramElementDoc commentDoc, Parameter[] parms, ClassDoc[] thrownExceptions, boolean isFirst, boolean isField, boolean isConstructor, boolean isDeprecated, Phrase deprecatedPhrase, Object constantValue) throws Exception { String name = commentDoc.name(); State.setCurrentMember(State.getCurrentClass() + "." + name); State.setCurrentDoc(commentDoc); // Returns the text, resolving any "inheritDoc" inline tags String commentText = DocletUtility.getComment(commentDoc); // TODO: The following line may set the wrong page number // in the index, when the member gets printed on a // new page completely (because it is in one table). // Solution unknown yet. Probably split up table. Doclet.getIndex().addToMemberList(State.getCurrentMember()); // Prepare list of exceptions (if it throws any) String throwsText = "throws"; int parmsColumn = declaration.length() + (name.length() - throwsText.length()); // First output text line (declaration of method and first parameter or "()" ). // This first line is a special case because the class name is bold, // while the rest is regular plain text, so it must be built using three Chunks. Paragraph declarationParagraph = new Paragraph((float) 10.0); // left part / declaration ("public static..") Chunk leftPart = new Chunk(declaration, Fonts.getFont(CODE_FONT, 10)); declarationParagraph.add(leftPart); if (returnType != null) { // left middle part / declaration ("public static..") declarationParagraph.add(returnType); declarationParagraph.add(new Chunk(" ", Fonts.getFont(CODE_FONT, 10))); parmsColumn = 2; } // right middle part / bold class name declarationParagraph.add(new Chunk(name, Fonts.getFont(CODE_FONT, BOLD, 10))); if (!isField) { // 1st parameter or empty brackets if ((parms != null) && (parms.length > 0)) { Phrase wholePhrase = new Phrase("(", Fonts.getFont(CODE_FONT, 10)); // create link for parameter type wholePhrase.add(PDFUtility.getParameterTypePhrase(parms[0], 10)); // then normal text for parameter name wholePhrase.add(" " + parms[0].name()); if (parms.length > 1) { wholePhrase.add(","); } else { wholePhrase.add(")"); } // In order to have the parameter types in the bookmark, // make the current state text more detailled String txt = State.getCurrentMethod() + "("; for (int i = 0; i < parms.length; i++) { if (i > 0) txt = txt + ","; txt = txt + DocletUtility.getParameterType(parms[i]); } txt = txt + ")"; State.setCurrentMethod(txt); // right part / parameter and brackets declarationParagraph.add(wholePhrase); } else { String lastPart = "()"; State.setCurrentMethod(State.getCurrentMethod() + lastPart); // right part / parameter and brackets declarationParagraph.add(new Chunk(lastPart, Fonts.getFont(CODE_FONT, 10))); } } float[] widths = { (float) 6.0, (float) 94.0 }; PdfPTable table = new PdfPTable(widths); table.setWidthPercentage((float) 100); // Before the first constructor or method, create a coloured title bar if (isFirst) { PdfPCell colorTitleCell = null; // Some empty space... Document.add(new Paragraph((float) 6.0, " ")); if (isConstructor) colorTitleCell = new CustomPdfPCell("Constructors"); else if (isField) colorTitleCell = new CustomPdfPCell("Fields"); else colorTitleCell = new CustomPdfPCell("Methods"); colorTitleCell.setColspan(2); table.addCell(colorTitleCell); } // Method name (large, first line of a method description block) Phrase linkPhrase = Destinations.createDestination(commentDoc.name(), commentDoc, Fonts.getFont(TEXT_FONT, BOLD, 14)); Paragraph nameTitle = new Paragraph(linkPhrase); PdfPCell nameCell = new CellNoBorderNoPadding(nameTitle); if (isFirst) nameCell.setPaddingTop(10); else nameCell.setPaddingTop(0); nameCell.setPaddingBottom(8); nameCell.setColspan(1); // Create nested table in order to try to prevent the stuff inside // this table from being ripped appart over a page break. The method // name and the declaration/parm/exception line(s) should always be // together, because everything else just looks bad PdfPTable linesTable = new PdfPTable(1); linesTable.addCell(nameCell); linesTable.addCell(new CellNoBorderNoPadding(declarationParagraph)); if (!isField) { // Set up following declaration lines Paragraph[] params = PDFUtility.createParameters(parmsColumn, parms); Paragraph[] exceps = PDFUtility.createExceptions(parmsColumn, thrownExceptions); for (int i = 0; i < params.length; i++) { linesTable.addCell(new CellNoBorderNoPadding(params[i])); } for (int i = 0; i < exceps.length; i++) { linesTable.addCell(new CellNoBorderNoPadding(exceps[i])); } } // Create cell for inserting the nested table into the outer table PdfPCell cell = new PdfPCell(linesTable); cell.setPadding(5); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(2); table.addCell(cell); // The empty, left cell (the invisible indentation column) State.setContinued(true); PdfPCell leftCell = PDFUtility.createElementCell(5, new Phrase("", Fonts.getFont(TEXT_FONT, BOLD, 6))); PdfPCell spacingCell = new PdfPCell(); spacingCell.setFixedHeight((float) 8.0); spacingCell.setBorder(Rectangle.NO_BORDER); table.addCell(spacingCell); table.addCell(spacingCell); // The descriptive method explanation text if (isDeprecated) { Phrase commentPhrase = new Phrase(); commentPhrase .add(new Phrase(AbstractConfiguration.LB_DEPRECATED_TAG, Fonts.getFont(TEXT_FONT, BOLD, 10))); commentPhrase.add(deprecatedPhrase); table.addCell(leftCell); table.addCell(PDFUtility.createElementCell(0, commentPhrase)); commentPhrase = new Phrase(); commentPhrase.add(Chunk.NEWLINE); table.addCell(leftCell); table.addCell(PDFUtility.createElementCell(0, commentPhrase)); } Element[] objs = HtmlParserWrapper.createPdfObjects(commentText); if (objs.length == 1) { table.addCell(leftCell); table.addCell(PDFUtility.createElementCell(0, objs[0])); } else { table.addCell(leftCell); table.addCell(PDFUtility.createElementCell(0, Element.ALIGN_LEFT, objs)); } // TODO: FORMAT THIS CONSTANT VALUE OUTPUT CORRECTLY if (isField) { if (constantValue != null) { // Add 2nd comment line (left cell empty, right cell text) Chunk valueTextChunk = new Chunk("Constant value: ", Fonts.getFont(TEXT_FONT, PLAIN, 10)); Chunk valueContentChunk = new Chunk(constantValue.toString(), Fonts.getFont(CODE_FONT, BOLD, 10)); Phrase constantValuePhrase = new Phrase(""); constantValuePhrase.add(valueTextChunk); constantValuePhrase.add(valueContentChunk); table.addCell(leftCell); table.addCell(PDFUtility.createElementCell(0, constantValuePhrase)); } } // Add whole method block to document Document.add(table); }
From source file:org.kuali.kfs.module.purap.pdf.PurchaseOrderQuoteRequestsPdf.java
License:Open Source License
/** * Creates the pdf using given input parameters. * /*from w w w . j a v a 2 s . co m*/ * @param po The PurchaseOrderDocument to be used to create the pdf. * @param document The pdf document whose margins have already been set. * @param writer The PdfWriter to write the pdf document into. * @param instName The purchasing institution name * @throws DocumentException */ private void createPOQuoteRequestsListPdf(PurchaseOrderDocument po, Document document, PdfWriter writer, String instName) throws DocumentException { if (LOG.isDebugEnabled()) { LOG.debug("createPOQuoteRequestsListPdf() started for po number " + po.getPurapDocumentIdentifier()); } // These have to be set because they are used by the onOpenDocument() method. this.po = po; // Turn on the page events that handle the header and page numbers. PurchaseOrderPdf events = new PurchaseOrderPdf().getPageEvents(); writer.setPageEvent(this); // Passing in "this" lets it know about the po, campusName, etc. document.open(); PdfPCell cell; Paragraph p = new Paragraph(); float[] headerWidths = { 0.25f, 0.25f, 0.25f, 0.25f }; headerTable = new PdfPTable(headerWidths); headerTable.setWidthPercentage(100); headerTable.setHorizontalAlignment(Element.ALIGN_CENTER); headerTable.getDefaultCell().setBorderWidth(0); headerTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); headerTable.getDefaultCell().setVerticalAlignment(Element.ALIGN_CENTER); // New row cell = new PdfPCell(new Paragraph(instName + "\nRequest for Quotation Vendor List\n\n", titleFont)); cell.setBorderWidth(0); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); headerTable.addCell(cell); // New row cell = new PdfPCell(new Paragraph("PO Number: " + po.getPurapDocumentIdentifier(), cellTextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBorderWidth(0); headerTable.addCell(cell); cell = new PdfPCell(new Paragraph("Req. Number: " + po.getRequisitionIdentifier(), cellTextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBorderWidth(0); headerTable.addCell(cell); // Date format pattern: MM-dd-yyyy SimpleDateFormat sdf = PurApDateFormatUtils .getSimpleDateFormat(PurapConstants.NamedDateFormats.KUALI_SIMPLE_DATE_FORMAT_2); Date today = SpringContext.getBean(DateTimeService.class).getCurrentSqlDate(); cell = new PdfPCell(new Paragraph("Printed: " + sdf.format(today), cellTextFont)); cell.setBorderWidth(0); cell.setHorizontalAlignment(Element.ALIGN_CENTER); headerTable.addCell(cell); if (po.getPurchaseOrderQuoteDueDate() != null) { Date dueDate = po.getPurchaseOrderQuoteDueDate(); cell = new PdfPCell(new Paragraph("Due: " + sdf.format(dueDate) + "\n\n", cellTextFont)); } else { cell = new PdfPCell(new Paragraph("Due: N/A\n\n", cellTextFont)); } cell.setBorderWidth(0); cell.setHorizontalAlignment(Element.ALIGN_CENTER); headerTable.addCell(cell); document.add(headerTable); // ***** List table ***** LOG.debug("createPOQuoteRequestsListPdf() list table started."); float[] listWidths = { 0.20f, 0.20f, 0.20f, 0.20f, 0.20f }; PdfPTable listTable = new PdfPTable(listWidths); listTable.setWidthPercentage(100); listTable.setHorizontalAlignment(Element.ALIGN_CENTER); cell = new PdfPCell(new Paragraph("Vendor Name", cellTextFont)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setBorderWidth(0); listTable.addCell(cell); cell = new PdfPCell(new Paragraph("City", cellTextFont)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setBorderWidth(0); listTable.addCell(cell); cell = new PdfPCell(new Paragraph("Attention", cellTextFont)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setBorderWidth(0); listTable.addCell(cell); cell = new PdfPCell(new Paragraph("Fax #", cellTextFont)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setBorderWidth(0); listTable.addCell(cell); cell = new PdfPCell(new Paragraph("Received", cellTextFont)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setBorderWidth(0); listTable.addCell(cell); // The line under the headings. cell = new PdfPCell(new Paragraph(" ", cellTitleFont)); cell.setFixedHeight(1); cell.setColspan(5); listTable.addCell(cell); for (PurchaseOrderVendorQuote poqv : po.getPurchaseOrderVendorQuotes()) { cell = new PdfPCell(new Paragraph(poqv.getVendorName(), cellTextFont)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setBorderWidth(0); listTable.addCell(cell); if (poqv.getVendorStateCode() != null) { cell = new PdfPCell( new Paragraph(poqv.getVendorCityName() + ", " + poqv.getVendorStateCode(), cellTextFont)); } else if (poqv.getVendorCountryCode() != null) { cell = new PdfPCell( new Paragraph(poqv.getVendorCityName() + ", " + poqv.getVendorCountryCode(), cellTextFont)); } else { cell = new PdfPCell(new Paragraph(poqv.getVendorCityName(), cellTextFont)); } cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setBorderWidth(0); listTable.addCell(cell); cell = new PdfPCell(new Paragraph(poqv.getVendorAttentionName(), cellTextFont)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setBorderWidth(0); listTable.addCell(cell); cell = new PdfPCell(new Paragraph(poqv.getVendorFaxNumber(), cellTextFont)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setBorderWidth(0); listTable.addCell(cell); cell = new PdfPCell(new Paragraph("__________", cellTextFont)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setBorderWidth(0); listTable.addCell(cell); } document.add(listTable); document.close(); LOG.debug("createPOQuoteRequestsListPdf()pdf document closed."); }