Hi,

I am trying to embed a PDF file in an excel, I am able to embed the file but
it is not opening. Excel is showing the image I had anchored to, but on
click of it, nothing happens as it is just an image.

XSSFWorkbook wb = new XSSFWorkbook(new FileInputStream("dr.xlsx"));
FileInputStream fs = new FileInputStream("test.pdf");
FileInputStream fs1 = new FileInputStream("download.png");
int pdf = wb.addOlePackage(IOUtils.toByteArray(fs), "text.pdf", "text.pdf",
"text.pdf");
int anc = wb.addPicture(IOUtils.toByteArray(fs1),
HSSFPicture.PICTURE_TYPE_PNG);
XSSFSheet sheet = wb.getSheetAt(0);
XSSFDrawing draw = sheet.createDrawingPatriarch();
ClientAnchor anchor = draw.createAnchor(0, 0, 0, 0, 1, 2, 2, 4);
anchor.setAnchorType(ClientAnchor.AnchorType.DONT_MOVE_AND_RESIZE);
XSSFObjectData objectData = draw.createObjectData(anchor, pdf, anc);
objectData.getCTShape().getNvSpPr().getCNvPr().setName( "text.pdf");
objectData.getCTShape().getNvSpPr().getCNvPr().setHidden(false);



--
Sent from: http://apache-poi.1045710.n5.nabble.com/POI-User-f2280730.html

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to