//create a new workbook Workbook workbook = new Workbook(); IWorksheet worksheet = workbook.getWorksheets().get(0); worksheet.getPageSetup().setOrientation(PageOrientation.Landscape); InputStream stream = this.getResourceStream("logo.png"); IShape picture = null; try { picture = worksheet.getShapes().addPicture(stream, ImageType.PNG, 20, 20, 400, 100); } catch (IOException ioe) { } //save to an pdf file workbook.save("SavePictureToPDF.pdf");
//create a new workbook var workbook = Workbook() val worksheet = workbook.worksheets.get(0) worksheet.pageSetup.orientation = PageOrientation.Landscape val stream = this.getResourceStream("logo.png") var picture: IShape? = null try { picture = worksheet.shapes.addPicture(stream, ImageType.PNG, 20.0, 20.0, 400.0, 100.0) } catch (ioe: IOException) { } //save to an pdf file workbook.save("SavePictureToPDF.pdf")