2

I am working on a React Application. I am unable to display EMF images on user interface. I am restricted to use only Chrome & Edge as browsers.

The workflow is -

  1. Users can copy & paste any rich text from word document on the UI.
  2. Rich text with EMF images are displayed as empty broken image boxes on the UI.
  3. I am retrieving the image from the rich text format and convert it to base64 before rendering it via HTML.
  4. When I explicitly copy & paste only the image(then the type changes to png) and it doesn't break. However when the entire word doc content is copied & pasted (image type remains as EMF), that is when I see the broken image.

I am still a beginner in React and tried searching for the solution online, but didn't come across anything specific to React JS. Is it possible to convert emf images into other supported image types? Are there any libraries or packages compatible with React JS? Is there a way by which I can achieve this use case? Open to other suggestions or approach.

Thanks.

Iti
  • 21
  • 2
  • 1
    Browser can't process EMF/WMF images natively. Using ActiveX embeddings isn't an option nowadays. so you would need to convert the images, e.g. to svg. google for "lib emf svg" and you'll find several options or use [my implementation](http://poi.apache.org/components/slideshow/ppt-wmf-emf-renderer.html) which has still room for improvements ... – kiwiwings Oct 01 '21 at 06:20
  • @kiwiwings Are you aware of any JS implementation for this conversion? – Iti Oct 01 '21 at 06:38
  • 1
    a quick search came up with [rtf.js](https://github.com/tbluemel/rtf.js) – kiwiwings Oct 01 '21 at 06:53
  • This didn't produced desired result. – Iti Oct 02 '21 at 04:53

0 Answers0