com.lowagie.text.Image.setAlignment()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(9.2k)|赞(0)|评价(0)|浏览(366)

本文整理了Java中com.lowagie.text.Image.setAlignment()方法的一些代码示例,展示了Image.setAlignment()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Image.setAlignment()方法的具体详情如下:
包路径:com.lowagie.text.Image
类名称:Image
方法名:setAlignment

Image.setAlignment介绍

[英]Sets the alignment for the image.
[中]设置图像的对齐方式。

代码示例

代码示例来源:origin: stackoverflow.com

image.setAlignment(Image.MIDDLE| Image.TEXTWRAP);

代码示例来源:origin: stackoverflow.com

/* Inserting Image in PDF */
ByteArrayOutputStream stream = new ByteArrayOutputStream();

Bitmap bitmap = BitmapFactory.decodeResource(getBaseContext().getResources(), R.drawable.android);

bitmap.compress(Bitmap.CompressFormat.JPEG, 100 , stream);

Image myImg = Image.getInstance(stream.toByteArray());

myImg.setAlignment(Image.MIDDLE);

//add image to document
doc.add(myImg);

代码示例来源:origin: stackoverflow.com

ByteArrayOutputStream stream = new ByteArrayOutputStream();
            Bitmap bitmap = BitmapFactory.decodeResource(getBaseContext().getResources(), R.drawable.ic_launcher);
            bitmap.compress(Bitmap.CompressFormat.JPEG, 100 , stream);
            Image myImg = Image.getInstance(stream.toByteArray());
            myImg.setAlignment(Image.MIDDLE);
            //add image to document
            document.add(myImg);

代码示例来源:origin: stackoverflow.com

try {
   Image img = Image.getInstance("url/logo.png");
   img.scaleToFit(100,100);  
   img.setAbsolutePosition((rect.getLeft() + rect.getRight()) / 2 - 45, rect.getTop() - 50);
   img.setAlignment(Element.ALIGN_CENTER);          
   writer.getDirectContent().addImage(img);
  } catch (Exception x) {
   x.printStackTrace();
  }

代码示例来源:origin: stackoverflow.com

bitmap1.compress(Bitmap.CompressFormat.JPEG, 100 , stream1);
Image myImg1 = Image.getInstance(stream1.toByteArray());
myImg1.setAlignment(Image.MIDDLE);

代码示例来源:origin: stackoverflow.com

image from camera
  //Bitmap imageBitmap = BitmapFactory.decodeFile(picturePath);
     ByteArrayOutputStream stream = new ByteArrayOutputStream();
     imageBitmap.compress(Bitmap.CompressFormat.JPEG, 80, stream);
     imagebytes = stream.toByteArray();
     stream.close();
     stream = null;
     Document document = new Document();
     PdfWriter.getInstance(document, new FileOutputStream(FILEPATH));
     document.open();
     Image image = Image.getInstance(imagebytes);
     image.scaleAbsolute(imageBitmap.getWidth(),
         imageBitmap.getHeight());
     image.setAlignment(Image.MIDDLE |Image.ALIGN_MIDDLE);
     document.add(image);
     document.close();
     File file = new File("mnt/sdcard/myPdf.pdf");
     byte[] binaryFile = new byte[(int) file.length()];
     InputStream fis = new FileInputStream(file);
     fis.read(binaryFile);
     fis.close();

代码示例来源:origin: stackoverflow.com

SAXSVGDocumentFactory factory = new SAXSVGDocumentFactory(XMLResourceDescriptor.getXMLParserClassName());
UserAgent userAgent = new UserAgentAdapter();
DocumentLoader loader = new DocumentLoader(userAgent);
BridgeContext ctx = new BridgeContext(userAgent, loader);
ctx.setDynamicState(BridgeContext.DYNAMIC);
GVTBuilder builder = new GVTBuilder();
SVGDocument svgDoc = factory.createSVGDocument(rootPath, new StringReader(svg));
PdfTemplate svgTempl = PdfTemplate.createTemplate(writer, Float.parseFloat(svgDoc.getDocumentElement().getAttribute("width")), Float.parseFloat(svgDoc.getDocumentElement().getAttribute("height")));
Graphics2D g2d = new PdfGraphics2D(svgTempl, svgTempl.getWidth(), svgTempl.getHeight());
GraphicsNode chartGfx = builder.build(ctx, svgDoc);
chartGfx.paint(g2d);
g2d.dispose();
Image svgImg = new ImgTemplate(svgTempl);
svgImg.setAlignment(Image.ALIGN_CENTER);
//svgImg.setBorder(Image.BOX);
//svgImg.setBorderColor(new BaseColor(0xff, 0x00, 0x00));
//svgImg.setBorderWidth(1);
document.add(svgImg);

代码示例来源:origin: es.gob.afirma/afirma-crypto-pdf-itext

.getProperty(ElementTags.TEXTWRAP)))
  align |= Image.TEXTWRAP;
image.setAlignment(align);

代码示例来源:origin: stackoverflow.com

Image image = Image.getInstance(stream.toByteArray());
image.scalePercent(70);
image.setAlignment(Image.MIDDLE);
document.add(image);

代码示例来源:origin: be.fedict.eid-applet/eid-applet-service

/**
 * Create a PDF image from eID photo
 *
 * @param photoData
 *            raw bytes
 * @return PDF image
 * @throws IOException
 * @throws BadElementException
 */
private Image createImageFromPhoto(byte[] photoData) throws IOException, BadElementException {
  Image image = Image.getInstance(photoData);
  image.setAlt("Photo");
  image.setAlignment(Element.ALIGN_CENTER);
  image.setSpacingAfter(20);
  return image;
}

代码示例来源:origin: stackoverflow.com

img.setAlignment(Image.TEXTWRAP);
img.scaleAbsolute(200f, 50f);

代码示例来源:origin: SonarQubeCommunity/sonar-pdf-report

public Image getGraphic(final ComplexityDistribution complexityDistribution) {
 Image image = null;
 try {
  if (complexityDistribution.getyValues().length != 0) {
   image = Image
     .getInstance(sonarBaseUrl
       + "/chart?cht=cvb&chdi=300x200&chca="
       + complexityDistribution.formatXValues()
       + "&chov=y&chrav=y&chv="
       + complexityDistribution.formatYValues()
       + "&chorgv=y&chcaaml=0.05&chseamu=0.2&chins=5&chcaamu=0.05&chcav=y&chc=777777,777777,777777,777777,777777,777777,777777");
   image.setAlignment(Image.ALIGN_MIDDLE);
  }
 } catch (BadElementException e) {
  LOG.error("Can not generate complexity distribution image", e);
 } catch (MalformedURLException e) {
  LOG.error("Can not generate complexity distribution image", e);
 } catch (IOException e) {
  LOG.error("Can not generate complexity distribution image", e);
 }
 return image;
}

代码示例来源:origin: stackoverflow.com

Image logo = Image.getInstance("/image.gif");
logo.setAlignment(Image.MIDDLE);
logo.scaleAbsoluteHeight(20);
logo.scaleAbsoluteWidth(20);
logo.scalePercent(100);
Chunk chunk = new Chunk(logo, 0, -45);
HeaderFooter header = new HeaderFooter(new Phrase(chunk), false);
header.setAlignment(Element.ALIGN_CENTER);
header.setBorder(Rectangle.NO_BORDER);
document.setHeader(header);

代码示例来源:origin: com.github.bengolder/pdf-rtf

/**
   * Set the alignment of this RtfHeaderFooter. Passes the setting
   * on to the contained element.
   */
  public void setAlignment(int alignment) {
    super.setAlignment(alignment);
    for(int i = 0; i < this.content.length; i++) {
      if(this.content[i] instanceof Paragraph) {
        ((Paragraph) this.content[i]).setAlignment(alignment);
      } else if(this.content[i] instanceof Table) {
        ((Table) this.content[i]).setAlignment(alignment);
      } else if(this.content[i] instanceof Image) {
        ((Image) this.content[i]).setAlignment(alignment);
      }     
    }
  }
}

代码示例来源:origin: org.jboss.itext/itext-rtf

/**
   * Set the alignment of this RtfHeaderFooter. Passes the setting
   * on to the contained element.
   */
  public void setAlignment(int alignment) {
    super.setAlignment(alignment);
    for(int i = 0; i < this.content.length; i++) {
      if(this.content[i] instanceof Paragraph) {
        ((Paragraph) this.content[i]).setAlignment(alignment);
      } else if(this.content[i] instanceof Table) {
        ((Table) this.content[i]).setAlignment(alignment);
      } else if(this.content[i] instanceof Image) {
        ((Image) this.content[i]).setAlignment(alignment);
      }     
    }
  }
}

代码示例来源:origin: stackoverflow.com

bitmap.compress(Bitmap.CompressFormat.JPEG, 100 , stream);
Image myImg = Image.getInstance(stream.toByteArray());
myImg.setAlignment(Image.MIDDLE);

代码示例来源:origin: stackoverflow.com

bitmap.compress(Bitmap.CompressFormat.JPEG, 100 , stream);
Image myImg = Image.getInstance(stream.toByteArray());
myImg.setAlignment(Image.MIDDLE);

代码示例来源:origin: SonarQubeCommunity/sonar-pdf-report

public Image getGraphic(final RadarGraphic radarGraphic) {
 Image image = null;
 try {
  String requestUrl = sonarBaseUrl
    + "/chart?ck=xradar&w=210&h=110&c=777777|F8A036&m=100&g=0.25&"
    + "l=Eff.(" + radarGraphic.getEfficiency() + "%25),Mai.("
    + radarGraphic.getMaintainability() + "%25),Por.("
    + radarGraphic.getPortability() + "%25),Rel.("
    + radarGraphic.getReliavility() + "%25),Usa.("
    + radarGraphic.getUsability() + "%25)&" + "v="
    + radarGraphic.getEfficiency() + ","
    + radarGraphic.getMaintainability() + ","
    + radarGraphic.getPortability() + "," + radarGraphic.getReliavility()
    + "," + radarGraphic.getUsability();
  LOG.debug("Getting radar graphic: " + requestUrl);
  image = Image.getInstance(requestUrl);
  image.setAlignment(Image.ALIGN_MIDDLE);
 } catch (BadElementException e) {
  LOG.error("Can not generate radar graphic", e);
 } catch (MalformedURLException e) {
  LOG.error("Can not generate radar graphic", e);
 } catch (IOException e) {
  LOG.error("Can not generate radar graphic", e);
 }
 return image;
}

代码示例来源:origin: org.onap.portal.sdk/epsdk-analytics

private void paintPdfImage(HttpServletRequest request, Document document, String fileName, ReportRuntime rr) 
      throws DocumentException
{
  
  ArrayList images = getImage(request, fileName,pb.isAttachmentOfEmail()?true:false, rr);
  //Image image = getImage(request, fileName,pb.isAttachmentOfEmail()?true:false);
  PdfPTable table =  null;
  PdfPCell cellValue = null;
  if(images!=null) {
    
    for (int i = 0; i < images.size(); i++) {
      table = new PdfPTable(1);
      cellValue = new PdfPCell();
      cellValue.setHorizontalAlignment(Rectangle.ALIGN_CENTER);
      Image image = (Image) images.get(i);                
      image.setAlignment(Image.ALIGN_CENTER);
      //System.out.println("Document 3 " + document + " i-" + i);
      if(i%2 ==0)
      document.newPage();
      //System.out.println("Document 31 " + document);
      cellValue.setImage(image);
      //table.getDefaultCell().setHorizontalAlignment(Rectangle.ALIGN_CENTER);
      table.addCell(cellValue);
      //System.out.println("Document 32 " + document + "table  " + table);
      document.add(table);
        //System.out.println("Document 33 " + document);    			
    }
  }
}

代码示例来源:origin: org.seasar.tuigwaa/tuigwaa-ext

img = Image.getInstance(realpath);                    
  img.setAlignment(Image.ALIGN_MIDDLE | Image.TEXTWRAP);
  e = (Element) img;                
}catch(MalformedURLException mue){

相关文章

微信公众号

最新文章

更多

Image类方法