Package org.apache.poi.hwpf.usermodel

Examples of org.apache.poi.hwpf.usermodel.Picture


    PicturesTable picC = docC.getPicturesTable();
    List picturesC = picC.getAllPictures();
   
    assertEquals(1, picturesC.size());
   
    Picture pic = (Picture)picturesC.get(0);
    assertNotNull(pic);
   
    // Check the same
    byte[] picBytes = readFile(imgCFile);
   
    assertEquals(picBytes.length, pic.getContent().length);
    assertBytesSame(picBytes, pic.getContent());
  }
View Full Code Here


   * @return a Picture object if picture exists for specified CharacterRun, null otherwise. PicturesTable.hasPicture is used to determine this.
   * @see #hasPicture(org.apache.poi.hwpf.usermodel.CharacterRun)
   */
  public Picture extractPicture(CharacterRun run, boolean fillBytes) {
    if (hasPicture(run)) {
      return new Picture(run.getPicOffset(), _dataStream, fillBytes);
    }
    return null;
  }
View Full Code Here

                {
                    EscherBSERecord bse = (EscherBSERecord) escherRecord;
                    EscherBlipRecord blip = bse.getBlipRecord();
                    if (blip != null)
                    {
                        pictures.add(new Picture(blip.getPicturedata()));
                    }
                    else if (bse.getOffset() > 0)
                    {
                        // Blip stored in delay stream, which in a word doc, is the main stream
                        EscherRecordFactory recordFactory = new DefaultEscherRecordFactory();
                        blip = (EscherBlipRecord) recordFactory.createRecord(_mainStream, bse.getOffset());
                        blip.fillFields(_mainStream, bse.getOffset(), recordFactory);
                        pictures.add(new Picture(blip.getPicturedata()));
                    }
                }

                // Recursive call.
                searchForPictures(escherRecord.getChildRecords(), pictures);
View Full Code Here

 
    Range range = _document.getRange();
    for (int i = 0; i < range.numCharacterRuns(); i++) {
      CharacterRun run = range.getCharacterRun(i);
      String text = run.text();
      Picture picture = extractPicture(run, false);
      if (picture != null) {
        pictures.add(picture);
      }
  }
   
View Full Code Here

    PicturesTable picB = docB.getPicturesTable();
    List picturesB = picB.getAllPictures();

    assertEquals(2, picturesB.size());

    Picture pic1 = (Picture)picturesB.get(0);
    Picture pic2 = (Picture)picturesB.get(1);

    assertNotNull(pic1);
    assertNotNull(pic2);

    // Check the same
    byte[] pic1B = readFile(imgAFile);
    byte[] pic2B = readFile(imgBFile);

    assertEquals(pic1B.length, pic1.getContent().length);
    assertEquals(pic2B.length, pic2.getContent().length);

    assertBytesSame(pic1B, pic1.getContent());
    assertBytesSame(pic2B, pic2.getContent());
  }
View Full Code Here

    PicturesTable picC = docC.getPicturesTable();
    List picturesC = picC.getAllPictures();

    assertEquals(1, picturesC.size());

    Picture pic = (Picture)picturesC.get(0);
    assertNotNull(pic);

    // Check the same
    byte[] picBytes = readFile(imgCFile);

    assertEquals(picBytes.length, pic.getContent().length);
    assertBytesSame(picBytes, pic.getContent());
  }
View Full Code Here

    HWPFDocument docD = HWPFTestDataSamples.openSampleFile(docDFile);
    List allPictures = docD.getPicturesTable().getAllPictures();

    assertEquals(1, allPictures.size());

    Picture pic = (Picture) allPictures.get(0);
    assertNotNull(pic);
    byte[] picD = readFile(imgDFile);

    assertEquals(picD.length, pic.getContent().length);

    assertBytesSame(picD, pic.getContent());
  }
View Full Code Here

   * @return a Picture object if picture exists for specified CharacterRun, null otherwise. PicturesTable.hasPicture is used to determine this.
   * @see #hasPicture(org.apache.poi.hwpf.usermodel.CharacterRun)
   */
  public Picture extractPicture(CharacterRun run, boolean fillBytes) {
    if (hasPicture(run)) {
      return new Picture(run.getPicOffset(), _dataStream, fillBytes);
    }
    return null;
  }
View Full Code Here

                {
                    EscherBSERecord bse = (EscherBSERecord) escherRecord;
                    EscherBlipRecord blip = bse.getBlipRecord();
                    if (blip != null)
                    {
                        pictures.add(new Picture(blip.getPicturedata()));
                    }
                    else if (bse.getOffset() > 0)
                    {
                        // Blip stored in delay stream, which in a word doc, is the main stream
                        EscherRecordFactory recordFactory = new DefaultEscherRecordFactory();
                        blip = (EscherBlipRecord) recordFactory.createRecord(_mainStream, bse.getOffset());
                        blip.fillFields(_mainStream, bse.getOffset(), recordFactory);
                        pictures.add(new Picture(blip.getPicturedata()));
                    }
                }

                // Recursive call.
                searchForPictures(escherRecord.getChildRecords(), pictures);
View Full Code Here

    Range range = _document.getOverallRange();
    for (int i = 0; i < range.numCharacterRuns(); i++) {
      CharacterRun run = range.getCharacterRun(i);
      String text = run.text();
      Picture picture = extractPicture(run, false);
      if (picture != null) {
        pictures.add(picture);
      }
  }
View Full Code Here

TOP

Related Classes of org.apache.poi.hwpf.usermodel.Picture

Copyright © 2018 www.massapicom. 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.