List of usage examples for com.lowagie.text Image TEXTWRAP
int TEXTWRAP
To view the source code for com.lowagie.text Image TEXTWRAP.
Click Source Link
From source file:appli_etudiants.ExportPDF.java
public static void main(Etudiants etudiant) throws SQLException, FileNotFoundException, BadElementException, IOException { try {//from w w w. j a v a 2 s .com Document document = new Document(PageSize.A4); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("c:/tesPDF.pdf")); document.open(); PdfContentByte canvas = writer.getDirectContentUnder(); Image image = Image.getInstance("c:/fond_cv.jpg"); image.setAbsolutePosition(0, 80); canvas.saveState(); PdfGState state = new PdfGState(); state.setFillOpacity(0.6f); canvas.setGState(state); canvas.addImage(image); canvas.restoreState(); LineSeparator lineSepa = new LineSeparator(); lineSepa.setLineColor(new Color(21, 96, 189)); Paragraph para1 = new Paragraph(); Paragraph para2 = new Paragraph(etudiant.getAdresse_rue()); Paragraph para3 = new Paragraph(etudiant.getAdresse_cp() + " " + etudiant.getAdresse_ville()); Paragraph para4 = new Paragraph(etudiant.getCourriel(), FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, new Color(21, 96, 189))); Paragraph para5 = new Paragraph(etudiant.getTel_personnel()); Paragraph para6 = new Paragraph(etudiant.getTel_professionnel()); Paragraph para7 = new Paragraph(etudiant.getSite_web()); para1.add(new Chunk(etudiant.getPrenom(), FontFactory.getFont(FontFactory.HELVETICA, 20, Font.BOLD, new Color(21, 96, 189)))); para1.add( new Chunk(" " + etudiant.getNom(), FontFactory.getFont(FontFactory.HELVETICA, 20, Font.BOLD))); Image image1 = Image.getInstance(DaoS4.getPhoto()); image1.scalePercent(50); image1.setAlignment(Image.RIGHT | Image.TEXTWRAP); image1.scaleAbsolute(94, 94); document.add(image1); document.add(para1); document.add(para2); document.add(para3); document.add(para4); document.add(para5); document.add(para6); para7.setSpacingAfter(25f); document.add(para7); Paragraph para8 = new Paragraph(DaoS4.getLibelleTitre()); para8.setSpacingBefore(25f); para8.setSpacingAfter(20f); document.add(para8); Paragraph para9 = new Paragraph(new Chunk("EXPERIENCE PROFESSIONELLE", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, new Color(21, 96, 189)))); para9.setSpacingBefore(15f); para9.setSpacingAfter(15f); document.add(para9); document.add(lineSepa); Paragraph para10 = new Paragraph(DaoS4.getLibelleExpPro()); para10.setSpacingAfter(15f); document.add(para10); Paragraph para11 = new Paragraph(new Chunk("FORMATION", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, new Color(21, 96, 189)))); para11.setSpacingBefore(15f); para11.setSpacingAfter(15f); document.add(para11); document.add(lineSepa); Paragraph para12 = new Paragraph(DaoS4.getLibelleFormation()); para12.setSpacingAfter(15f); document.add(para12); Paragraph para13 = new Paragraph(new Chunk("INFORMATIQUE", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, new Color(21, 96, 189)))); para13.setSpacingBefore(15f); para13.setSpacingAfter(15f); document.add(para13); document.add(lineSepa); Paragraph para14 = new Paragraph(DaoS4.getLibelleInformatique()); para14.setSpacingAfter(15f); document.add(para14); Paragraph para15 = new Paragraph(new Chunk("LANGUE", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, new Color(21, 96, 189)))); para15.setSpacingBefore(15f); para15.setSpacingAfter(15f); document.add(para15); document.add(lineSepa); Paragraph para16 = new Paragraph(DaoS4.getLibelleLangue()); para16.setSpacingAfter(15f); document.add(para16); Paragraph para17 = new Paragraph(new Chunk("CENTRES D'INTERET", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, new Color(21, 96, 189)))); para17.setSpacingBefore(15f); para17.setSpacingAfter(15f); document.add(para17); document.add(lineSepa); Paragraph para18 = new Paragraph(DaoS4.getLibelleInteret()); para18.setSpacingAfter(15f); document.add(para18); document.close(); } catch (DocumentException ex) { Logger.getLogger(ExportPDF.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.amphisoft.epub2pdf.content.XhtmlHandler.java
License:Open Source License
private void handleImage(String url, String alt, String borderWidth, String alignment) throws DocumentException { float marginTopPt = document.topMargin(); float marginBottomPt = document.bottomMargin(); float marginLeftPt = document.leftMargin(); float marginRightPt = document.rightMargin(); if (url == null) return;//w ww .ja v a 2 s.com Image img = null; String imgSimpleName = ""; try { File imgFile = new File(xhtmlDir, url); String imgPath = imgFile.getCanonicalPath(); imgSimpleName = imgFile.getName(); img = Image.getInstance(imgPath); if (alt == null) { alt = imgSimpleName; } img.setAlt(alt); } catch (Exception e) { printlnerr("epub2pdf: problem adding image " + imgSimpleName + ": " + e.getMessage()); return; } if (borderWidth != null) { int border = Integer.parseInt(borderWidth); if (border == 0) { img.setBorder(Image.NO_BORDER); } else { img.setBorder(Image.BOX); img.setBorderWidth(border); } } if (alignment != null) { int align = Image.DEFAULT; if (ElementTags.ALIGN_LEFT.equalsIgnoreCase(alignment)) align = Image.LEFT; else if (ElementTags.ALIGN_RIGHT.equalsIgnoreCase(alignment)) align = Image.RIGHT; else if (ElementTags.ALIGN_MIDDLE.equalsIgnoreCase(alignment)) align = Image.MIDDLE; img.setAlignment(align | Image.TEXTWRAP); } else { img.setAlignment(Image.MIDDLE); } Rectangle pageRect = document.getPageSize(); float verticalMarginTotal = marginTopPt + marginBottomPt; float horizontalMarginTotal = marginLeftPt + marginRightPt; float imgMaxWidth = pageRect.getWidth() - horizontalMarginTotal - 2; float imgMaxHeight = pageRect.getHeight() - verticalMarginTotal - 2; float imgOrigWidth = img.getWidth(); float imgOrigHeight = img.getHeight(); if (imgOrigHeight > imgMaxHeight || imgOrigWidth > imgMaxWidth) { img.scaleToFit(imgMaxWidth, imgMaxHeight); } boolean addOK = addToDocument(img); if (!addOK) { System.err.println("** addToDocument(" + img.getUrl() + ") returned false"); } }
From source file:com.geek.tutorial.itext.image.TextWrapping.java
License:Open Source License
public TextWrapping() throws Exception { Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream("TextWrapping.pdf")); document.open();/*from w ww . j a va 2 s . c o m*/ for (int i = 0; i < 100; i++) { document.add(new Phrase("AAAA ")); // Code 1 } com.lowagie.text.Image image = com.lowagie.text.Image.getInstance("square.jpg"); image.setAlignment(Image.RIGHT | Image.TEXTWRAP); // Code 2 document.add(image); document.add(new Phrase("\n\n")); // Code 3 for (int i = 0; i < 100; i++) { document.add(new Phrase("BBBB ")); } document.close(); }
From source file:com.homesoft.component.report.pdf.PdfWrappedStamper.java
License:Open Source License
public static void init() { instance = new PdfWrappedStamper(); try {/*from ww w. j a va 2 s .c o m*/ //png image imageEnabled = GlobalConfig.getInstance().getStamperImageEnabled(); if (imageEnabled) { image = Image.getInstance(getResourcePath() + GlobalConfig.getInstance().getStamperImagePath()); image.setAlignment(Image.LEFT | Image.TEXTWRAP); image.setBorderWidth(10); image.scaleToFit(GlobalConfig.getInstance().getStamperImageWidth(), GlobalConfig.getInstance().getStamperImageHeight());//size gsFixed = new PdfGState(); gsDynamic = new PdfGState(); gsFixed.setFillOpacity(GlobalConfig.getInstance().getStamperFixedImageTransparent()); gsDynamic.setFillOpacity(GlobalConfig.getInstance().getStamperDynamicImageTransparent()); } } catch (Exception e) { log.error(e.getMessage(), e); } }
From source file:Cotizacion.ExportarPDF.java
private static void acomodarImagenCabecera(Paragraph imagen) { try {//from w ww.ja va 2 s .c om Image im; im = Image.getInstance("src/Imagenes/arriba.png"); im.setAlignment(Image.ALIGN_CENTER | Image.TEXTWRAP); imagen.add(im); } catch (Exception e) { System.out.print(e.getMessage()); } }
From source file:Cotizacion.ExportarPDF.java
private static void acomodarImagenLogo(Paragraph imagen) throws BadElementException { try {/*from w ww .ja va2s. c o m*/ Image im = Image.getInstance("src/Imagenes/todo Lonas.png"); im.setAlignment(Image.ALIGN_LEFT | Image.TEXTWRAP); imagen.add(im); } catch (Exception e) { System.out.print(e.getMessage()); } }
From source file:Cotizacion.ExportarPDF.java
private static void acomodarImagenFirma(Paragraph imagen) throws BadElementException { try {// w ww . j a v a2 s .c o m Image im = Image.getInstance("src/Imagenes/firma3.png"); im.setAlignment(Image.ALIGN_CENTER | Image.TEXTWRAP); imagen.add(im); // agregarLineasEnBlanco(parrafoNormal, 3); } catch (Exception e) { System.out.print(e.getMessage()); } }
From source file:knop.psfj.exporter.PDFExporter.java
License:Open Source License
/** * Fill report.// w w w . jav a2 s . c om * * @param report the report * @param writer the writer * @param bead the bead * @param id the id */ public static void fillReport(Document report, PdfWriter writer, BeadFrame bead, int id) { Microscope microscope = bead.getSource().getMicroscope(); ReportSections rs = new ReportSections(); writer.setStrictImageSequence(true); try { /* * report.add(rs.bigTitle("Bead " + id)); * report.add(rs.littleNote(microscope.date)); /* * report.add(rs.title("Profile view:")); ImagePlus img; try { img = * svg.getPanelView(pp.getImagePlus(), SideViewGenerator.MAX_METHOD, * true, true, 5, false, null, 0); } catch (NullPointerException e) * { e.printStackTrace(); return; } float zoom2scaleTo256pxMax = * 25600 / Math.max(img.getWidth(), img.getHeight()); * report.add(rs.imagePlus(img, zoom2scaleTo256pxMax)); * * report.add(rs.title("Microscope infos:")); * report.add(rs.paragraph(microscope.getMicroscopeHeader())); */ id = bead.getId(); String suffix = ""; if (bead.isValid() == false) suffix = " (Rejected)"; if (bead.isValid() && bead.getInvalidityReason() != null) { suffix = " (Rejected from the pair analysis)"; } // Image logo = loadImage("knoplablogo.png"); // report.add(); // currentDocument.add(rs.littleNote(FileUtils.getTodayDate())); double[] resolutions = bead.getResolutions(); // the resolutions extracted from the Bead Spread function are // assigned to // individual variables String resolutionX = microscope.formatDouble(bead.getResolution(0)); String resolutionY = microscope.formatDouble(bead.getResolution(1)); String resolutionZ = microscope.formatDouble(bead.getResolution(2)); // the corrected resolution are calculated by the Microscope Object // (it holds // all the experiment data). String correctedResolutionX = microscope.formatDouble(bead.getCorrectionResolution(Microscope.X)); String correctedResolutionY = microscope.formatDouble(bead.getCorrectionResolution(Microscope.Y)); String correctedResolutionZ = microscope.formatDouble(bead.getCorrectionResolution(Microscope.Z)); String asymmetry = MathUtils.roundToString(bead.getAsymetry(), 3); String theta = MathUtils.roundToString(bead.getThetaInDegrees(), 1) + MathUtils.DEGREE_SYMBOL; String[][] content = { { "FWHM", "min", "max", "z", "Asymmetry", "Theta" }, { "Non corrected", resolutionX, resolutionY, resolutionZ, asymmetry, theta }, { "Corrected", correctedResolutionX, correctedResolutionY, correctedResolutionZ, "", "" }, { "Theoretical", microscope.formatDouble(microscope.getXYTheoreticalResolution()), microscope.formatDouble(microscope.getXYTheoreticalResolution()), microscope.formatDouble(microscope.getZTheoreticalResolution()), "", "" } }; Paragraph header = new Paragraph(); Image sideView = rs.imagePlus(bead.getSideViewImage(), 100); sideView.setAlignment(Image.ALIGN_RIGHT | Image.TEXTWRAP); report.add(sideView); String microscopeId = bead.getSource().getMicroscope().getIdentifier(); if (microscopeId.equals("") == false) microscopeId = String.format(" ( %s )", microscopeId); String date = "Date : " + FileUtils.getTodayDate(); String origin = String.format("\n Origin : %s %s\n Frame size : %d pixels\n", bead.getSource().getImageName(), microscopeId, bead.getWidth()); String shift; String correspondingBead = "\nCorresponding bead : " + ((bead.getAlterEgo() == null) ? "Not found" : "Number " + bead.getAlterEgo().getId() + " in " + bead.getAlterEgo().getSource().getImageName()); String coordinates = "\nCoordinates : " + microscope.formatDouble(bead.getFovX()) + " (x), " + microscope.formatDouble(bead.getFovY()) + " (y), " + microscope.formatDouble(bead.getCentroidZ() * microscope.getCalibration().pixelDepth) + " (z)"; String rejectionReason = (bead.getInvalidityReason() == null ? "" : "\nReason of rejection : " + bead.getInvalidityReason()); if (bead.getAlterEgo() != null) { shift = "\nShift : "; shift += microscope.formatDouble(bead.getDeltaX()); shift += " x " + microscope.formatDouble(bead.getDeltaY()); shift += " x " + microscope.formatDouble(bead.getDeltaZ()); } else { shift = ""; } report.add(rs.title("Bead " + id + suffix)); report.add(rs.paragraph(date + origin + coordinates + correspondingBead + shift + rejectionReason)); // report.add(rs.subtitle("Resolution table:")); report.add(rs.table(content, 100)); int height = 130; ImagePlus xPlot; ImagePlus yPlot; if (bead instanceof BeadFrame2D) { BeadFrame2D bead2D = (BeadFrame2D) bead; xPlot = new ImagePlus("", bead2D.getOverlayWithTheoretical()); yPlot = xPlot; report.add(rs.subtitle("XY profile & fitting parameters : ")); report.add(rs.littleNote("(red : the orignal data, green : the fit, yellow : the two merged)", Paragraph.ALIGN_LEFT)); } else { xPlot = bead.getXplot().getImagePlus(); yPlot = bead.getYplot().getImagePlus(); report.add(rs.subtitle("X profile & fitting parameters:")); } Image image = rs.imagePlus(xPlot, height); image.setAlignment(Image.ALIGN_LEFT | Image.TEXTWRAP); report.add(image); report.add(rs.paragraph(bead.getXParams())); if (bead instanceof BeadFrame2D == false) { report.add(rs.subtitle("Y profile & fitting parameters:")); image = rs.imagePlus(yPlot, height); image.setAlignment(Image.ALIGN_LEFT | Image.TEXTWRAP); report.add(image); report.add(rs.paragraph(bead.getYParams())); } report.add(rs.subtitle("Z profile & fitting parameters:")); image = rs.imagePlus(bead.getZplot().getImagePlus(), height); image.setAlignment(Image.ALIGN_LEFT | Image.TEXTWRAP); report.add(image); report.add(rs.paragraph(bead.getZParams())); if (!microscope.sampleInfos.equals("") || !microscope.comments.equals("")) report.newPage(); if (!microscope.sampleInfos.equals("")) { report.add(rs.title("Sample infos:")); report.add(rs.paragraph(microscope.sampleInfos)); } if (!microscope.comments.equals("")) { report.add(rs.title("Comments:")); report.add(rs.paragraph(microscope.comments)); } // logo.setAlignment(Image.ALIGN_RIGHT | Image.TEXTWRAP); // logo.scalePercent(10); // currentDocument.add(logo); } catch (DocumentException e) { e.printStackTrace(); } System.gc(); }
From source file:org.nuxeo.ecm.platform.ui.web.component.seam.UIImage.java
License:Open Source License
@Override public void createITextObject(FacesContext context) throws IOException, DocumentException { value = valueBinding(context, "value", value); // instance() doesn't work here - we need a new instance org.jboss.seam.ui.graphicImage.Image seamImage = new org.jboss.seam.ui.graphicImage.Image(); try {// w w w . j ava 2 s . c om if (value instanceof BufferedImage) { seamImage.setBufferedImage((BufferedImage) value); } else { seamImage.setInput(value); } } catch (Exception e) { log.error("Cannot resolve image for value " + value, e); return; } for (UIComponent cmp : this.getChildren()) { if (cmp instanceof ImageTransform) { ImageTransform imageTransform = (ImageTransform) cmp; imageTransform.applyTransform(seamImage); } } byte[] data = seamImage.getImage(); if (data == null) { log.error("Cannot resolve image for value " + value); return; } image = Image.getInstance(data); rotation = (Float) valueBinding(context, "rotation", rotation); if (rotation != 0) { image.setRotationDegrees(rotation); } height = (Float) valueBinding(context, "height", height); width = (Float) valueBinding(context, "width", width); if (height > 0 || width > 0) { image.scaleAbsolute(width, height); } int alignmentValue = 0; alignment = (String) valueBinding(context, "alignment", alignment); if (alignment != null) { alignmentValue = (ITextUtils.alignmentValue(alignment)); } wrap = (Boolean) valueBinding(context, "wrap", wrap); if (wrap != null && wrap.booleanValue()) { alignmentValue |= Image.TEXTWRAP; } underlying = (Boolean) valueBinding(context, "underlying", underlying); if (underlying != null && underlying.booleanValue()) { alignmentValue |= Image.UNDERLYING; } image.setAlignment(alignmentValue); alt = (String) valueBinding(context, "alt", alt); if (alt != null) { image.setAlt(alt); } indentationLeft = (Float) valueBinding(context, "indentationLeft", indentationLeft); if (indentationLeft != null) { image.setIndentationLeft(indentationLeft); } indentationRight = (Float) valueBinding(context, "indentationRight", indentationRight); if (indentationRight != null) { image.setIndentationRight(indentationRight); } spacingBefore = (Float) valueBinding(context, "spacingBefore", spacingBefore); if (spacingBefore != null) { image.setSpacingBefore(spacingBefore); } spacingAfter = (Float) valueBinding(context, "spacingAfter", spacingAfter); if (spacingAfter != null) { image.setSpacingAfter(spacingAfter); } widthPercentage = (Float) valueBinding(context, "widthPercentage", widthPercentage); if (widthPercentage != null) { image.setWidthPercentage(widthPercentage); } initialRotation = (Float) valueBinding(context, "initialRotation", initialRotation); if (initialRotation != null) { image.setInitialRotation(initialRotation); } dpi = (String) valueBinding(context, "dpi", dpi); if (dpi != null) { int[] dpiValues = ITextUtils.stringToIntArray(dpi); image.setDpi(dpiValues[0], dpiValues[1]); } applyRectangleProperties(context, image); scalePercent = (String) valueBinding(context, "scalePercent", scalePercent); if (scalePercent != null) { float[] scale = ITextUtils.stringToFloatArray(scalePercent); if (scale.length == 1) { image.scalePercent(scale[0]); } else if (scale.length == 2) { image.scalePercent(scale[0], scale[1]); } else { throw new RuntimeException("scalePercent must contain one or two scale percentages"); } } }
From source file:org.posterita.core.PDFReportGenerator.java
License:Open Source License
protected Image getTextAsImage(String text) throws OperationException { try {//from w ww . ja va2 s . c o m PdfTemplate template = writer.getDirectContent().createTemplate(20, 20); //BaseFont bf = BaseFont.createFont("Helvetica", "winansi", false); BaseFont bf = HEADER_FONT.getBaseFont(); float size = 10; float width = bf.getWidthPoint(text, size); template.beginText(); //template.setRGBColorFillF(1, 1, 1); template.setFontAndSize(bf, size); template.setTextMatrix(0, 2); template.showText(text); template.endText(); template.setWidth(width); template.setHeight(size + 2); // make an Image object from the template Image img = Image.getInstance(template); img.setAlignment(Image.RIGHT | Image.TEXTWRAP); return img; } catch (Exception e) { throw new OperationException(e); } }