List of usage examples for com.itextpdf.text Image scalePercent
public void scalePercent(final float percent)
From source file:ImagetoPDF.java
public void convertToPDF(String folderName, String fileName, float compressionFactor) throws DocumentException, FileNotFoundException, BadElementException, IOException { File folder = new File(folderName); File[] listOfFiles = folder.listFiles(); Image img = Image.getInstance(listOfFiles[0].getAbsolutePath()); float width, height, temp; width = img.getWidth();//from w ww .j a va2 s. c o m height = img.getHeight(); if (height < width) { temp = height; height = width; width = height; } Rectangle pageSize = new Rectangle(width, height); Document document = new Document(pageSize, 0, 0, 0, 0); for (int i = 0; i < listOfFiles.length; i++) { enhance(listOfFiles[i].getAbsolutePath()); } float scalar; PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(fileName)); writer.open(); writer.setCompressionLevel(5); document.open(); for (int i = 0; i < listOfFiles.length; i++) { img = Image.getInstance(listOfFiles[i].getAbsolutePath()); if (img.getWidth() > img.getHeight()) { img.setRotationDegrees(270f); } scalar = ((document.getPageSize().getWidth() - document.leftMargin() - document.rightMargin() - 0) / img.getWidth()) * 100; img.scalePercent(scalar); document.add(img); } document.close(); writer.close(); }
From source file:com.atacadao.almoxarifado.model.GerandoPDF.java
public void pdfImpressaoBarraDeCodigo(String codigo) { Document documento = new Document(new Rectangle(90, 65)); documento.setMargins(0, 0, 0, 0);// w ww. ja va2 s. c om PdfWriter pdf; try { pdf = PdfWriter.getInstance(documento, new FileOutputStream("codigodebarras.pdf")); documento.open(); PdfContentByte contB = pdf.getDirectContent(); Barcode128 barCode = new Barcode128(); barCode.setCode(codigo); barCode.setCodeType(Barcode128.CODE128); Image image = barCode.createImageWithBarcode(contB, BaseColor.BLACK, BaseColor.BLACK); Paragraph titulo = new Paragraph("ATCADO DOS PISOS\n", new com.itextpdf.text.Font(com.itextpdf.text.Font.FontFamily.HELVETICA, 5)); titulo.setPaddingTop(0); titulo.setAlignment(Element.ALIGN_CENTER); float scaler = ((documento.getPageSize().getWidth() - documento.leftMargin() - documento.rightMargin() - 0) / image.getWidth()) * 60; image.scalePercent(scaler); image.setPaddingTop(0); image.setAlignment(Element.ALIGN_CENTER); documento.add(titulo); documento.add(image); documento.close(); Desktop.getDesktop().open(new File("codigodebarras.pdf")); } catch (DocumentException | FileNotFoundException ex) { Logger.getLogger(GerandoPDF.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(GerandoPDF.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.example.admin.avoidq.billGenerated.java
private void generatePDF(final String personName) { new Thread(new Runnable() { public void run() { // a potentially time consuming task //create a new document Document document = new Document(); try { PdfWriter docWriter = PdfWriter.getInstance(document, new FileOutputStream(pdfFile)); document.open();// w ww . j av a2 s . c om PdfContentByte cb = docWriter.getDirectContent(); //initialize fonts for text printing initializeFonts(); //the company logo is stored in the assets which is read only //get the logo and print on the document /* try { bitmap11 = encodeAsBitmap(barcode_data, BarcodeFormat.CODE_128, 600, 300); iv.setImageBitmap(bitmap11); } catch (WriterException e) { e.printStackTrace(); } * */ InputStream inputStream = getAssets().open("sale.png"); Bitmap bmp = null;//BitmapFactory.decodeStream(inputStream); bmp = bitmap11; ByteArrayOutputStream stream = new ByteArrayOutputStream(); bmp.compress(Bitmap.CompressFormat.PNG, 100, stream); Image companyLogo = Image.getInstance(stream.toByteArray()); companyLogo.setAbsolutePosition(25, 700); companyLogo.scalePercent(65); document.add(companyLogo); Calendar calendar = Calendar.getInstance(); SimpleDateFormat df1 = new SimpleDateFormat("dd-MM-yyyy"); String formattedDate = df1.format(calendar.getTime()); //creating a sample invoice with some customer data createHeadings(cb, 400, 780, "Date :"); createHeadings(cb, 430, 780, formattedDate); String fname = customer.getName(); String lname = customer.getSurname(); createHeadings(cb, 400, 765, "Customer :"); createHeadings(cb, 445, 765, fname + " " + lname); String mob = customer.getMobile_no(); createHeadings(cb, 400, 750, "Mobile No :"); createHeadings(cb, 445, 750, mob); createHeadings(cb, 400, 735, "Shop :"); createHeadings(cb, 430, 735, "Empress Mall"); createHeadings(cb, 400, 720, "City :"); createHeadings(cb, 430, 720, "Nagpur"); // createHeadings(cb,400,720,"Country"); //list all the products sold to the customer float[] columnWidths = { 1.5f, 3f, 2.5f, 2.5f, 2f, 2f }; //create PDF table with the given widths PdfPTable table = new PdfPTable(columnWidths); // set table width a percentage of the page width table.setTotalWidth(500f); PdfPCell cell = new PdfPCell(new Phrase("S.NO")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); cell = new PdfPCell(new Phrase("Item Name")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); cell = new PdfPCell(new Phrase("Price")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); cell = new PdfPCell(new Phrase("Quantity")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); cell = new PdfPCell(new Phrase("Discount")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); cell = new PdfPCell(new Phrase("Amount")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); table.setHeaderRows(1); /*DecimalFormat df = new DecimalFormat("0.000"); for(int i=0; i < 10; i++ ){ double price = Double.valueOf(df.format(Math.random() * 10)); double extPrice = price * (i+1) ; table.addCell(String.valueOf(i+1)); table.addCell("ITEM" + String.valueOf(i+1)); table.addCell(String.valueOf(5*i)); table.addCell(String.valueOf(1)); table.addCell(String.valueOf(i)+ " %"); table.addCell(df.format(extPrice)); }*/ int sr = 0; DecimalFormat df = new DecimalFormat("0.0"); double total_price = 0; //Log.i("c0","c0 = "+carts[0].getItemname()+" "+String.valueOf(carts[0].getPrice())); // Log.i("c1","c1 = "+carts[1].getItemname()+" "+String.valueOf(carts[1].getPrice())); for (Cart cd : carts) { Log.i("cartscheck", "carts check = " + cd.getBarcode() + " " + cd.getItemname() + " " + String.valueOf(cd.getPrice())); } for (Cart c : carts) { double price = c.getPrice(); int quantity = c.getQuantity(); price = (price / quantity); double discont = c.getDiscount(); sr++; table.addCell(String.valueOf(sr)); table.addCell(c.getItemname()); table.addCell(df.format(price)); table.addCell(String.valueOf(quantity)); table.addCell(df.format(discont) + " %"); double total = (price * quantity); total_price = total_price + total; Log.i("total", "total in for loop = " + String.valueOf(total)); table.addCell(df.format(total)); } float headerHeight = table.getHeaderHeight(); Log.i("headerHeight", String.valueOf(headerHeight)); //absolute location to print the PDF table from table.writeSelectedRows(0, -1, document.leftMargin(), 650, docWriter.getDirectContent()); float total_height = table.getTotalHeight(); Log.i("total_height", String.valueOf(total_height)); createHeadings(cb, 420, 750f - 125f - total_height, "Total Price = "); createHeadings(cb, 475, 750f - 125f - total_height, String.valueOf(total_price)); //print the signature image along with the persons name inputStream = getAssets().open("user.png"); bmp = BitmapFactory.decodeStream(inputStream); stream = new ByteArrayOutputStream(); bmp.compress(Bitmap.CompressFormat.PNG, 100, stream); Image signature = Image.getInstance(stream.toByteArray()); signature.setAbsolutePosition(400f, 750f - 125f - total_height - 60f); signature.scalePercent(35f); document.add(signature); createHeadings(cb, 450, 750f - 125f - total_height - 80f, fname + " " + lname); document.close(); } catch (Exception e) { e.printStackTrace(); } //PDF file is now ready to be sent to the bluetooth printer using PrintShare Intent i = new Intent(Intent.ACTION_VIEW); // i.setPackage("com.dynamixsoftware.printershare"); i.setDataAndType(Uri.fromFile(pdfFile), "application/pdf"); startActivity(i); } }).start(); }
From source file:com.gp.cong.logisoft.lcl.report.LclAllBLPdfCreator.java
public PdfPTable commodityValues() throws DocumentException, ParseException, Exception { Paragraph p = null;/*from w w w. j a v a2 s . c om*/ table = new PdfPTable(2); table.setWidthPercentage(100f); table.setWidths(new float[] { 5f, 3.2f }); cell = new PdfPCell(); cell.setBorder(2); cell.setBorderWidthTop(0.6f); cell.setBorderWidthRight(0.6f); cell.setBorderWidthBottom(0f); if (isFirst_page) { cell.addElement(appendChargesAndCommodity()); isFirst_page = false; } else { cell.setFixedHeight(100f); } table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); cell.setBorderWidthTop(0.6f); cell.addElement(appendDescComments()); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); PdfPTable fileAndLogo = new PdfPTable(2); fileAndLogo.setWidthPercentage(100f); fileAndLogo.setWidths(new float[] { 4f, 2f }); PdfPCell file = new PdfPCell(); file.setBorder(0); String blNumbering = new LCLBlDAO().getExportBlNumbering(lclbl.getLclFileNumber().getId().toString()); p = new Paragraph(16f, "B/L# " + blNumbering, blackBoldFont14); file.setPaddingTop(-6f); file.addElement(p); fileAndLogo.addCell(file); String companyLogo = LoadLogisoftProperties.getProperty( "ECU".equalsIgnoreCase(ruleName) ? "application.image.logo" : "application.image.econo.logo"); Image img = Image.getInstance(servletPath + companyLogo); img.scalePercent(25); file = new PdfPCell(img); file.setBorder(0); file.setBorder(Rectangle.NO_BORDER); file.setHorizontalAlignment(Element.ALIGN_LEFT); file.setVerticalAlignment(Element.ALIGN_LEFT); file.setBorder(0); fileAndLogo.addCell(file); cell.addElement(fileAndLogo); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); table.addCell(cell); return table; }
From source file:com.gp.cong.logisoft.lcl.report.LclAllBLPdfCreator.java
public PdfPTable companyLogo(String realPath) throws Exception { String path = LoadLogisoftProperties.getProperty("application.image.logo"); table = new PdfPTable(1); table.setWidthPercentage(100f);/*from ww w.ja v a 2 s . c o m*/ Image img = Image.getInstance(realPath + path); img.scalePercent(75); PdfPCell logoCell = new PdfPCell(img); logoCell.setBorder(Rectangle.NO_BORDER); logoCell.setHorizontalAlignment(Element.ALIGN_LEFT); logoCell.setVerticalAlignment(Element.ALIGN_LEFT); logoCell.setBorder(0); logoCell.setPaddingLeft(50); table.addCell(logoCell); return table; }
From source file:com.gp.cong.logisoft.lcl.report.LclVoyageNotificationPdfCreator.java
public PdfPTable onStartPage(String realPath, String scheduleNo, String unitNo, String voyContent) throws Exception { String path = LoadLogisoftProperties.getProperty("application.image.logo"); Font fontArialBold = FontFactory.getFont("Arial", 10f, Font.BOLD); Font colorBoldFont = FontFactory.getFont("Arial", 12f, Font.BOLD, new BaseColor(00, 102, 00)); Phrase p = null;//from ww w . j a va 2s . c o m Paragraph pValues = null; table = new PdfPTable(6); table.setWidths(new float[] { 0.1f, 1.8f, 2.5f, 3.5f, 1.8f, 1.8f }); table.setWidthPercentage(100f); cell = new PdfPCell(); cell.setBorder(0); cell.setPadding(0f); cell.setRowspan(3); table.addCell(cell); cell = new PdfPCell(); cell.setPadding(0f); cell.setBorder(0); cell.setPaddingBottom(3f); p = new Phrase("", fontArialBold); p.setLeading(20f); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); cell.setPadding(0f); cell.setPaddingBottom(3f); pValues = new Paragraph(25f, "", fontArialBold); cell.addElement(pValues); table.addCell(cell); cell = new PdfPCell(); cell.setRowspan(3); cell.setBorder(0); cell.setPadding(0f); Image img = Image.getInstance(realPath + path); img.scalePercent(60); img.setAlignment(Element.ALIGN_CENTER); img.setAlignment(Element.ALIGN_TOP); cell.addElement(img); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); cell.setPadding(0f); cell.setPaddingBottom(3f); pValues = new Paragraph(20f, "Date:", fontArialBold); pValues.setAlignment(Element.ALIGN_RIGHT); cell.addElement(pValues); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); cell.setPadding(0f); cell.setPaddingBottom(3f); pValues = new Paragraph(20f, " " + DateUtils.formatStringDateToAppFormatMMM(new Date()), fontArialBold); pValues.setAlignment(Element.ALIGN_LEFT); cell.addElement(pValues); table.addCell(cell); cell = new PdfPCell(); cell.setPadding(0f); cell.setBorder(0); cell.setPaddingBottom(3f); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); cell.setPaddingBottom(3f); cell.setPadding(0f); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); cell.setPadding(0f); cell.setPaddingBottom(3f); pValues = new Paragraph(9f, "Time:", fontArialBold); pValues.setAlignment(Element.ALIGN_RIGHT); cell.addElement(pValues); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); cell.setPadding(0f); cell.setPaddingBottom(3f); pValues = new Paragraph(9f, " " + DateUtils.formatStringDateToTimeTT(new Date()), fontArialBold); pValues.setAlignment(Element.ALIGN_LEFT); cell.addElement(pValues); table.addCell(cell); cell = new PdfPCell(); cell.setColspan(2); cell.setBorder(0); cell.setPadding(0f); cell.setPaddingBottom(3f); table.addCell(cell); cell = new PdfPCell(); cell.setColspan(2); cell.setBorder(0); cell.setPaddingBottom(3f); table.addCell(cell); //voyage cell = new PdfPCell(); cell.setBorder(0); cell.setColspan(3); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); cell.setPaddingLeft(5f); pValues = new Paragraph(8f, "VOYAGE NOTIFICATION", colorBoldFont); pValues.setAlignment(Element.ALIGN_CENTER); cell.addElement(pValues); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); cell.setColspan(2); table.addCell(cell); return table; }
From source file:com.gp.cong.logisoft.reports.DeliveryOrderPdfCreator.java
public PdfPTable lineTable(FclBl bl, String deliveryDate, String realPath) throws Exception { PdfPCell cell = new PdfPCell(); PdfPCell celL = new PdfPCell(); String path = LoadLogisoftProperties.getProperty("application.image.logo"); String econoPath = LoadLogisoftProperties.getProperty("application.image.econo.logo"); String companyCode = new SystemRulesDAO().getSystemRulesByCode("CompanyCode"); PdfPTable table = new PdfPTable(4); table.setWidthPercentage(100);/*from www . j a v a2s.co m*/ Paragraph p = null; cell = new PdfPCell(); cell.setColspan(4); cell.setBorder(0); if (null != bl && bl.getBrand().equalsIgnoreCase("Econo") && ("03").equals(companyCode)) { Image img = Image.getInstance(realPath + econoPath); img.setAlignment(Element.ALIGN_CENTER); img.scalePercent(60); img.setAlignment(Element.ALIGN_TOP); cell.addElement(img); } else if (null != bl && bl.getBrand().equalsIgnoreCase("OTI") && ("02").equals(companyCode)) { Image img = Image.getInstance(realPath + econoPath); img.setAlignment(Element.ALIGN_CENTER); img.scalePercent(60); img.setAlignment(Element.ALIGN_TOP); cell.addElement(img); } else if (null != bl && bl.getBrand().equalsIgnoreCase("Ecu Worldwide")) { Image img = Image.getInstance(realPath + path); img.setAlignment(Element.ALIGN_CENTER); img.scalePercent(60); img.setAlignment(Element.ALIGN_TOP); cell.addElement(img); } table.addCell(cell); cell = new PdfPCell(); cell.setColspan(4); cell.setBorder(0); p = new Paragraph("DELIVERY ORDER", blackBoldFontheading); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setColspan(4); cell.setBorder(0); p = new Paragraph("DATE PRINTED : " + DateUtils.formatStringDateToAppFormatMMM(new Date()), blackFontForAR); p.setAlignment(Element.ALIGN_RIGHT); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorderWidthBottom(0f); p = new Paragraph(8f, "CONSIGNEE NAME", blackFontForAR); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); table.addCell(cell); cell = new PdfPCell(); cell.setBorderWidthBottom(0f); p = new Paragraph(8f, "DATE:", blackFontForAR); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorderWidthBottom(0f); p = new Paragraph(8f, "REF:", blackFontForAR); cell.addElement(p); table.addCell(cell); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(CommonUtils.isNotEmpty(bl.getConsigneeName()) ? bl.getConsigneeName() : ""); stringBuilder.append("\n"); stringBuilder.append(CommonUtils.isNotEmpty(bl.getConsigneeAddress()) ? bl.getConsigneeAddress() : ""); cell = new PdfPCell(); cell.setRowspan(2); cell.setBorderWidthTop(0f); p = new Paragraph(8f, stringBuilder.toString(), blackFont); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); table.addCell(cell); cell = new PdfPCell(); cell.setBorderWidthTop(0f); p = new Paragraph(8f, deliveryDate, blackFont); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorderWidthTop(0f); p = new Paragraph(8f, "04-" + bl.getFileNo(), blackFont); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); cell.setColspan(2); p = new Paragraph(8f, "THE MERCHANDISE DESCRIBED BELOW WILL BE ENTERED AND FORWARDED AS FOLLOWS:", blackFontForAR); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); table.addCell(cell); return table; }
From source file:com.gp.cong.logisoft.reports.LclExportVoyageNotificationPdf.java
public PdfPTable imageBlock(String realPath, String path) throws IOException, BadElementException, DocumentException { Font fontArialBold = FontFactory.getFont("Courier", 18f, Font.NORMAL); table = new PdfPTable(1); table.setWidths(new float[] { 5.9f }); table.setWidthPercentage(100f);/*from w w w .j a va 2 s . c om*/ cell = new PdfPCell(); cell.setBorder(0); cell.setPadding(0f); Image img = Image.getInstance(realPath + path); img.scalePercent(90); img.setAlignment(Element.ALIGN_CENTER); cell.addElement(img); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); cell.setPadding(0f); p = new Paragraph(12f, " (866) 326-6648", fontArialBold); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); cell.setPadding(0f); String companyWebsite = new PropertyDAO().getProperty( companyCode.equalsIgnoreCase("03") ? "application.ECU.website" : "application.OTI.website"); p = new Paragraph(28f, " " + companyWebsite, fontArialBold); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); table.addCell(cell); return table; }
From source file:com.ideationdesignservices.txtbook.pdf.TxtBookPdf.java
public Boolean createFrontCoverPage(Document document, String coverTitle, Bitmap photo) throws DocumentException, MalformedURLException, IOException { if (photo != null) { int imageMaxWidth; int imageMaxHeight; int imagePosX; int imagePosY; if (photo.getWidth() < photo.getHeight()) { imageMaxWidth = 900;/*from ww w .j av a 2 s. co m*/ imageMaxHeight = 1200; imagePosX = 198; imagePosY = 379; } else { imageMaxWidth = 1200; imageMaxHeight = 900; imagePosX = 162; imagePosY = 379; } OutputStream stream = new ByteArrayOutputStream(); ImageUtilities.scaleCenterCrop(photo, imageMaxWidth, imageMaxHeight).compress(CompressFormat.JPEG, 50, stream); Image coverImage = Image.getInstance(stream.toByteArray()); coverImage.setAbsolutePosition(0.0f, 0.0f); PdfTemplate t = this.writer.getDirectContent().createTemplate((float) imageMaxWidth, (float) imageMaxHeight); t.newPath(); t.moveTo(0.0f, (float) imageMaxHeight); t.lineTo(0.0f, 71.0f); t.lineTo(17.0f, 71.0f); t.lineTo(17.0f, 0.0f); t.lineTo(72.0f, 71.0f); t.lineTo((float) imageMaxWidth, 71.0f); t.lineTo((float) imageMaxWidth, (float) imageMaxHeight); t.lineTo(0.0f, (float) imageMaxHeight); t.closePath(); t.clip(); t.newPath(); t.addImage(coverImage); t.setColorStroke(new BaseColor(0, 0, 0)); t.setLineWidth(BUBBLE_TEXT_INDENT_ALTERNATE); t.newPath(); t.moveTo(0.0f, (float) imageMaxHeight); t.lineTo(0.0f, 71.0f); t.lineTo(17.0f, 71.0f); t.lineTo(17.0f, 0.0f); t.lineTo(72.0f, 71.0f); t.lineTo((float) imageMaxWidth, 71.0f); t.lineTo((float) imageMaxWidth, (float) imageMaxHeight); t.lineTo(0.0f, (float) imageMaxHeight); t.closePathStroke(); Image clipped = Image.getInstance(t); clipped.scalePercent(24.0f); clipped.setAbsolutePosition((float) imagePosX, (float) imagePosY); clipped.setCompressionLevel(this.settings.compressionLevel); clipped.setAlignment(5); document.add(clipped); } if (coverTitle != null && coverTitle.length() > 0) { PdfContentByte canvas = this.writer.getDirectContent(); Paragraph coverTitleEl = new Paragraph(coverTitle, this.serifFont24); coverTitleEl.setAlignment(1); PdfPTable table = new PdfPTable(1); table.setTotalWidth(311.0f); PdfPCell cell = new PdfPCell(); cell.setBorder(0); cell.addElement(coverTitleEl); cell.setPadding(0.0f); cell.setIndent(0.0f); table.addCell(cell); table.completeRow(); table.writeSelectedRows(0, -1, 147.0f, 390.0f, canvas); } return Boolean.valueOf(true); }
From source file:com.ideationdesignservices.txtbook.pdf.TxtBookPdf.java
public Boolean createBackCoverPage(Document document, String backCoverNote) throws DocumentException, MalformedURLException, IOException { document.newPage();/* ww w . jav a 2s .c o m*/ Image backCoverImageFrame = Image .getInstance(ImageUtilities.getImageDataForFile(this.mContext, "pdf/txtbook_backpage_300.png")); backCoverImageFrame.scalePercent(24.0f); backCoverImageFrame.setAbsolutePosition(87.0f, 78.0f); backCoverImageFrame.setCompressionLevel(this.settings.compressionLevel); document.add(backCoverImageFrame); PdfContentByte canvas = this.writer.getDirectContent(); PdfPTable table = new PdfPTable(1); table.setTotalWidth(215.0f); if (backCoverNote != null && backCoverNote.length() > 0) { Paragraph backCoverEl = new Paragraph(backCoverNote, this.serifFont14); PdfPCell cell = new PdfPCell(); cell.setBorder(0); cell.addElement(backCoverEl); cell.setPadding(13.0f); cell.setIndent(0.0f); cell.setFixedHeight(310.0f); table.addCell(cell); table.completeRow(); } Element backUrl = new Anchor("txt-book.com", this.sansFont11Gray); backUrl.setName("txt-book.com"); backUrl.setReference("http://www.txt-book.com"); Paragraph paragraph = new Paragraph(); paragraph.setAlignment(2); paragraph.add(backUrl); PdfPCell cell2 = new PdfPCell(); cell2.setBorder(0); cell2.setHorizontalAlignment(2); cell2.addElement(paragraph); cell2.setPadding(0.0f); cell2.setPaddingTop(0.0f); cell2.setIndent(0.0f); table.addCell(cell2); table.completeRow(); table.writeSelectedRows(0, -1, 306.0f, 400.0f, canvas); return Boolean.valueOf(true); }