Hello Matthew, Are you still trying to do this? If so, I may - that is a big may - have a solution for you.
To get at the size of the pictures, you really need to get acess to the client anchor object that is associated with each one. It may be possible to do this if you open the workbook, get a reference to the sheet that 'contains' the pictures, get a reference to the patriarch from this and ask it for a list of it's children. If I am correct, this will return to you a list of all the shapes that the patriarch contains. HSSFPicture is a subclass of HSSFSimpleShape which itself is a subclass of HSSFShape and so I am hoping that this list will contain references to the pictures. What I am hoping - and I have not tested this so forgive me please if I am incorrect - is that the List of children recovered from the patriarch will contain entries of type HSSFPicture - or that you can cast them to this type if all else fails. That way, you can call the getImageDimension() or getPreferredSize() methods defined on the HSSFPicture class. As I said, this may work, it may equally fall down flat on it's face, but it is probably worth trying. matthewxb wrote: > > I have a workbook contains two pictures. I want to copy the pictures from > a source workbook to a target workbook. How can I do that? > > I used HSSFWorkbook.getAllPictures() to retrieve all the pictures, but it > only allow me to read the pictures' binary data. I have to know the size > and the location of each picture. > I write a loop to read each worksheet and call > HSSFSheet.getDrawingPatriarch(). It contains four methods in > HSSFPatriarch, suppose they represent the location of picture. > > HSSFPatriarch.getX1(),HSSFPatriarch.getX2(), HSSFPatriarch.getY1(), > HSSFPatriarch.getY2() > > But above methods return 0, which is incorrect. > > And the size of picture I couldn't find a way to know, since the actual > picture size and the size shown in worksheet are different. > > I want to copy the pictures from a source workbook to a target workbook. > How can I do that? Please advice, thank you very much! > -- View this message in context: http://www.nabble.com/Copy-images-from-Workbook-to-Workbook-tp23032425p23061964.html Sent from the POI - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
