Page 1 of 1

Can we have a faster way to add images

PostPosted: Sat Jul 07, 2018 12:38 am
by irfanm
Hi Jason,

Can we have a faster way to add images to a table cell?

I wrote a sample code using simple for loop 500 iterations to write into a table, so 500 rows with images it took me 1 minute.

If i remove images it took 5 sec. Why it takes that much time to write a image? I am using "createImageRun" for adding a image.

Any alternative faster way? Please help?


Regards
Irfan Mohammed

Re: Can we have a faster way to add images

PostPosted: Mon Jul 09, 2018 7:31 pm
by jason
BinaryPartAbstractImage contains a method:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
        private static ImageInfo ensureFormatIsSupported(URL url, File imageFile, byte[] bytes, boolean isLoad) throws Docx4JException {
 
Parsed in 0.014 seconds, using GeSHi 1.0.8.4


ImageInfo is org.apache.xmlgraphics.image.loader.ImageInfo

That's used to find out what type of image it is (eg png), and to provide the image size info. Last time I checked, it needed a tmp file. That may have changed now, in which case things could be quicker.

Alternatively, if you know all that info already, with a little code you could bypass ImageInfo entirely