Getting contents out of HemfComment.EmfCommentDataWMF ?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Getting contents out of HemfComment.EmfCommentDataWMF ?

Tim Allison
All,
  I'm trying to update Tika for POI 4.1.0, and we used to do the
following in our EMFParser:

private void handleWMF(HemfCommentPublic.WindowsMetafile comment, ...)
throws ... {
...
     try (InputStream is = TikaInputStream.get(comment.getWmfInputStream())) {
                 ...parse(is)

      }
}

How can I get the raw data out of HemfComment.EmfCommentDataWMF ?

  Thank you!

             Best,

                     Tim

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Getting contents out of HemfComment.EmfCommentDataWMF ?

kiwiwings
Hi Tim,

please use the getWMFData() method:

HemfPicture emf = new HemfPicture((InputStream)...);
for (HemfRecord r : emf.getRecords()) {
    if (r instanceof EmfComment) {
        EmfCommentData hc = ((EmfComment)r).getCommentData();
        if (hc instanceof EmfCommentDataWMF) {
            EmfCommentDataWMF hcWmf = (EmfCommentDataWMF)hc;
            HwmfPicture wmf = new HwmfPicture(new ByteArrayInputStream(hcWmf.getWMFData()));
            List<HwmfRecord> bla = wmf.getRecords();
        }
    }
}

Best wishes,
Andi


signature.asc (499 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Getting contents out of HemfComment.EmfCommentDataWMF ?

kiwiwings
Oh sorry ... I've just realized you've introduced the method recently ... how embarrassing ...


signature.asc (499 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Getting contents out of HemfComment.EmfCommentDataWMF ?

Tim Allison
Are you ok w it?

On Mon, Apr 8, 2019 at 6:11 PM Andreas Beeker <[hidden email]> wrote:

> Oh sorry ... I've just realized you've introduced the method recently ...
> how embarrassing ...
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Getting contents out of HemfComment.EmfCommentDataWMF ?

kiwiwings
Yes of course - it's a pity I forgot about adding it to the API in 4.1.
I'm still deep in (/struggling to) getting XmlBeans fit for Java 9+, but afterwards I intend to provide more emfplus records, so this won't be the only change in that area for the next release.

On 09.04.19 00:24, Tim Allison wrote:
> Are you ok w it?
>
> On Mon, Apr 8, 2019 at 6:11 PM Andreas Beeker <[hidden email]> wrote:
>
>> Oh sorry ... I've just realized you've introduced the method recently ...
>> how embarrassing ...
>>
>>



signature.asc (499 bytes) Download Attachment