List of usage examples for com.itextpdf.text Section add
@Override public boolean add(final Element element)
Paragraph
, List
, Table
or another Section
to this Section
. From source file:br.com.docedesafio.pdfs.FirstPdf.java
private static void createTable(Section subCatPart) throws BadElementException { PdfPTable table = new PdfPTable(3); // t.setBorderColor(BaseColor.GRAY); // t.setPadding(4); // t.setSpacing(4); // t.setBorderWidth(1); PdfPCell c1 = new PdfPCell(new Phrase("Table Header 1")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1);//from www .j a v a 2s. c o m c1 = new PdfPCell(new Phrase("Table Header 2")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Table Header 3")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); table.setHeaderRows(1); table.addCell("1.0"); table.addCell("1.1"); table.addCell("1.2"); table.addCell("2.1"); table.addCell("2.2"); table.addCell("2.3"); subCatPart.add(table); }
From source file:bsf.conn.DBMS.java
private static void createTable(Section subCatPart, javax.swing.JTable table) { try {//from w w w.j a v a 2s .c o m PdfPTable ptable = new PdfPTable(table.getColumnCount()); // t.setBorderColor(BaseColor.GRAY); // t.setPadding(4); // t.setSpacing(4); // t.setBorderWidth(1); for (String col : DBMS.getTableHeader(table)) ptable.addCell(col); String[][] row = DBMS.getTable(table); for (String[] col : row) for (String cell : col) if (!(cell.equals("null"))) ptable.addCell(cell); else ptable.addCell(" "); subCatPart.add(ptable); } catch (Exception ex) { JOptionPane.showMessageDialog(null, ex); } }
From source file:com.athena.chameleon.engine.core.PDFDocGenerator.java
License:Apache License
public static void setLastPageInfo(Document doc, PdfWriter writer, int cNum) throws Exception { Chapter chapter = PDFWriterUtil.getChapter(MessageUtil.getMessage("pdf.message.chapter.confirm.title"), cNum);//from w ww.j a va 2s.com Paragraph preP = new Paragraph(); preP.add(new Phrase(MessageUtil.getMessage("pdf.message.chapter.confirm.prepared1"), PDFWriterUtil.fnNormalBold)); preP.add(new Phrase(" ", new Font(bfKorean, 10, Font.UNDERLINE))); preP.setSpacingBefore(15); preP.setSpacingAfter(2); chapter.add(preP); preP = new Paragraph(); preP.add(new Phrase(MessageUtil.getMessage("pdf.message.chapter.confirm.prepared2"), PDFWriterUtil.fnNormal)); preP.setIndentationLeft(65); preP.setSpacingAfter(14); chapter.add(preP); preP = new Paragraph(); preP.add(new Phrase(MessageUtil.getMessage("pdf.message.chapter.confirm.approved1"), PDFWriterUtil.fnNormalBold)); preP.add(new Phrase(" ", new Font(bfKorean, 10, Font.UNDERLINE))); preP.setSpacingBefore(15); preP.setSpacingAfter(2); chapter.add(preP); preP = new Paragraph(); preP.add(new Phrase(MessageUtil.getMessage("pdf.message.chapter.confirm.approved2"), PDFWriterUtil.fnNormal)); preP.setIndentationLeft(65); preP.setSpacingAfter(14); chapter.add(preP); cNum++; doc.add(chapter); chapter = PDFWriterUtil.getChapter(MessageUtil.getMessage("pdf.message.chapter.appendices.title"), cNum); Section section = PDFWriterUtil.getSection(chapter, MessageUtil.getMessage("pdf.message.chapter.appendices.label1")); Chunk url = new Chunk(MessageUtil.getMessage("pdf.message.chapter.appendices.text1"), PDFWriterUtil.fnURL); url.setAction(new PdfAction(new URL(MessageUtil.getMessage("pdf.message.chapter.appendices.text1")))); preP = new Paragraph(url); preP.setIndentationLeft(23); preP.setSpacingAfter(14); section.add(preP); section = PDFWriterUtil.getSection(chapter, MessageUtil.getMessage("pdf.message.chapter.appendices.label2")); doc.add(chapter); }
From source file:com.athena.chameleon.engine.utils.PDFWriterUtil.java
License:Apache License
/** * Element Mapping// ww w . j a v a 2 s.co m * * @param section section ? * @param e element * @return Section * @throws Exception */ public static Section setElement(PdfWriter writer, Section section, Element e) throws Exception { for (org.jdom2.Element e1 : e.getChildren()) { if (e1.getName().equals("section")) { // section? setSectionElement(writer, section, e1); } else if (e1.getName().equals("text")) { /* ? text ? attribute : padding - padding */ if (e1.getAttributeValue("padding") != null) { Paragraph text = getDefault(e1.getText()); text.setIndentationLeft( text.getIndentationLeft() + Float.parseFloat(e1.getAttributeValue("padding"))); section.add(text); } else { section.add(getDefault(e1.getText())); } } else if (e1.getName().equals("table")) { // ? setTable(section, e1); } else if (e1.getName().equals("textR")) { //?? ? text ? section.add(getDefaultRed(e1.getText(), Font.ITALIC)); } else if (e1.getName().equals("textP")) { //? ? text ? section.add(getDefaultPoint(e1.getText())); } else if (e1.getName().equals("box")) { //text box ? setBox(section, e1); } else if (e1.getName().equals("boxB")) { //? ? text box ? setBoxB(section, e1); } else if (e1.getName().equals("boxW")) { //text box ? setBoxW(section, e1); } else if (e1.getName().equals("list")) { //? ? setList(section, e1); } else if (e1.getName().equals("img")) { //? ? setImage(section, e1); } else if (e1.getName().equals("chart")) { // ? setChart(writer, section, e1); } } return section; }
From source file:com.athena.chameleon.engine.utils.PDFWriterUtil.java
License:Apache License
/** * /*from w w w. j a v a 2 s. c o m*/ * Table * * @param section table? section ? * @param e table element * @throws Exception */ public static void setTable(Section section, Element e) throws Exception { int colSize = Integer.parseInt(e.getAttributeValue("size")); PdfPTable t = new PdfPTable(colSize); if (e.getAttributeValue("width") != null) t.setTotalWidth(Float.parseFloat(e.getAttributeValue("width"))); t.setSpacingAfter(12); t.getDefaultCell().setLeading(0.0F, 1.3F); t.getDefaultCell().setMinimumHeight(22); t.getDefaultCell().setPaddingBottom(8); t.getDefaultCell().setVerticalAlignment(com.itextpdf.text.Element.ALIGN_MIDDLE); setTableHeader(e, t, colSize); setTableRow(e, t); section.add(t); }
From source file:com.athena.chameleon.engine.utils.PDFWriterUtil.java
License:Apache License
/** * /*from w w w .j av a 2s .com*/ * box * * @param section box section ? * @param e box element * @throws Exception */ public static void setBox(Section section, Element e) throws Exception { PdfPTable t = new PdfPTable(1); t.setSpacingBefore(1); t.setSpacingAfter(12); if (e.getAttributeValue("width") != null) t.setTotalWidth(Float.parseFloat(e.getAttributeValue("width"))); PdfPCell cell = new PdfPCell(); if (e.getAttributeValue("option") != null) { ColumnText col = new ColumnText(null); for (Element e1 : e.getChildren()) { if (e1.getAttributeValue("type").equals("red")) col.addText(new Phrase(e1.getText(), fnBoxRed)); else col.addText(new Phrase(e1.getText(), fnBox)); } cell.setColumn(col); } else { cell.setPhrase(new Phrase(e.getText(), fnBox)); } cell.setPaddingLeft(10); cell.setLeading(0.0F, 1.8F); cell.setVerticalAlignment(com.itextpdf.text.Element.ALIGN_MIDDLE); cell.setBackgroundColor(new BaseColor(238, 236, 225)); t.addCell(cell); section.add(t); }
From source file:com.athena.chameleon.engine.utils.PDFWriterUtil.java
License:Apache License
/** * /* w ww.j av a 2s . com*/ * box (Backgroud : Black) * * @param section box section ? * @param e box element * @throws Exception */ public static void setBoxB(Section section, Element e) throws Exception { PdfPTable t = new PdfPTable(1); t.setSpacingBefore(1); t.setSpacingAfter(12); if (e.getAttributeValue("width") != null) t.setTotalWidth(Float.parseFloat(e.getAttributeValue("width"))); PdfPCell cell = new PdfPCell(); if (e.getAttributeValue("option") != null) { ColumnText col = new ColumnText(null); for (Element e1 : e.getChildren()) { if (e1.getAttributeValue("type").equals("red")) col.addText(new Phrase(e1.getText(), fnBoxRed)); else col.addText(new Phrase(e1.getText(), fnBoxWhite)); } cell.setColumn(col); } else { cell.setPhrase(new Phrase(e.getText(), fnBoxWhite)); } cell.setPaddingLeft(10); cell.setLeading(0.0F, 1.8F); cell.setVerticalAlignment(com.itextpdf.text.Element.ALIGN_MIDDLE); cell.setBackgroundColor(new BaseColor(0, 0, 0)); t.addCell(cell); section.add(t); }
From source file:com.athena.chameleon.engine.utils.PDFWriterUtil.java
License:Apache License
/** * /* www. ja v a 2s .c o m*/ * box (Backgroud : White) * * @param section box section ? * @param e box element * @throws Exception */ public static void setBoxW(Section section, Element e) throws Exception { PdfPTable t = new PdfPTable(1); t.setSpacingBefore(1); t.setSpacingAfter(12); if (e.getAttributeValue("width") != null) t.setTotalWidth(Float.parseFloat(e.getAttributeValue("width"))); PdfPCell cell = new PdfPCell(); if (e.getAttributeValue("option") != null) { ColumnText col = new ColumnText(null); for (Element e1 : e.getChildren()) { if (e1.getAttributeValue("type").equals("red")) col.addText(new Phrase(e1.getText(), fnBoxRed)); else col.addText(new Phrase(e1.getText(), fnBoxBlack)); } cell.setColumn(col); } else { cell.setPhrase(new Phrase(e.getText(), fnBoxBlack)); } cell.setPaddingLeft(10); cell.setLeading(0.0F, 1.8F); cell.setVerticalAlignment(com.itextpdf.text.Element.ALIGN_MIDDLE); cell.setBackgroundColor(new BaseColor(255, 255, 255)); t.addCell(cell); section.add(t); }
From source file:com.athena.chameleon.engine.utils.PDFWriterUtil.java
License:Apache License
/** * // w w w. j a v a 2 s . co m * list * * @param section list section ? * @param e list element * @throws Exception */ public static void setList(Section section, Element e) throws Exception { List list = new List(false, 15); list.setIndentationLeft(23); for (Element e1 : e.getChildren()) { ListItem item = new ListItem(e1.getText(), fnNormal); if (e1.getChild("url") != null) { item.add(getUrl(e1.getChild("url"))); } item.setMultipliedLeading(1.8F); list.add(item); } list.getFirstItem().setSpacingBefore(-14); list.getLastItem().setSpacingAfter(14); section.add(list); }
From source file:com.athena.chameleon.engine.utils.PDFWriterUtil.java
License:Apache License
/** * //w ww . j a va 2s. com * image * * @param section image section ? * @param e image element * @throws Exception */ public static void setImage(Section section, Element e) throws Exception { Image img = Image.getInstance(PDFDocGenerator.class.getResource(e.getText())); img.setAlignment(com.itextpdf.text.Element.ALIGN_CENTER); if (e.getAttributeValue("scale") != null) { float scale = Float.parseFloat(e.getAttributeValue("scale")); img.scalePercent(scale, scale); } section.add(img); }