use of org.apache.poi.hwpf.model.PicturesTable in project poi by apache.
the class TestHWPFPictures method testImageData.
/**
* Test that we have the right images in at least one file
*/
public void testImageData() {
HWPFDocument docB = HWPFTestDataSamples.openSampleFile(docBFile);
PicturesTable picB = docB.getPicturesTable();
List<Picture> picturesB = picB.getAllPictures();
assertEquals(2, picturesB.size());
Picture pic1 = picturesB.get(0);
Picture pic2 = 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());
}
use of org.apache.poi.hwpf.model.PicturesTable in project poi by apache.
the class TestHWPFPictures method testCompressedImageData.
/**
* Test that compressed image data is correctly returned.
*/
public void testCompressedImageData() {
HWPFDocument docC = HWPFTestDataSamples.openSampleFile(docCFile);
PicturesTable picC = docC.getPicturesTable();
List<Picture> picturesC = picC.getAllPictures();
assertEquals(1, picturesC.size());
Picture pic = picturesC.get(0);
assertNotNull(pic);
// Check the same
byte[] picBytes = readFile(imgCFile);
assertEquals(picBytes.length, pic.getContent().length);
assertBytesSame(picBytes, pic.getContent());
}
use of org.apache.poi.hwpf.model.PicturesTable in project poi by apache.
the class TestPictures method testPictureDetectionWithPNG.
@Test
public void testPictureDetectionWithPNG() {
HWPFDocument document = HWPFTestDataSamples.openSampleFile("PngPicture.doc");
PicturesTable pictureTable = document.getPicturesTable();
assertEquals(1, pictureTable.getAllPictures().size());
Picture p = pictureTable.getAllPictures().get(0);
assertEquals(PictureType.PNG, p.suggestPictureType());
assertEquals("png", p.suggestFileExtension());
}
use of org.apache.poi.hwpf.model.PicturesTable in project poi by apache.
the class TestPictures method testPictureWithAlternativeText.
@Test
public void testPictureWithAlternativeText() {
HWPFDocument document = HWPFTestDataSamples.openSampleFile("Picture_Alternative_Text.doc");
PicturesTable pictureTable = document.getPicturesTable();
Picture picture = pictureTable.getAllPictures().get(0);
assertEquals("This is the alternative text for the picture.", picture.getDescription());
}
use of org.apache.poi.hwpf.model.PicturesTable in project poi by apache.
the class TestPictures method expectImages.
private void expectImages(HWPFDocument docA, int expectedCount) {
assertNotNull(docA.getPicturesTable());
PicturesTable picA = docA.getPicturesTable();
List<Picture> picturesA = picA.getAllPictures();
assertEquals(expectedCount, picturesA.size());
}
Aggregations