You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Tim Allison <ta...@apache.org> on 2019/04/08 13:36:14 UTC

Getting contents out of HemfComment.EmfCommentDataWMF ?

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: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Getting contents out of HemfComment.EmfCommentDataWMF ?

Posted by Andreas Beeker <ki...@apache.org>.
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 <ki...@apache.org> wrote:
>
>> Oh sorry ... I've just realized you've introduced the method recently ...
>> how embarrassing ...
>>
>>



Re: Getting contents out of HemfComment.EmfCommentDataWMF ?

Posted by Tim Allison <ta...@apache.org>.
Are you ok w it?

On Mon, Apr 8, 2019 at 6:11 PM Andreas Beeker <ki...@apache.org> wrote:

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

Re: Getting contents out of HemfComment.EmfCommentDataWMF ?

Posted by Andreas Beeker <ki...@apache.org>.
Oh sorry ... I've just realized you've introduced the method recently ... how embarrassing ...


Re: Getting contents out of HemfComment.EmfCommentDataWMF ?

Posted by Andreas Beeker <ki...@apache.org>.
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