List of usage examples for com.lowagie.text.pdf PdfPCell setPaddingLeft
public void setPaddingLeft(float paddingLeft)
From source file:jm.web.Addons.java
License:GNU General Public License
public static PdfPCell setLogoCarnet(String logo, int ancho, int alto) { PdfPCell celdaImg = null; try {//www. j ava 2 s .com Image imagelogo = Image.getInstance(logo); imagelogo.scaleAbsolute(ancho, alto); celdaImg = new PdfPCell(imagelogo); celdaImg.setBorderWidth(0); celdaImg.setPadding(0); celdaImg.setPaddingLeft(50); } catch (Exception e) { celdaImg = null; } return celdaImg; }
From source file:net.bull.javamelody.internal.web.pdf.PdfAbstractTableReport.java
License:Apache License
void initTable(List<String> headers, int[] relativeWidths) throws DocumentException { assert headers.size() == relativeWidths.length; final PdfPTable mytable = new PdfPTable(headers.size()); mytable.setWidthPercentage(100);/* ww w . j a v a 2 s. c o m*/ mytable.setWidths(relativeWidths); mytable.setHeaderRows(1); final PdfPCell defaultCell = mytable.getDefaultCell(); defaultCell.setGrayFill(0.9f); defaultCell.setHorizontalAlignment(Element.ALIGN_CENTER); defaultCell.setPaddingLeft(0); defaultCell.setPaddingRight(0); final Font tableHeaderFont = PdfFonts.TABLE_HEADER.getFont(); for (final String header : headers) { mytable.addCell(new Phrase(header, tableHeaderFont)); } defaultCell.setPaddingLeft(2); defaultCell.setPaddingRight(2); this.table = mytable; }
From source file:net.bull.javamelody.internal.web.pdf.PdfMBeansReport.java
License:Apache License
private static PdfPTable createAttributesTable() { final PdfPTable table = new PdfPTable(3); table.setWidthPercentage(100);/*from www .jav a 2s . c o m*/ final PdfPCell defaultCell = table.getDefaultCell(); defaultCell.setPaddingLeft(2); defaultCell.setPaddingRight(2); defaultCell.setVerticalAlignment(Element.ALIGN_TOP); defaultCell.setBorder(0); return table; }
From source file:net.bull.javamelody.internal.web.pdf.PdfRuntimeDependenciesReport.java
License:Apache License
private void writeHeader() throws DocumentException { final List<String> headers = new ArrayList<String>(); headers.add("Beans"); headers.addAll(calledBeans);/* w w w . j a va2s .c om*/ final int[] relativeWidths = new int[headers.size()]; Arrays.fill(relativeWidths, 0, headers.size(), 1); relativeWidths[0] = 4; final PdfPTable table = new PdfPTable(headers.size()); table.setWidthPercentage(100); table.setWidths(relativeWidths); table.setHeaderRows(1); final PdfPCell defaultCell = table.getDefaultCell(); defaultCell.setGrayFill(0.9f); defaultCell.setHorizontalAlignment(Element.ALIGN_CENTER); defaultCell.setVerticalAlignment(Element.ALIGN_MIDDLE); defaultCell.setPaddingLeft(0); defaultCell.setPaddingRight(0); for (final String header : headers) { table.addCell(new Phrase(header, boldCellFont)); // pas la premire entte de colonne defaultCell.setRotation(90); } defaultCell.setRotation(0); defaultCell.setPaddingLeft(2); defaultCell.setPaddingRight(2); currentTable = table; }
From source file:nl.dykema.jxmlnote.spikes.Spacing.java
License:Open Source License
/** * Main method.//from w ww . jav a 2s . c o m * @param args no arguments needed * @throws DocumentException * @throws IOException */ public static void main(String[] args) throws DocumentException, IOException { // step 1 Document document = new Document(); // step 2 PdfWriter.getInstance(document, new FileOutputStream(RESULT)); // step 3 document.open(); // step 4 PdfPTable table = new PdfPTable(2); table.setWidthPercentage(100); Phrase p = new Phrase( "Dr. iText or: How I Learned to Stop Worrying " + "and Love the Portable Document Format."); PdfPCell cell = new PdfPCell(p); table.addCell("default leading / spacing"); table.addCell(cell); table.addCell("absolute leading: 20"); cell.setLeading(20f, 0f); table.addCell(cell); table.addCell("absolute leading: 3; relative leading: 1.2"); cell.setLeading(3f, 1.2f); table.addCell(cell); table.addCell("absolute leading: 0; relative leading: 1.2"); cell.setLeading(0f, 1.2f); table.addCell(cell); table.addCell("no leading at all"); cell.setLeading(0f, 0f); table.addCell(cell); cell = new PdfPCell(new Phrase("Dr. iText or: How I Learned to Stop Worrying and Love PDF")); table.addCell("padding 10"); cell.setPadding(10); table.addCell(cell); table.addCell("padding 0"); cell.setPadding(0); table.addCell(cell); table.addCell("different padding for left, right, top and bottom"); cell.setPaddingLeft(20); cell.setPaddingRight(50); cell.setPaddingTop(0); cell.setPaddingBottom(5); table.addCell(cell); p = new Phrase("iText in Action Second Edition"); table.getDefaultCell().setPadding(2); table.getDefaultCell().setUseAscender(false); table.getDefaultCell().setUseDescender(false); table.addCell("padding 2; no ascender, no descender"); table.addCell(p); table.getDefaultCell().setUseAscender(true); table.getDefaultCell().setUseDescender(false); table.addCell("padding 2; ascender, no descender"); table.addCell(p); table.getDefaultCell().setUseAscender(false); table.getDefaultCell().setUseDescender(true); table.addCell("padding 2; descender, no ascender"); table.addCell(p); table.getDefaultCell().setUseAscender(true); table.getDefaultCell().setUseDescender(true); table.addCell("padding 2; ascender and descender"); cell.setPadding(2); cell.setUseAscender(true); cell.setUseDescender(true); table.addCell(p); document.add(table); // step 5 document.close(); }
From source file:open.dolphin.hiro.PrescriptionPDFMaker.java
private List<PdfPTable> createPrescriptionTbl2() { ClaimItem[] items;/*from w w w . java2s . c o m*/ PdfPCell pcell, blank, numCell, amountCell; int num, cnt; double sum; // @009 ?????(?*) List<PdfPTable> preTblList = null; String admin, number; // @009 String classCode, amount, medicine; // @009 try { StringBuilder sb = new StringBuilder(); sb.append( "???????(??)??????????????\n"); sb.append( "?????????????????????????"); PdfPTable ptbl = new PdfPTable(9); // @009 ptbl.setWidthPercentage(100f); // @009 ???, ?, ??, ?, ??, , "(", , ")" float[] widthsP = { 14, 7, 52, 8, 15, 32, 2, 5, 9 }; ptbl.setWidths(widthsP); ptbl.getDefaultCell().setPadding(0f); preTblList = new ArrayList<PdfPTable>(); num = 1; //admin = ""; // @009 //number = ""; // @009 //amount = ""; // @009 ? numCell = new PdfPCell(new Paragraph("", min_8)); // @009 numCell.setBorderWidth(LINE_WIDTH_0); // @009 PdfPCell notes = new PdfPCell(new Paragraph("??", min_8)); notes.setBorderWidth(LINE_WIDTH_1); notes.setBorderWidthBottom(LINE_WIDTH_0); PdfPCell bracket = new PdfPCell(new Paragraph("", min_15)); bracket.setBorderWidth(LINE_WIDTH_0); bracket.setHorizontalAlignment(Element.ALIGN_RIGHT); bracket.setPadding(0f); PdfPCell notesDetail = new PdfPCell(new Paragraph(sb.toString(), min_6)); notesDetail.setBorderWidth(LINE_WIDTH_0); notesDetail.setColspan(5); PdfPCell bracketC = new PdfPCell(new Paragraph("", min_15)); bracketC.setBorderWidth(LINE_WIDTH_0); bracketC.setHorizontalAlignment(Element.ALIGN_LEFT); bracketC.setPadding(0f); bracketC.setColspan(2); for (Iterator<BundleMed> ite = pkg.getPriscriptionList().iterator(); ite.hasNext();) { BundleMed prescription = ite.next(); admin = prescription.getAdmin(); // @009 number = prescription.getBundleNumber(); // @009 ????=1 bundeNumber classCode = prescription.getClassCode(); // @009 221 etc items = prescription.getClaimItem(); //minagawa^ boolean genericIsOk = true; if (items != null) { for (ClaimItem i : items) { if (i.getCode().equals("099209903")) { genericIsOk = false; break; } } } genericIsOk = true; //minagawa4 if (ptbl.getRows().isEmpty()) { ptbl.addCell(notes); ptbl.addCell(bracket); ptbl.addCell(notesDetail); ptbl.addCell(bracketC); } // @001 2009/11/17 ? // items?null??????????????? // ???????????items ? null ?????? // if???????????(??????????) if (items != null) { boolean clearFlg = true; // @004 2010/02/26 ? // ********** @009 ********** //sum = 0; // ????? Font adminF = min_8; // boolean wrap = true; if (admin != null) { if (admin.length() > 17) { // ??17???4?? adminF = min_4; wrap = false; } else if (admin.length() > 11) { // ??11???6?? adminF = min_6; } } Font medicineF; // ?? // ********** @009 ********** // ??? ClaimItem iterate for (cnt = 0; cnt < items.length; cnt++) { //System.out.println("row size:" + ptbl.getRows().size()); // ?? if (!genericIsOk) { blank = new PdfPCell(new Paragraph("", min_8)); blank.setBorderWidth(LINE_WIDTH_0); blank.setBorderWidthRight(LINE_WIDTH_1); ptbl.addCell(blank); genericIsOk = true; } else { blank = new PdfPCell(); blank.setBorderWidth(LINE_WIDTH_0); blank.setBorderWidthRight(LINE_WIDTH_1); ptbl.addCell(blank); } if (ptbl.getRows().size() > 13) { // ?13??????????? blank = new PdfPCell(); blank.setBorderWidth(LINE_WIDTH_0); blank.setColspan(4); ptbl.addCell(blank); pcell = new PdfPCell(new Paragraph("???", min_8)); pcell.setBorderWidth(LINE_WIDTH_0); pcell.setColspan(5); ptbl.addCell(pcell); preTblList.add(ptbl); ptbl = new PdfPTable(9); ptbl.setWidthPercentage(100f); ptbl.setWidths(widthsP); ptbl.getDefaultCell().setPadding(0f); // ?? ptbl.addCell(notes); ptbl.addCell(bracket); ptbl.addCell(notesDetail); ptbl.addCell(bracketC); blank = new PdfPCell(); blank.setBorderWidth(LINE_WIDTH_0); blank.setBorderWidthRight(LINE_WIDTH_1); ptbl.addCell(blank); } if (cnt > 0) { // ?1????????? blank = new PdfPCell(); blank.setBorderWidth(LINE_WIDTH_0); ptbl.addCell(blank); } else { // ?1?????? numCell = new PdfPCell(new Paragraph(num++ + ")", min_8)); numCell.setBorderWidth(LINE_WIDTH_0); setAlignRight(numCell); ptbl.addCell(numCell); // @004 2010/02/26 // ?1?????? false ?? if (!ClaimConst.COMMENT_CODE_0.equals(items[cnt].getCode())) { clearFlg = false; } // @004 2010/02/26 } // ********** @009 ********** amount = items[cnt].getNumber(); // System.out.println("??" + items[cnt].getName()); // System.out.println("?" + amount); //medicine = ""; medicine = items[cnt].getName(); // System.out.println("????" + medicine.length()); if (medicine.length() > 19) { // ????19???7?? medicineF = min_7; } else { // ????19???8??? medicineF = min_8; } // ********** @009 ********** if ((ClaimConst.SUBCLASS_CODE_ID.equals(items[cnt].getClassCodeSystem())) && ((String.valueOf(ClaimConst.YAKUZAI).equals(items[cnt].getClassCode())) || (String.valueOf(ClaimConst.ZAIRYO).equals(items[cnt].getClassCode())))) { pcell = new PdfPCell(new Paragraph(convertNVL(items[cnt].getName()), medicineF)); // ?? ??? ???? pcell.setBorderWidth(LINE_WIDTH_0); ptbl.addCell(pcell); amountCell = new PdfPCell(new Paragraph(convertNVL(amount), min_8)); // ? setAlignRight(amountCell); amountCell.setBorderWidth(LINE_WIDTH_0); ptbl.addCell(amountCell); if (!(String.valueOf(ClaimConst.ZAIRYO).equals(items[cnt].getClassCode()))) { // ????? pcell = new PdfPCell(new Paragraph(convertNVL(items[cnt].getUnit()), min_8)); // ?? pcell.setBorderWidth(LINE_WIDTH_0); ptbl.addCell(pcell); // ********** @009 ********** pcell = new PdfPCell(new Paragraph(admin, adminF)); // pcell.setBorderWidth(LINE_WIDTH_0); pcell.setNoWrap(wrap); ptbl.addCell(pcell); } else { blank = new PdfPCell(); blank.setColspan(2); blank.setBorderWidth(LINE_WIDTH_0); ptbl.addCell(blank); } if (ClaimConst.RECEIPT_CODE_GAIYO.equals(classCode)) { pcell = new PdfPCell(new Paragraph("", min_8)); pcell.setBorderWidth(LINE_WIDTH_0); pcell.setColspan(3); ptbl.addCell(pcell); sum = Double.parseDouble(amount) * Double.parseDouble(number); DecimalFormat f = new DecimalFormat("####0.###"); // System.out.println("??" + sum); amountCell.getPhrase().clear(); amountCell.getPhrase().add(new Paragraph(String.valueOf(f.format(sum)), min_8)); // ? } else { // if ((number != null) && !("".equals(number))) { pcell = new PdfPCell(new Paragraph("(", min_8)); pcell.setBorderWidth(LINE_WIDTH_0); ptbl.addCell(pcell); pcell = new PdfPCell(new Paragraph(number, min_8)); pcell.setBorderWidth(LINE_WIDTH_0); setAlignRight(pcell); ptbl.addCell(pcell); //minagawa^ if (classCode.startsWith("22")) { // pcell = new PdfPCell(new Paragraph(")", min_8)); } else if (classCode.startsWith("21")) { // pcell = new PdfPCell(new Paragraph(")", min_8)); // } else if (classCode.startsWith("23")) { pcell = new PdfPCell(new Paragraph("", min_8)); } //minagawa$ pcell.setBorderWidth(LINE_WIDTH_0); setAlignRight(pcell); ptbl.addCell(pcell); } else { blank = new PdfPCell(); blank.setBorderWidth(LINE_WIDTH_0); blank.setColspan(3); ptbl.addCell(blank); } } // ********** @009 ********** } else { pcell = new PdfPCell(new Paragraph(convertNVL(items[cnt].getName()), min_8)); pcell.setBorderWidth(LINE_WIDTH_0); pcell.setColspan(7); ptbl.addCell(pcell); } } // @004 2010/02/26 // ?? true ???? if (clearFlg && (admin == null)) { numCell.getPhrase().clear(); num--; } // @004 2010/02/26 } else { String stampName = prescription.getOrderName(); System.err.println("??" + stampName + "????????????"); StringBuilder b = new StringBuilder(); b.append("??").append(stampName) .append("?????????").append(System.getProperty(STR_LF)); System.err.println(b.toString()); } if (!ite.hasNext()) { blank = new PdfPCell(); blank.setBorderWidth(LINE_WIDTH_0); ptbl.addCell(blank); pcell = new PdfPCell(new Paragraph("", min_8)); pcell.setBorderWidth(LINE_WIDTH_0); pcell.setBorderWidthLeft(LINE_WIDTH_1); pcell.setPaddingLeft(30f); pcell.setColspan(8); ptbl.addCell(pcell); preTblList.add(ptbl); } } } catch (Exception e) { e.printStackTrace(System.err); } return preTblList; }
From source file:org.areasy.common.doclet.document.Summary.java
License:Open Source License
/** * Prints inner classes summaries.//from w ww . j a v a 2 s . c om * * @param name * @param destination * @param isDeprecated * @param deprecatedPhrase * @param mainTable * @throws Exception */ private static void printInnerClass(String name, String destination, boolean isDeprecated, Phrase deprecatedPhrase, PdfPTable mainTable) throws Exception { Element[] objs = HtmlParserWrapper.createPdfObjects(name); PdfPTable commentsTable = createColumnsAndDeprecated(objs, isDeprecated, deprecatedPhrase); PdfPTable anotherinnertable = new PdfPTable(1); anotherinnertable.setWidthPercentage(100f); anotherinnertable.getDefaultCell().setBorder(Rectangle.NO_BORDER); PdfPTable innerTable = addDeclaration("class", null); // right part of the table PdfPCell cell = PDFUtility.createElementCell(2, new LinkPhrase(destination, name, Fonts.getFont(CODE_FONT, 9))); cell.setPaddingTop((float) 2.0); cell.setPaddingLeft((float) 7.0); anotherinnertable.addCell(cell); anotherinnertable.addCell(commentsTable); innerTable.addCell(anotherinnertable); mainTable.addCell(innerTable); }
From source file:org.areasy.common.doclet.document.Summary.java
License:Open Source License
/** * Prints field summaries.//from w w w. j a va2 s. c om * @param constantValue * @param isDeprecated * @param deprecatedPhrase * @param mainTable * @throws Exception */ private static void printField(FieldDoc fieldDoc, Object constantValue, boolean isDeprecated, Phrase deprecatedPhrase, PdfPTable mainTable) throws Exception { String name = fieldDoc.name(); String modifier = fieldDoc.modifiers(); String commentText = DocletUtility.getFirstSentence(fieldDoc); String destination = fieldDoc.qualifiedName(); Element[] objs = HtmlParserWrapper.createPdfObjects(commentText); PdfPTable commentsTable = createColumnsAndDeprecated(objs, isDeprecated, deprecatedPhrase); if (constantValue != null) { // Add 2nd comment line (left cell empty, right cell text) commentsTable.addCell(new Phrase("")); Chunk valueTextChunk = new Chunk("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); commentsTable.addCell(constantValuePhrase); } PdfPTable anotherinnertable = new PdfPTable(1); anotherinnertable.setWidthPercentage(100f); anotherinnertable.getDefaultCell().setBorder(Rectangle.NO_BORDER); PdfPTable innerTable = addDeclaration(modifier, null); // Link to field LinkPhrase linkPhrase = new LinkPhrase(destination, name, Fonts.getFont(CODE_FONT, 9)); // right part of the table PdfPCell cell = PDFUtility.createElementCell(2, linkPhrase); cell.setPaddingTop((float) 2.0); cell.setPaddingLeft((float) 7.0); anotherinnertable.addCell(cell); anotherinnertable.addCell(commentsTable); innerTable.addCell(anotherinnertable); mainTable.addCell(innerTable); }
From source file:org.areasy.common.doclet.document.Summary.java
License:Open Source License
/** * Prints constructor summaries.//from w w w .j av a 2s .com * @param isDeprecated * @param deprecatedPhrase * @param mainTable * @throws Exception */ private static void printConstructor(ConstructorDoc constructorDoc, boolean isDeprecated, Phrase deprecatedPhrase, PdfPTable mainTable) throws Exception { String name = constructorDoc.name(); String modifier = constructorDoc.modifiers(); String commentText = DocletUtility.getFirstSentence(constructorDoc); String destination = constructorDoc.qualifiedName() + constructorDoc.signature(); Parameter[] parms = constructorDoc.parameters(); Element[] objs = HtmlParserWrapper.createPdfObjects(commentText); PdfPTable commentsTable = createColumnsAndDeprecated(objs, isDeprecated, deprecatedPhrase); PdfPTable anotherinnertable = new PdfPTable(1); anotherinnertable.setWidthPercentage(100f); anotherinnertable.getDefaultCell().setBorder(Rectangle.NO_BORDER); // Link to constructor Font constructorFont = Fonts.getFont(CODE_FONT, 9); Phrase phrase = new Phrase("", constructorFont); phrase.add(new LinkPhrase(destination, name, constructorFont)); phrase.add("("); if ((parms != null) && (parms.length > 0)) { for (int i = 0; i < parms.length; i++) { phrase.add(PDFUtility.getParameterTypePhrase(parms[i], 9)); phrase.add(" "); phrase.add(parms[i].name()); if (i != (parms.length - 1)) { phrase.add(", "); } } } phrase.add(")"); PdfPCell cell = PDFUtility.createElementCell(2, phrase); cell.setPaddingLeft((float) 7.0); anotherinnertable.addCell(cell); anotherinnertable.addCell(commentsTable); PdfPTable innerTable = addDeclaration(modifier, null); innerTable.addCell(anotherinnertable); mainTable.addCell(innerTable); }
From source file:org.areasy.common.doclet.document.Summary.java
License:Open Source License
/** * Prints the summary tables for a method. * @param modifier//from w ww . jav a 2 s. c o m * @param returnType * @param isDeprecated * @param deprecatedPhrase * @param mainTable * @throws Exception */ private static void printMethod(MethodDoc methodDoc, String modifier, Phrase returnType, boolean isDeprecated, Phrase deprecatedPhrase, PdfPTable mainTable) throws Exception { String name = methodDoc.name(); String destination = methodDoc.qualifiedName() + methodDoc.signature(); String commentText = DocletUtility.getFirstSentence(methodDoc); Parameter[] parms = methodDoc.parameters(); // Create inner table for both columns (left column already filled in) PdfPTable rowTable = addDeclaration(modifier, returnType); // Inner table with 1st sentence of javadoc of this method. // We use a table in order to be able to create two cells // in it (1st an empty one for intendation) Element[] objs = HtmlParserWrapper.createPdfObjects(commentText); // Phrase descPhr = new Phrase(); PdfPTable commentsTable = createColumnsAndDeprecated(objs, isDeprecated, deprecatedPhrase); // Table with 1 column and 2 rows (row 1 is parameters etc., // row 2 is the description PdfPTable rightColumnInnerTable = new PdfPTable(1); rightColumnInnerTable.setWidthPercentage(100f); rightColumnInnerTable.getDefaultCell().setBorder(Rectangle.NO_BORDER); // Link to method Font methodFont = Fonts.getFont(CODE_FONT, 9); Phrase phrase = new Phrase("", methodFont); phrase.add(new LinkPhrase(destination, name, methodFont)); phrase.add("("); if ((parms != null) && (parms.length > 0)) { for (int i = 0; i < parms.length; i++) { phrase.add(PDFUtility.getParameterTypePhrase(parms[i], 9)); phrase.add(" "); phrase.add(parms[i].name()); if (i != (parms.length - 1)) { phrase.add(", "); } } } phrase.add(")"); PdfPCell cell = PDFUtility.createElementCell(2, phrase); cell.setPaddingLeft((float) 7.0); rightColumnInnerTable.addCell(cell); rightColumnInnerTable.addCell(commentsTable); // Now fill in right column as well rowTable.addCell(rightColumnInnerTable); // And add inner table to main summary table as a new row mainTable.addCell(rowTable); }