0

I am using docx4j for report generation in my java program. I can add text to the report but i cannot add images to the report.

I'm trying to add an image for the report using the following code

WordprocessingMLPackage wordprocessingMLPackage = WordprocessingMLPackage.createPackage();

InputStream frontImageInputStream = new FileInputStream(new File(fileNameAndPath));

byte[] binaryDataFrontImage = IOUtils.toByteArray(frontImageInputStream);

BinaryPartAbstractImage.createImagePart(wordprocessingMLPackage, binaryDataFrontImage);

wordprocessingMLPackage.save(new java.io.File("myfile.docx"));

Can anyone share any idea about this.

madu
  • 344
  • 3
  • 14

1 Answers1

0

You've added the image part, but you haven't added anything on the document surface to actually display it.

For a complete example, please see ImageAdd.java

JasonPlutext
  • 15,352
  • 4
  • 44
  • 84