public void write(PDFDocument document, PdfPTable tabla) throws DocumentException { com.lowagie.text.List list = new com.lowagie.text.List(false,10f); list.setListSymbol(new Chunk("\u2022")); PdfPCell cell = new PdfPCell(); if(!titulo.equals("")) { cell.addElement(new Phrase(titulo,document.getContext().getDefaultFont())); } for(int i=0; i<campos.size(); i++) { list.add(new ListItem((String)campos.get(i),document.getContext().getDefaultFont())); } cell.addElement(list); cell.setPaddingLeft(30f); cell.setBorder(Rectangle.LEFT | Rectangle.RIGHT); cell.setColspan(2); tabla.addCell(cell); }
private float addImage(PdfPCell cell, String name) { try { java.awt.Image awtImage = (java.awt.Image)iImages.get(name); if (awtImage==null) return 0; Image img = Image.getInstance(awtImage, Color.WHITE); Chunk ck = new Chunk(img, 0, 0); if (cell.getPhrase()==null) { cell.setPhrase(new Paragraph(ck)); cell.setVerticalAlignment(Element.ALIGN_TOP); cell.setHorizontalAlignment(Element.ALIGN_CENTER); } else { cell.getPhrase().add(ck); } return awtImage.getWidth(null); } catch (Exception e) { return 0; } }
private float addText(PdfPCell cell, String text, boolean bold, boolean italic, boolean underline, Color color, Color bgColor) { Font font = PdfFont.getFont(bold, italic, underline, color); Chunk chunk = new Chunk(text, font); if (bgColor!=null) chunk.setBackground(bgColor); if (cell.getPhrase()==null) { cell.setPhrase(new Paragraph(chunk)); cell.setVerticalAlignment(Element.ALIGN_TOP); cell.setHorizontalAlignment(Element.ALIGN_CENTER); } else { cell.getPhrase().add(chunk); } float width = 0; if (text.indexOf('\n')>=0) { for (StringTokenizer s = new StringTokenizer(text,"\n"); s.hasMoreTokens();) width = Math.max(width,font.getBaseFont().getWidthPoint(s.nextToken(), font.getSize())); } else width = Math.max(width,font.getBaseFont().getWidthPoint(text, font.getSize())); return width; }
/** * Constructs a <CODE>PdfPCell</CODE> with an <CODE>Image</CODE>. * The default padding is 0.25 for a border width of 0.5. * * @param image the <CODE>Image</CODE> * @param fit <CODE>true</CODE> to fit the image to the cell */ public PdfPCell(Image image, boolean fit) { super(0, 0, 0, 0); borderWidth = 0.5f; border = BOX; if (fit) { this.image = image; column.setLeading(0, 1); setPadding(borderWidth / 2); } else { column.addText(this.phrase = new Phrase(new Chunk(image, 0, 0))); column.setLeading(0, 1); setPadding(0); } }
public boolean handleCloseGroup() { this.onCloseGroup(); // event handler if(this.rtfParser.isImport()) { if(this.buffer.length()>0) { writeBuffer(); } writeText("}"); } if(this.rtfParser.isConvert()) { if(this.buffer.length() > 0 && this.iTextParagraph == null) { this.iTextParagraph = new Paragraph(); } if(this.buffer.length() > 0 ) { Chunk chunk = new Chunk(); chunk.append(this.buffer.toString()); this.iTextParagraph.add(chunk); } if(this.iTextParagraph != null) { addParagraphToDocument(); } } return true; }
/** * Constructs a RtfChunk based on the content of a Chunk * * @param doc The RtfDocument that this Chunk belongs to * @param chunk The Chunk that this RtfChunk is based on */ public RtfChunk(RtfDocument doc, Chunk chunk) { super(doc); if(chunk == null) { return; } if(chunk.getAttributes() != null && chunk.getAttributes().get(Chunk.SUBSUPSCRIPT) != null) { this.superSubScript = ((Float)chunk.getAttributes().get(Chunk.SUBSUPSCRIPT)).floatValue(); } if(chunk.getAttributes() != null && chunk.getAttributes().get(Chunk.BACKGROUND) != null) { this.background = new RtfColor(this.document, (Color) ((Object[]) chunk.getAttributes().get(Chunk.BACKGROUND))[0]); } font = new RtfFont(doc, chunk.getFont()); content = chunk.getContent(); }
/** * Creates a Phrase object based on a list of properties. * @param attributes * @return a Phrase */ public static Phrase getPhrase(Properties attributes) { Phrase phrase = new Phrase(); phrase.setFont(FontFactory.getFont(attributes)); String value; value = attributes.getProperty(ElementTags.LEADING); if (value != null) { phrase.setLeading(Float.parseFloat(value + "f")); } value = attributes.getProperty(Markup.CSS_KEY_LINEHEIGHT); if (value != null) { phrase.setLeading(Markup.parseLength(value, Markup.DEFAULT_FONT_SIZE)); } value = attributes.getProperty(ElementTags.ITEXT); if (value != null) { Chunk chunk = new Chunk(value); if ((value = attributes.getProperty(ElementTags.GENERICTAG)) != null) { chunk.setGenericTag(value); } phrase.add(chunk); } return phrase; }
public Chunk createChunk(String text, ChainedProperties props) { Font font = getFont(props); float size = font.getSize(); size /= 2; Chunk ck = new Chunk(text, font); if (props.hasProperty("sub")) ck.setTextRise(-size); else if (props.hasProperty("sup")) ck.setTextRise(size); ck.setHyphenation(getHyphenation(props)); return ck; }
/** * Specifying an encoding. */ @Test public void main() throws Exception { // step 1: creation of a document-object Document document = new Document(); // step 2: creation of the writer PdfWriter.getInstance(document, PdfTestBase.getOutputStream("fontencoding.pdf")); // step 3: we open the document document.open(); // step 4: we add content to the document BaseFont helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED); Font font = new Font(helvetica, 12, Font.NORMAL); Chunk chunk = new Chunk("Sponsor this example and send me 1\u20ac. These are some special characters: \u0152\u0153\u0160\u0161\u0178\u017D\u0192\u02DC\u2020\u2021\u2030", font); document.add(chunk); // step 5: we close the document document.close(); }
/** * Creates a document with a javascript action. * */ @Test public void main() throws Exception { // step 1: creation of a document-object Document document = new Document(); // step 2: PdfWriter writer = PdfWriter.getInstance(document, PdfTestBase.getOutputStream("JavaScriptAction.pdf")); // step 3: we add Javascript as Metadata and we open the document document.open(); // step 4: we add some content Paragraph p = new Paragraph(new Chunk("Click to say Hello").setAction(PdfAction.javaScript( "app.alert('Hello');\r", writer))); document.add(p); // step 5: we close the document document.close(); }
/** * Creates a document with Named Actions. * * @param args The file to open */ public void main(String... args) throws Exception { // step 1: creation of a document-object Document document = new Document(PageSize.A4, 50, 50, 50, 50); // step 2: we create a writer that listens to the document PdfWriter.getInstance(document, PdfTestBase.getOutputStream("OpenApplication.pdf")); // step 3: we open the document document.open(); // step 4: we add some content String application = args[0]; Paragraph p = new Paragraph(new Chunk("Click to open " + application).setAction( new PdfAction(application, null, null, null))); document.add(p); // step 5: we close the document document.close(); }
/** * Creates a document with chained Actions. * */ @Test public void main() throws Exception { // step 1: creation of a document-object Document document = new Document(); // step 2: PdfWriter writer = PdfWriter.getInstance(document, PdfTestBase.getOutputStream("ChainedActions.pdf")); // step 3: we add Javascript as Metadata and we open the document document.open(); // step 4: we add some content PdfAction action = PdfAction.javaScript("app.alert('Welcome at my site');\r", writer); action.next(new PdfAction("http://www.lowagie.com/iText/")); Paragraph p = new Paragraph(new Chunk("Click to go to Bruno's site").setAction(action)); document.add(p); // step 5: we close the document document.close(); }
/** * Using FontSelector. */ @Test public void main() throws Exception { // step 1 Document document = new Document(); // step 2 PdfWriter.getInstance(document, PdfTestBase.getOutputStream("differentfonts.pdf")); // step 3 document.open(); // step 4 Paragraph p = new Paragraph(); p.add(new Chunk("This text is in Times Roman. This is ZapfDingbats: ", new Font(Font.TIMES_ROMAN, 12))); p.add(new Chunk("abcdefghijklmnopqrstuvwxyz", new Font(Font.ZAPFDINGBATS, 12))); p.add(new Chunk(". This is font Symbol: ", new Font(Font.TIMES_ROMAN, 12))); p.add(new Chunk("abcdefghijklmnopqrstuvwxyz", new Font(Font.SYMBOL, 12))); document.add(new Paragraph(p)); // step 5 document.close(); }
private void createTempFile(String filename, String[] pageContents) throws Exception{ Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream(filename)); document.open(); for (int i = 0; i < pageContents.length; i++) { if (i != 0) document.newPage(); String content = pageContents[i]; Chunk contentChunk = new Chunk(content); document.add(contentChunk); } document.close(); }
protected void writePageAnchor(int pageIndex) throws DocumentException { Map<Attribute,Object> attributes = new HashMap<Attribute,Object>(); fontUtil.getAttributesWithoutAwtFont(attributes, new JRBasePrintText(jasperPrint.getDefaultStyleProvider())); Font pdfFont = getFont(attributes, getLocale(), false); Chunk chunk = new Chunk(" ", pdfFont); chunk.setLocalDestination(JR_PAGE_ANCHOR_PREFIX + reportIndex + "_" + (pageIndex + 1)); tagHelper.startPageAnchor(); ColumnText colText = new ColumnText(pdfContentByte); colText.setSimpleColumn( new Phrase(chunk), 0, pageFormat.getPageHeight(), 1, 1, 0, Element.ALIGN_LEFT ); colText.go(); tagHelper.endPageAnchor(); }
protected void setAnchor(Chunk chunk, JRPrintAnchor anchor, JRPrintElement element) { String anchorName = anchor.getAnchorName(); if (anchorName != null) { chunk.setLocalDestination(anchorName); if (anchor.getBookmarkLevel() != JRAnchor.NO_BOOKMARK) { int x = OrientationEnum.PORTRAIT.equals(pageFormat.getOrientation()) ? getOffsetX() + element.getX() : getOffsetY() + element.getY(); int y = OrientationEnum.PORTRAIT.equals(pageFormat.getOrientation()) ? getOffsetY() + element.getY() : getOffsetX() + element.getX(); addBookmark(anchor.getBookmarkLevel(), anchor.getAnchorName(), x, y); } } }
private void writeJndiBinding(JndiBinding jndiBinding) throws BadElementException, IOException { final PdfPCell defaultCell = getDefaultCell(); defaultCell.setHorizontalAlignment(Element.ALIGN_LEFT); final String name = jndiBinding.getName(); final String className = jndiBinding.getClassName(); final String contextPath = jndiBinding.getContextPath(); final String value = jndiBinding.getValue(); if (contextPath != null) { final Image image = getFolderImage(); final Phrase phrase = new Phrase("", cellFont); phrase.add(new Chunk(image, 0, 0)); phrase.add(" "); phrase.add(name); addCell(phrase); } else { addCell(name); } addCell(className != null ? className : ""); addCell(value != null ? value : ""); }
private void writeMemoryInformations(MemoryInformations memoryInformations) throws BadElementException, IOException { addCell(memoryInformations.getMemoryDetails().replace(" Mo", ' ' + getString("Mo"))); final long usedPermGen = memoryInformations.getUsedPermGen(); if (usedPermGen > 0) { // perm gen est à 0 sous jrockit final long maxPermGen = memoryInformations.getMaxPermGen(); addCell(getString("Memoire_Perm_Gen") + ':'); if (maxPermGen > 0) { final Phrase permGenPhrase = new Phrase( integerFormat.format(usedPermGen / 1024 / 1024) + ' ' + getString("Mo") + DIVIDE + integerFormat.format(maxPermGen / 1024 / 1024) + ' ' + getString("Mo") + BAR_SEPARATOR, cellFont); final Image permGenImage = Image.getInstance( Bar.toBarWithAlert(memoryInformations.getUsedPermGenPercentage()), null); permGenImage.scalePercent(50); permGenPhrase.add(new Chunk(permGenImage, 0, 0)); currentTable.addCell(permGenPhrase); } else { addCell(integerFormat.format(usedPermGen / 1024 / 1024) + ' ' + getString("Mo")); } } }
/** * Affiche l'arbre des MBeans. * @throws DocumentException e */ void writeTree() throws DocumentException { // MBeans pour la plateforme margin = 0; final MBeanNode platformNode = mbeans.get(0); writeTree(platformNode.getChildren()); for (final MBeanNode node : mbeans) { if (node != platformNode) { newPage(); addToDocument(new Chunk(node.getName(), boldFont)); margin = 0; writeTree(node.getChildren()); } } }
Element createParagraphElement(String paragraphTitle, String iconName) throws DocumentException, IOException { final Paragraph paragraph = new Paragraph("", paragraphTitleFont); paragraph.setSpacingBefore(5); paragraph.setSpacingAfter(5); if (iconName != null) { paragraph.add(new Chunk(getParagraphImage(iconName), 0, -5)); } final Phrase element = new Phrase(' ' + paragraphTitle, paragraphTitleFont); element.setLeading(12); paragraph.add(element); // chapter pour avoir la liste des signets final ChapterAutoNumber chapter = new ChapterAutoNumber(paragraph); // sans numéro de chapitre chapter.setNumberDepth(0); chapter.setBookmarkOpen(false); chapter.setTriggerNewPage(false); return chapter; }
protected void writeBatchGroupSectionTitle(com.lowagie.text.Document pdfDoc, String batchSeqNbr, java.sql.Date procInvDt, String cashControlDocNumber) { Font font = FontFactory.getFont(FontFactory.COURIER, 10, Font.BOLD); String lineText = "CASHCTL " + rightPad(cashControlDocNumber, 12) + " " + "BATCH GROUP: " + rightPad(batchSeqNbr, 5) + " " + rightPad((procInvDt == null ? "NONE" : procInvDt.toString()), 35); Paragraph paragraph = new Paragraph(); paragraph.setAlignment(com.lowagie.text.Element.ALIGN_LEFT); Chunk chunk = new Chunk(lineText, font); chunk.setBackground(Color.LIGHT_GRAY, 5, 5, 5, 5); paragraph.add(chunk); // blank line paragraph.add(new Chunk("", font)); try { pdfDoc.add(paragraph); } catch (DocumentException e) { LOG.error("iText DocumentException thrown when trying to write content.", e); throw new RuntimeException("iText DocumentException thrown when trying to write content.", e); } }
protected void writeDetailLine(com.lowagie.text.Document pdfDoc, String detailLineText) { if (ObjectUtils.isNotNull(detailLineText)) { Font font = FontFactory.getFont(FontFactory.COURIER, 8, Font.NORMAL); Paragraph paragraph = new Paragraph(); paragraph.setAlignment(com.lowagie.text.Element.ALIGN_LEFT); paragraph.add(new Chunk(detailLineText, font)); try { pdfDoc.add(paragraph); } catch (DocumentException e) { LOG.error("iText DocumentException thrown when trying to write content.", e); throw new RuntimeException("iText DocumentException thrown when trying to write content.", e); } } }
protected void writeInvoiceSectionTitle(com.lowagie.text.Document pdfDoc, String customerNameLine) { Font font = FontFactory.getFont(FontFactory.COURIER, 8, Font.BOLD + Font.UNDERLINE); Paragraph paragraph = new Paragraph(); paragraph.setAlignment(com.lowagie.text.Element.ALIGN_LEFT); paragraph.add(new Chunk(customerNameLine, font)); // blank line paragraph.add(new Chunk("", font)); try { pdfDoc.add(paragraph); } catch (DocumentException e) { LOG.error("iText DocumentException thrown when trying to write content.", e); throw new RuntimeException("iText DocumentException thrown when trying to write content.", e); } }
protected void writeInvoiceSectionMessage(com.lowagie.text.Document pdfDoc, String resultLine) { Font font = FontFactory.getFont(FontFactory.COURIER, 8, Font.NORMAL); Paragraph paragraph = new Paragraph(); paragraph.setAlignment(com.lowagie.text.Element.ALIGN_LEFT); paragraph.add(new Chunk(resultLine, font)); // blank line paragraph.add(new Chunk("", font)); try { pdfDoc.add(paragraph); } catch (DocumentException e) { LOG.error("iText DocumentException thrown when trying to write content.", e); throw new RuntimeException("iText DocumentException thrown when trying to write content.", e); } }
protected void writeFileNameSectionTitle(Document pdfDoc, String filenameLine) { Font font = FontFactory.getFont(FontFactory.COURIER, 10, Font.BOLD); Paragraph paragraph = new Paragraph(); paragraph.setAlignment(Element.ALIGN_LEFT); Chunk chunk = new Chunk(filenameLine, font); chunk.setBackground(Color.LIGHT_GRAY, 5, 5, 5, 5); paragraph.add(chunk); // blank line paragraph.add(new Chunk("", font)); try { pdfDoc.add(paragraph); } catch (DocumentException e) { LOG.error("iText DocumentException thrown when trying to write content.", e); throw new RuntimeException("iText DocumentException thrown when trying to write content.", e); } }
protected void writeCustomerSectionTitle(Document pdfDoc, String customerNameLine) { Font font = FontFactory.getFont(FontFactory.COURIER, 8, Font.BOLD + Font.UNDERLINE); Paragraph paragraph = new Paragraph(); paragraph.setAlignment(Element.ALIGN_LEFT); paragraph.add(new Chunk(customerNameLine, font)); // blank line paragraph.add(new Chunk("", font)); try { pdfDoc.add(paragraph); } catch (DocumentException e) { LOG.error("iText DocumentException thrown when trying to write content.", e); throw new RuntimeException("iText DocumentException thrown when trying to write content.", e); } }
protected void writeCustomerSectionResult(Document pdfDoc, String resultLine) { Font font = FontFactory.getFont(FontFactory.COURIER, 8, Font.BOLD); Paragraph paragraph = new Paragraph(); paragraph.setAlignment(Element.ALIGN_LEFT); paragraph.add(new Chunk(resultLine, font)); // blank line paragraph.add(new Chunk("", font)); try { pdfDoc.add(paragraph); } catch (DocumentException e) { LOG.error("iText DocumentException thrown when trying to write content.", e); throw new RuntimeException("iText DocumentException thrown when trying to write content.", e); } }
protected void writeMessageEntryLines(Document pdfDoc, List<String[]> messageLines) { Font font = FontFactory.getFont(FontFactory.COURIER, 8, Font.NORMAL); Paragraph paragraph; String messageEntry; for (String[] messageLine : messageLines) { paragraph = new Paragraph(); paragraph.setAlignment(Element.ALIGN_LEFT); messageEntry = StringUtils.rightPad(messageLine[0], (12 - messageLine[0].length()), " ") + " - " + messageLine[1].toUpperCase(); paragraph.add(new Chunk(messageEntry, font)); // blank line paragraph.add(new Chunk("", font)); try { pdfDoc.add(paragraph); } catch (DocumentException e) { LOG.error("iText DocumentException thrown when trying to write content.", e); throw new RuntimeException("iText DocumentException thrown when trying to write content.", e); } } }
private PdfPCell getPDFCell(String fieldTitle, String fieldValue){ Paragraph p = new Paragraph(); p.add(new Chunk(" " + fieldTitle, ver_5_normal)); if (StringUtils.isNotEmpty(fieldValue)){ p.add(new Chunk(" " + fieldValue, cour_10_normal)); }else{ p.add(new Chunk(" ")); } PdfPCell cell = new PdfPCell(p); cell.setHorizontalAlignment(Element.ALIGN_LEFT); return cell; }
/** * This method adds any error to the report * * @param errorMsg */ private void generateReportErrorLog(String errorMsg) { try { Font font = FontFactory.getFont(FontFactory.HELVETICA, 9, Font.NORMAL); Paragraph p1 = new Paragraph(); int rowsWritten = 0; if (!errorMsg.equals("")) { this.generateErrorColumnHeaders(); p1 = new Paragraph(new Chunk(errorMsg, font)); this.document.add(p1); line++; } } catch (Exception de) { throw new RuntimeException("DepreciationReport.generateReportErrorLog(List<String> reportLog) - Report Generation Failed: " + de.getMessage()); } }
public void preProcessPDF(Object document) throws IOException, BadElementException, DocumentException { Document pdf = (Document) document; pdf.setPageSize(PageSize.A3); pdf.open(); ServletContext servletContext = (ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext(); String logo = servletContext.getRealPath("") + File.separator +"resources" + File.separator + "images" + File.separator +"logo" + File.separator + "logo.png"; Image image=Image.getInstance(logo); image.scaleAbsolute(100f, 50f); pdf.add(image); // add a couple of blank lines pdf.add( Chunk.NEWLINE ); pdf.add( Chunk.NEWLINE ); Font fontbold = FontFactory.getFont("Times-Roman", 16, Font.BOLD); fontbold.setColor(55, 55, 55);; pdf.add(new Paragraph("Investment Summary",fontbold)); // add a couple of blank lines pdf.add( Chunk.NEWLINE ); pdf.add( Chunk.NEWLINE ); }
public void preProcessPDF(Object document) throws IOException, BadElementException, DocumentException { Document pdf = (Document) document; pdf.setPageSize(PageSize.A3); pdf.open(); ServletContext servletContext = (ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext(); String logo = servletContext.getRealPath("") + File.separator +"resources" + File.separator + "images" + File.separator +"logo" + File.separator + "logo.png"; Image image=Image.getInstance(logo); image.scaleAbsolute(100f, 50f); pdf.add(image); // add a couple of blank lines pdf.add( Chunk.NEWLINE ); pdf.add( Chunk.NEWLINE ); Font fontbold = FontFactory.getFont("Times-Roman", 16, Font.BOLD); fontbold.setColor(55, 55, 55);; pdf.add(new Paragraph("Account Summary",fontbold)); // add a couple of blank lines pdf.add( Chunk.NEWLINE ); pdf.add( Chunk.NEWLINE ); }
public void preProcessPDF(Object document) throws IOException, BadElementException, DocumentException { Document pdf = (Document) document; pdf.setPageSize(PageSize.A4); pdf.open(); ServletContext servletContext = (ServletContext) FacesContext .getCurrentInstance().getExternalContext().getContext(); String logo = servletContext.getRealPath("") + File.separator + "resources" + File.separator + "images" + File.separator + "logo" + File.separator + "logo.png"; Image image = Image.getInstance(logo); image.scaleAbsolute(100f, 50f); pdf.add(image); // add a couple of blank lines pdf.add(Chunk.NEWLINE); pdf.add(Chunk.NEWLINE); Font fontbold = FontFactory.getFont("Times-Roman", 16, Font.BOLD); fontbold.setColor(55, 55, 55); ; pdf.add(new Paragraph("Transaction Summary", fontbold)); // add a couple of blank lines pdf.add(Chunk.NEWLINE); pdf.add(Chunk.NEWLINE); }
/** * Using FontSelector. * * @param args * no arguments needed */ public static void main(String[] args) { try { // step 1 Document document = new Document(); // step 2 PdfWriter.getInstance(document, new FileOutputStream(android.os.Environment.getExternalStorageDirectory() + java.io.File.separator + "droidtext" + java.io.File.separator + "differentfonts.pdf")); // step 3 document.open(); // step 4 Paragraph p = new Paragraph(); p.add(new Chunk("This text is in Times Roman. This is ZapfDingbats: ", new Font(Font.TIMES_ROMAN, 12))); p.add(new Chunk("abcdefghijklmnopqrstuvwxyz", new Font(Font.ZAPFDINGBATS, 12))); p.add(new Chunk(". This is font Symbol: ", new Font(Font.TIMES_ROMAN, 12))); p.add(new Chunk("abcdefghijklmnopqrstuvwxyz", new Font(Font.SYMBOL, 12))); document.add(new Paragraph(p)); // step 5 document.close(); } catch (Exception de) { de.printStackTrace(); } }
/** * Creates a document with a javascript action. * * @param args * no arguments needed */ public static void main(String[] args) { System.out.println("JavaScript"); // step 1: creation of a document-object Document document = new Document(); try { // step 2: PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(android.os.Environment.getExternalStorageDirectory() + java.io.File.separator + "droidtext" + java.io.File.separator + "JavaScriptAction.pdf")); // step 3: we add Javascript as Metadata and we open the document document.open(); // step 4: we add some content Paragraph p = new Paragraph(new Chunk("Click to say Hello").setAction(PdfAction.javaScript( "app.alert('Hello');\r", writer))); document.add(p); } catch (Exception de) { de.printStackTrace(); } // step 5: we close the document document.close(); }
protected void insertDiagramSectionHeader(Document document, int[] tableParams, String description) { try { Table table = ReportUtils.createTable(tableParams[0], tableParams[1], tableParams[2], tableParams[3]); Chunk chunk = new Chunk(description, descriptionBoldFont); Cell descriptionCell = new Cell(chunk); descriptionCell.setColspan(1); descriptionCell.setHorizontalAlignment(Element.ALIGN_LEFT); descriptionCell.setBorderWidthBottom(1.5f); table.addCell(descriptionCell); document.add(table); } catch (Exception e) { jUCMNavErrorDialog error = new jUCMNavErrorDialog(e.getMessage()); e.printStackTrace(); } }
/** * Constructs a <CODE>PdfChunk</CODE>-object. * * @param string the content of the <CODE>PdfChunk</CODE>-object * @param other Chunk with the same style you want for the new Chunk */ PdfChunk(String string, PdfChunk other) { thisChunk[0] = this; value = string; this.font = other.font; this.attributes = other.attributes; this.noStroke = other.noStroke; this.baseFont = other.baseFont; Object obj[] = (Object[])attributes.get(Chunk.IMAGE); if (obj == null) image = null; else { image = (Image)obj[0]; offsetX = ((Float)obj[1]).floatValue(); offsetY = ((Float)obj[2]).floatValue(); changeLeading = ((Boolean)obj[3]).booleanValue(); } encoding = font.getFont().getEncoding(); splitCharacter = (SplitCharacter)noStroke.get(Chunk.SPLITCHARACTER); if (splitCharacter == null) splitCharacter = this; }
/** Constructs a <CODE>PdfPCell</CODE> with an <CODE>Image</CODE>. * The default padding is 0.25 for a border width of 0.5. * @param image the <CODE>Image</CODE> * @param fit <CODE>true</CODE> to fit the image to the cell */ public PdfPCell(Image image, boolean fit) { super(0, 0, 0, 0); if (fit) { borderWidth = 0.5f; border = BOX; this.image = image; column.setLeading(0, 1); setPadding(borderWidth / 2); } else { borderWidth = 0.5f; border = BOX; column.addText(this.phrase = new Phrase(new Chunk(image, 0, 0))); column.setLeading(0, 1); setPadding(0); } }