List of usage examples for com.lowagie.text Element ALIGN_RIGHT
int ALIGN_RIGHT
To view the source code for com.lowagie.text Element ALIGN_RIGHT.
Click Source Link
From source file:org.egov.works.web.actions.tender.TenderNegotiationPDFGenerator.java
License:Open Source License
public PdfPTable createBefTenderNegQuotedTable() { final double totTenderBefNegPer = tenderResponse.getPercQuotedRate(); final PdfPTable befTenderNegQuotedTable = new PdfPTable(2); befTenderNegQuotedTable.getDefaultCell().setBorderWidth(1); befTenderNegQuotedTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); befTenderNegQuotedTable.getDefaultCell().setColspan(2); String perc_amt = null;/*w ww. ja va 2 s . c o m*/ if (tenderResponse.getTenderEstimate().getTenderType().equalsIgnoreCase(percTenderType)) { if (totTenderBefNegPer > 0) perc_amt = formatter.format(totalBefNegAmt + totalBefNegAmt * (Math.abs(totTenderBefNegPer) / 100)); else perc_amt = formatter.format(totalBefNegAmt - totalBefNegAmt * (Math.abs(totTenderBefNegPer) / 100)); } else perc_amt = formatter.format(Math.abs(totalBefNegAmt)); befTenderNegQuotedTable.addCell(makePara(perc_amt)); return befTenderNegQuotedTable; }
From source file:org.egov.works.web.actions.tender.TenderNegotiationPDFGenerator.java
License:Open Source License
public PdfPTable createAftTenderNegFormulaTable() { final double totTenderAftNegPer = tenderResponse.getPercNegotiatedAmountRate(); final PdfPTable aftTenderNegFormulaTable = new PdfPTable(2); aftTenderNegFormulaTable.getDefaultCell().setBorderWidth(1); aftTenderNegFormulaTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); aftTenderNegFormulaTable.getDefaultCell().setColspan(2); String formated_perc = null;/* ww w . j a v a 2 s . c o m*/ if (tenderResponse.getTenderEstimate().getTenderType().equalsIgnoreCase(percTenderType)) formated_perc = nf.format(totTenderAftNegPer); else formated_perc = formatter.format(Math.abs(totTenderAftNegPer)); aftTenderNegFormulaTable .addCell(makePara((totTenderAftNegPer > 0 ? POSITIVE_SIGN : NEGATIVE_SIGN) + formated_perc + "%")); return aftTenderNegFormulaTable; }
From source file:org.egov.works.web.actions.tender.TenderNegotiationPDFGenerator.java
License:Open Source License
public PdfPTable createAftTenderNegQuotedTable() { final double totTenderAftNegPer = tenderResponse.getPercNegotiatedAmountRate(); final PdfPTable aftTenderNegQuotedTable = new PdfPTable(2); aftTenderNegQuotedTable.getDefaultCell().setBorderWidth(1); aftTenderNegQuotedTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); aftTenderNegQuotedTable.getDefaultCell().setColspan(2); String perc_amt = null;// www. java2 s . com if (tenderResponse.getTenderEstimate().getTenderType().equalsIgnoreCase(percTenderType)) { if (totTenderAftNegPer > 0) perc_amt = formatter.format(totalAftNegAmt + totalAftNegAmt * (Math.abs(totTenderAftNegPer) / 100)); else perc_amt = formatter.format(totalAftNegAmt - totalAftNegAmt * (Math.abs(totTenderAftNegPer) / 100)); } else perc_amt = formatter.format(Math.abs(totalAftNegAmt)); aftTenderNegQuotedTable.addCell(makePara(perc_amt)); return aftTenderNegQuotedTable; }
From source file:org.egov.works.web.actions.tender.TenderNegotiationPDFGenerator.java
License:Open Source License
public PdfPTable createMarketTenderNegFormulaTable() { final double totTenderNegMarketPer = calculateMarketRate(); final PdfPTable marketTenderNegFormulaTable = new PdfPTable(2); marketTenderNegFormulaTable.getDefaultCell().setBorderWidth(1); marketTenderNegFormulaTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); marketTenderNegFormulaTable.getDefaultCell().setColspan(2); String formated_perc = null;/* w ww .j a va2 s . c o m*/ formated_perc = nf.format(totTenderNegMarketPer); marketTenderNegFormulaTable.addCell( makePara((totTenderNegMarketPer > 0 ? POSITIVE_SIGN : NEGATIVE_SIGN) + formated_perc + "%")); return marketTenderNegFormulaTable; }
From source file:org.egov.works.web.actions.tender.TenderNegotiationPDFGenerator.java
License:Open Source License
public PdfPTable createMarketTenderNegTable() { final double totTenderNegMarketPer = calculateMarketRate(); final PdfPTable marketTenderNegQuotedTable = new PdfPTable(2); marketTenderNegQuotedTable.getDefaultCell().setBorderWidth(1); marketTenderNegQuotedTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); marketTenderNegQuotedTable.getDefaultCell().setColspan(2); String perc_amt = null;/*from ww w.ja v a 2 s. co m*/ if (totTenderNegMarketPer >= 0) perc_amt = formatter .format(totalMarketRateAmt + totalMarketRateAmt * (Math.abs(totTenderNegMarketPer) / 100)); else perc_amt = formatter .format(totalMarketRateAmt - totalMarketRateAmt * (Math.abs(totTenderNegMarketPer) / 100)); marketTenderNegQuotedTable.addCell(makePara(perc_amt)); return marketTenderNegQuotedTable; }
From source file:org.esa.nest.dat.reports.PDFFormat.java
License:Open Source License
private void allign(Document document) throws DocumentException { // Left//www. ja v a2s . c o m Paragraph paragraph = new Paragraph("This is right aligned text"); paragraph.setAlignment(Element.ALIGN_RIGHT); document.add(paragraph); // Centered paragraph = new Paragraph("This is centered text"); paragraph.setAlignment(Element.ALIGN_CENTER); document.add(paragraph); // Left paragraph = new Paragraph("This is left aligned text"); paragraph.setAlignment(Element.ALIGN_LEFT); document.add(paragraph); // Left with indentation paragraph = new Paragraph("This is left aligned text with indentation"); paragraph.setAlignment(Element.ALIGN_LEFT); paragraph.setIndentationLeft(50); document.add(paragraph); }
From source file:org.flightgear.clgen.backend.PdfVisitor.java
License:Open Source License
@Override public void enter(final Check check) { try {// w ww. ja v a 2s . c om String i = check.getItem() != null ? nvl(check.getItem().getName()) : ""; String s = check.getState() != null ? nvl(check.getState().getName()) : ""; String line = String.format("%s %s %s", i, dots(i, s, normalTextWidth() - 2), s); Paragraph p = new Paragraph(line, empty(s) ? B : P); p.setSpacingBefore(6.0f); document.add(p); for (String value : check.getAdditionalValues()) { p = new Paragraph(value, P); p.setSpacingBefore(6.0f); p.setAlignment(Element.ALIGN_RIGHT); document.add(p); } } catch (DocumentException e) { document.close(); throw new GeneratorException(e); } }
From source file:org.jaffa.modules.printing.services.FormPrintEngineIText.java
License:Open Source License
/** * Process the template and do the following * <ol>// w w w .j a va 2 s. c o m * <li>Throw errors if there is something wrong with the template (in getTemplateName()) * <li>Determine to the total number of pages in the template * (The template should have at least one page) * <li>Populate an array where each template page should have one entry in it. * Each entry will a PageDetails object, containing a list of fields * on the page, and a list of repeating entities. * </ol> * On return from this the engine will calculate the total no of template pages, * and the unique list of reappearing group names * @throws FormPrintException Thrown if there is an error parsing the template pdf * @return This returns a List of PageDetails objects which contain data about * each page. It is assumed that the size of the list indicated the * number of pages in the template document being used */ protected List parseTemplatePages() throws FormPrintException { log.debug("parseTemplatePages:"); try { m_templateReader = new PdfReader(getTemplateName()); } catch (IOException e) { log.error("Error opening template - " + e.getMessage(), e); throw new EngineProcessingException("Error opening template - " + e.getMessage()); } // we retrieve the total number of pages int templatePages = m_templateReader.getNumberOfPages(); if (templatePages < 1) throw new EngineProcessingException("Template Document has no pages!"); if (log.isDebugEnabled()) log.debug("Template '" + getTemplateName() + "' has " + templatePages + " page(s)"); // Create Empty array of page data ArrayList pageData = new ArrayList(); for (int templatePage = 0; templatePage < templatePages; templatePage++) { PageDetailsExtended page = new PageDetailsExtended(); pageData.add(page); } // Look for a related data file... File data = new File(getTemplateName() + ".csv"); if (!data.exists()) { log.warn("CSV Parse Error: No data file found for field layout"); } else { // Read the file, and populate PageDetailsExtended try (BufferedReader in = new BufferedReader(new FileReader(data))) { String line; int[] colOrder = null; int row = 0; while ((line = in.readLine()) != null) { row++; if (line.startsWith("#") || line.length() == 0) // ignore commented out or blank lines. continue; String[] cols = line.split(","); if (row == 1) { // Must be first line, analyse column names.... colOrder = new int[cols.length]; for (int i = 0; i < cols.length; i++) { String col = cols[i]; colOrder[i] = HEADINGS.indexOf(col); if (colOrder[i] == -1) { log.error("CSV Parse Error: Unknown column heading '" + col + "' in column " + (i + 1) + ". Can't Process File"); throw new EngineProcessingException( "Can't read layout data file, column headings incorrect"); } } } else { // This is a row of data, process it int pageNo = 0; String field = null; FormPrintEngineIText.FieldProperties props = new FormPrintEngineIText.FieldProperties(); for (int i = 0; i < cols.length; i++) { try { if (cols[i] != null && cols[i].trim().length() > 0 && colOrder != null) { String value = cols[i].trim(); switch (colOrder[i]) { case COLUMN_PAGE: pageNo = Integer.parseInt(value); break; case COLUMN_FIELD: field = value; break; case COLUMN_X1: props.x1 = Float.parseFloat(value); break; case COLUMN_Y1: props.y1 = Float.parseFloat(value); break; case COLUMN_X2: props.x2 = Float.parseFloat(value); break; case COLUMN_Y2: props.y2 = Float.parseFloat(value); break; case COLUMN_FONT: props.fontFace = value; break; case COLUMN_SIZE: props.fontSize = Float.parseFloat(value); break; case COLUMN_ALIGN: if ("center".equalsIgnoreCase(value)) { props.align = Element.ALIGN_CENTER; } else if ("right".equalsIgnoreCase(value)) { props.align = Element.ALIGN_RIGHT; } break; case COLUMN_MULTILINE: props.multiLine = Boolean.valueOf(value).booleanValue(); break; case COLUMN_FIT_METHOD: if (FIT_METHODS.contains(value.toLowerCase())) props.fitMethod = FIT_METHODS.indexOf(value.toLowerCase()); break; case COLUMN_ROTATE: props.rotate = Float.parseFloat(value); break; case COLUMN_STYLE: props.style = value; break; case COLUMN_COLOR: props.color = value; break; case COLUMN_BACKGROUND: props.background = value; break; case COLUMN_SAMPLE_DATA: props.sampleData = URLDecoder.decode(value, "UTF-8"); break; case COLUMN_OPACITY: props.opacity = Float.parseFloat(value); break; } // switch } } catch (NumberFormatException ne) { String err = "CSV Parse Error: Invalid Numeric Value in Form Layout Data. Row=" + row + ", Column=" + i + ", Value='" + cols[i] + "'"; log.error(err); throw new EngineProcessingException(err); } } // for if (pageNo < 1 || pageNo > templatePages) { String err = "CSV Parse Error: Invalid Page Number " + pageNo + " on row " + row; log.error(err); throw new EngineProcessingException(err); } if (field == null) { String err = "CSV Parse Error: Invalid/Missing Field Name on row " + row; log.error(err); throw new EngineProcessingException(err); } PageDetailsExtended page = (PageDetailsExtended) pageData.get(pageNo - 1); page.fieldList.add(field); page.fieldProperties.put(field, props); } } // while loop on each input line } catch (IOException e) { log.warn("CSV Parse Error: Failed to read layout data file", e); } } return pageData; }
From source file:org.jaffa.modules.printing.services.FormPrintEngineIText.java
License:Open Source License
/** * This will fill in the page with data, * m_currentPageData contains the details of the current page being printed * @throws FormPrintException Thrown if there is any form processing problems *//* w w w . j av a2s .c om*/ protected void fillPageFields() throws FormPrintException { log.debug("fillPageFields: Page=" + getCurrentPage()); try { PdfContentByte cb = m_writer.getDirectContent(); PageDetailsExtended page = (PageDetailsExtended) getCurrentPageData(); // // Test code to throw a barcode on the page... // Barcode39 code39 = new Barcode39(); // code39.setCode("CODE39-1234567890"); // code39.setStartStopText(false); // code39.setSize(0); // Image image39 = code39.createImageWithBarcode(cb, null, null); // com.lowagie.text.pdf.PdfPTable table = new com.lowagie.text.pdf.PdfPTable(2); // table.setWidthPercentage(100); // table.getDefaultCell().setBorder(com.lowagie.text.Rectangle.NO_BORDER); // table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); // table.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE); // table.getDefaultCell().setFixedHeight(70); // table.addCell("CODE 39"); // table.addCell(new Phrase(new Chunk(image39, 0, 0))); // m_generatedDoc.add(table); // //-------------------------------------------------- // Loop through each field to be inserted for (Iterator i = page.fieldList.iterator(); i.hasNext();) { String fieldname = (String) i.next(); // Get the properties for displaying this field FieldProperties props = (FieldProperties) page.fieldProperties.get(fieldname); // Get the data to display FormPrintEngine.DomValue data = new FormPrintEngine.DomValue(fieldname, props.sampleData); // Caluclate Clipping Region float x1 = Math.min(props.x1, props.x2); float x2 = Math.max(props.x1, props.x2); float y1 = Math.min(props.y1, props.y2); float y2 = Math.max(props.y1, props.y2); float w = Math.abs(props.x1 - props.x2) + 1; float h = Math.abs(props.y1 - props.y2) + 1; if (log.isDebugEnabled()) log.debug("Print Field " + fieldname + "=" + data.getObject() + " @ [(" + x1 + "," + y1 + ")->(" + x2 + "," + y2 + ")]"); // Default the font if not specified String font = BaseFont.HELVETICA; if (props.fontFace != null) font = props.fontFace; // Handle Barcodes diffently withing iText, don't just use fonts if (font.startsWith("Barcode")) { String bcClassName = "com.lowagie.text.pdf." + font; Object bcode = null; String dataStr = data.getValue(); if (dataStr != null) { log.debug("Barcode Data String = " + dataStr); // Try and create the correct Barcode Object try { Class bcClass = Class.forName(bcClassName); bcode = bcClass.newInstance(); } catch (Exception e) { String err = "Can't Create Barcode Object for barcode type '" + font + "' on field " + fieldname; log.error(err, e); } // Only continue if the barcode object was created if (bcode != null) { // Generate and Print barcode, based on common interface if (bcode instanceof Barcode) { Barcode b = (Barcode) bcode; // Set some default output a barcode b.setCode(dataStr); if (props.fontSize <= 0) { // Hide text if font size is 0, and make the barcode height the size of the box b.setBarHeight(h); b.setFont(null); } else { b.setSize(props.fontSize); // size of text under barcode b.setBarHeight(h - props.fontSize - 5); // Adjust Bar Height to allow for font size } b.setN(2); // Wide Bars // Set custom parameters setBarcodeParams(fieldname, bcode, props.style); // Print out barcode Image image = ((Barcode) bcode).createImageWithBarcode(cb, null, null); printImage(image, cb, x1, y1, x2, y2, props.align, props.fitMethod, props.rotate); } else // Print PDF417 barcode, not based on common interface if (bcode instanceof BarcodePDF417) { BarcodePDF417 b = (BarcodePDF417) bcode; // Set some default output a barcode b.setText(dataStr); b.setErrorLevel(5); // Set custom parameters setBarcodeParams(fieldname, bcode, props.style); log.debug("PDF417 Settings\n" + "BitColumns=" + b.getBitColumns() + "\n" + "CodeColumns=" + b.getCodeColumns() + "\n" + "CodeRows=" + b.getCodeRows() + "\n" + "ErrorLevel=" + b.getErrorLevel() + "\n" + "YHeight=" + b.getYHeight() + "\n" + "AspectRatio=" + b.getAspectRatio() + "\n" + "Options=" + b.getOptions() + "\n" + "LenCodewords=" + b.getLenCodewords()); // Print out barcode //image = b.getImage(); printImage(b.getImage(), cb, x1, y1, x2, y2, props.align, props.fitMethod, props.rotate); } else { // Error, unknown barcode String err = "Error, No print handler for barcode object " + bcode.getClass().getName(); log.error(err); //throw new EngineProcessingException(err); } } } else log.debug("SKIPPED BARCODE : No data for " + fieldname); // Handle Images differently within iText, native support for JFreeChart } else if ("image".equalsIgnoreCase(font)) { try { java.awt.Image image = data.getDomImage(); // Add an image to the page if (image != null) { if (fieldname.startsWith("watermark")) { // Add an image-based watermark to the under content layer PdfContentByte contentUnder = m_writer.getDirectContentUnder(); if (props.opacity != 1f) { PdfGState gs = new PdfGState(); gs.setFillOpacity(props.opacity); contentUnder.setGState(gs); } printImage(image, contentUnder, x1, y1, x2, y2, props.align, props.fitMethod, props.rotate); } else { // Add an image to main page layer printImage(image, cb, x1, y1, x2, y2, props.align, props.fitMethod, props.rotate); } } } catch (IOException e) { // Add Error on page. Phrase text = new Phrase("Image Error", FontFactory .getFont(FontFactory.HELVETICA_BOLDOBLIQUE, 8f, 0, ColorHelper.getColor("red"))); ColumnText ct = new ColumnText(cb); ct.setSimpleColumn(text, x1, y1, x2, y2, 8f, Element.ALIGN_LEFT); } } else if (fieldname.startsWith("watermark")) { // Add a text-based watermark String text = data.getValue(); PdfContentByte contentUnder = m_writer.getDirectContentUnder(); if (props.opacity != 1f) { PdfGState gs = new PdfGState(); gs.setFillOpacity(props.opacity); contentUnder.setGState(gs); } // The text aligns (left, center, right) on the pivot point. // Default to align left. float pivotX = x1; float pivotY = y1; if (Element.ALIGN_CENTER == props.align) { pivotX = (x1 / 2) + (x2 / 2); pivotY = y1; } else if (Element.ALIGN_RIGHT == props.align) { pivotX = x2; pivotY = y1; } Phrase watermark = new Phrase(text, FontFactory.getFont(props.fontFace, props.fontSize, decodeFontStyle(props.style), ColorHelper.getColor(defaultWatermarkColor))); ColumnText.showTextAligned(contentUnder, props.align, watermark, pivotX, pivotY, props.rotate); } else { // Handle printing of basic Text float lineHeight = props.fontSize; String str = data.getValue(); if (str != null) { // Add a bounded column to add text to. Phrase text = new Phrase(str, FontFactory.getFont(props.fontFace, props.fontSize, decodeFontStyle(props.style), ColorHelper.getColor(props.color))); ColumnText ct = new ColumnText(cb); if (props.fitMethod == FIT_METHOD_CLIP) // set up column with height/width restrictions ct.setSimpleColumn(text, x1, y1, x2, y2, lineHeight, props.align); else // set up column without (i.e. large) height/width restrictions ct.setSimpleColumn(text, x1, y1, 1000, 0, lineHeight, props.align); ct.go(); } } // Draw outline boxes arround fields if (isTemplateMode()) { cb.setLineWidth(0.5f); cb.setLineDash(4f, 2f); cb.setColorStroke(new Color(0xA0, 0xA0, 0xA0)); cb.moveTo(x1, y1); cb.lineTo(x1, y2); cb.lineTo(x2, y2); cb.lineTo(x2, y1); cb.lineTo(x1, y1); cb.stroke(); } } // end for-loop } catch (DocumentException e) { String err = "Error printing data - " + e.getMessage(); log.error(err, e); throw new EngineProcessingException(err); // } catch (IOException e) { // String err = "Error printing data - " + e.getMessage(); // log.error(err ,e); // throw new EngineProcessingException(err); } }
From source file:org.jpedal.examples.simpleviewer.utils.ItextFunctions.java
License:Open Source License
public void addHeaderFooter(int pageCount, PdfPageData currentPageData, final AddHeaderFooterToPDFPages addHeaderFooter) { File tempFile = null;//from w w w .jav a 2s . c o m try { tempFile = File.createTempFile("temp", null); ObjectStore.copy(selectedFile, tempFile.getAbsolutePath()); } catch (Exception e) { return; } try { int[] pgsToEdit = addHeaderFooter.getPages(); if (pgsToEdit == null) return; List pagesToEdit = new ArrayList(); for (int i = 0; i < pgsToEdit.length; i++) pagesToEdit.add(new Integer(pgsToEdit[i])); final PdfReader reader = new PdfReader(tempFile.getAbsolutePath()); PdfStamper stamp = new PdfStamper(reader, new FileOutputStream(selectedFile)); String chosenFont = addHeaderFooter.getFontName(); Color chosenFontColor = addHeaderFooter.getFontColor(); int chosenFontSize = addHeaderFooter.getFontSize(); float chosenLeftRightMargin = addHeaderFooter.getLeftRightMargin(); float chosenTopBottomMargin = addHeaderFooter.getTopBottomMargin(); String text[] = new String[6]; text[0] = addHeaderFooter.getLeftHeader(); text[1] = addHeaderFooter.getCenterHeader(); text[2] = addHeaderFooter.getRightHeader(); text[3] = addHeaderFooter.getLeftFooter(); text[4] = addHeaderFooter.getCenterFooter(); text[5] = addHeaderFooter.getRightFooter(); Date date = new Date(); String shortDate = DateFormat.getDateInstance(DateFormat.SHORT).format(date); String longDate = DateFormat.getDateInstance(DateFormat.LONG).format(date); SimpleDateFormat formatter = new SimpleDateFormat("hh:mm:ss a"); String time12 = formatter.format(date); formatter = new SimpleDateFormat("HH.mm.ss"); String time24 = formatter.format(date); String fileName = new File(selectedFile).getName(); BaseFont font = BaseFont.createFont(chosenFont, BaseFont.WINANSI, false); for (int page = 1; page <= pageCount; page++) { if (pagesToEdit.contains(new Integer(page))) { String[] textCopy = new String[text.length]; System.arraycopy(text, 0, textCopy, 0, text.length); for (int i = 0; i < 6; i++) { textCopy[i] = textCopy[i].replaceAll("<d>", shortDate); textCopy[i] = textCopy[i].replaceAll("<D>", longDate); textCopy[i] = textCopy[i].replaceAll("<t>", time12); textCopy[i] = textCopy[i].replaceAll("<T>", time24); textCopy[i] = textCopy[i].replaceAll("<f>", fileName); textCopy[i] = textCopy[i].replaceAll("<F>", selectedFile); textCopy[i] = textCopy[i].replaceAll("<p>", "" + page); textCopy[i] = textCopy[i].replaceAll("<P>", "" + pageCount); } PdfContentByte cb = stamp.getOverContent(page); cb.beginText(); cb.setColorFill(chosenFontColor); cb.setFontAndSize(font, chosenFontSize); Rectangle pageSize = reader.getPageSizeWithRotation(page); cb.showTextAligned(Element.ALIGN_LEFT, textCopy[0], chosenLeftRightMargin, pageSize.height() - chosenTopBottomMargin, 0); cb.showTextAligned(Element.ALIGN_CENTER, textCopy[1], pageSize.width() / 2, pageSize.height() - chosenTopBottomMargin, 0); cb.showTextAligned(Element.ALIGN_RIGHT, textCopy[2], pageSize.width() - chosenLeftRightMargin, pageSize.height() - chosenTopBottomMargin, 0); cb.showTextAligned(Element.ALIGN_LEFT, textCopy[3], chosenLeftRightMargin, chosenTopBottomMargin, 0); cb.showTextAligned(Element.ALIGN_CENTER, textCopy[4], pageSize.width() / 2, chosenTopBottomMargin, 0); cb.showTextAligned(Element.ALIGN_RIGHT, textCopy[5], pageSize.width() - chosenLeftRightMargin, chosenTopBottomMargin, 0); cb.endText(); } } stamp.close(); } catch (Exception e) { ObjectStore.copy(tempFile.getAbsolutePath(), selectedFile); e.printStackTrace(); } finally { tempFile.delete(); } }