Docx: How to create image in javascript

Created on 18 Apr 2019  路  3Comments  路  Source: dolanmiu/docx

Hello everybody.
My English is very poor, when you use node, you use this expression.
const image = doc.createImage(fs.readFileSync('./cat.jpg'));

but how to create image in javascript or angular.

Thanks.

Most helpful comment

That's correct

It can also be Buffer or Uint8Array or ArrayBuffer too, as well as the aforementioned base 64 string:

https://github.com/dolanmiu/docx/blob/master/src/file/media/media.ts#L48

Pick which one works for you best

All 3 comments

it's a base64 format image.
Please approach this stackoverflow who details all different variations https://stackoverflow.com/questions/6150289/how-to-convert-image-into-base64-string-using-javascript

That's correct

It can also be Buffer or Uint8Array or ArrayBuffer too, as well as the aforementioned base 64 string:

https://github.com/dolanmiu/docx/blob/master/src/file/media/media.ts#L48

Pick which one works for you best

A lot of thanks everybody.

Was this page helpful?
0 / 5 - 0 ratings