Examples of addPicture()


Examples of org.apache.poi.xwpf.usermodel.XWPFDocument.addPicture()

 
  public void testAddPicture(){
    XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("sample.docx");
    byte[] jpeg = "This is a jpeg".getBytes();
    try {
      int jpegNum = doc.addPicture(jpeg, XWPFDocument.PICTURE_TYPE_JPEG);
      byte[] newJpeg = doc.getAllPictures().get(jpegNum).getData();
      assertEquals(newJpeg.length, jpeg.length);
      for(int i = 0 ; i < jpeg.length; i++){
        assertEquals(newJpeg[i], jpeg[i]);
      }
View Full Code Here

Examples of org.apache.poi.xwpf.usermodel.XWPFRun.addPicture()

        XWPFRun r = p.createRun();
       
        int format = XWPFDocument.PICTURE_TYPE_JPEG;
        r.setText(imgFile);
        r.addBreak();
        r.addPicture(new FileInputStream(imgFile), format, imgFile, Units.toEMU(200), Units.toEMU(200)); // 200x200 pixels
        r.addBreak(BreakType.PAGE);

      FileOutputStream out = new FileOutputStream("data/Apache_ImagesInDoc.docx");
      doc.write(out);
      out.close();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.