Skip to content

TIKA-4855: Render EMF/WMF through POI and emit the OLE2 SummaryInformation thumbnail - #3095

Open
dschmidt wants to merge 7 commits into
apache:mainfrom
dschmidt:metafile-rendering
Open

TIKA-4855: Render EMF/WMF through POI and emit the OLE2 SummaryInformation thumbnail#3095
dschmidt wants to merge 7 commits into
apache:mainfrom
dschmidt:metafile-rendering

Conversation

@dschmidt

Copy link
Copy Markdown
Contributor

Office documents carry their preview image as a vector metafile: the OOXML docProps/thumbnail.emf of Word (an EMF wrapping a WMF) and thumbnail.wmf of Excel, and the SummaryInformation thumbnail (PIDSI_THUMBNAIL, CF_METAFILEPICT, a WMF) of the OLE2 formats. Neither is usable as a preview outside Windows, and outside the JVM there is no maintained EMF/WMF rasterizer, while POI's HEMF/HWMF can draw both.

Following the PDF parser's rendering design:

  • POIMetafileRenderer (poi-metafile-renderer) is a Renderer for image/emf and image/wmf: the POI picture drawn onto a white canvas, a PNG of a configurable width. The WMF thumbnails Word writes consist of a setWindowExt and a dibStretchBlt record only, for which POI cannot compute bounds; those are rendered from the record's bitmap.
  • EMFParser and WMFParser implement RenderingParser and, with "emf-parser" / "wmf-parser": {"renderImage": true, "renderWidth": 800} (off by default), emit the rendering as a RENDERING embedded document named after the image. An injected renderer is used when it supports the type, the POI one otherwise. The shared config and emission live in MetafileParserConfig and MetafileRendering.
  • OfficeParser emits the SummaryInformation thumbnail as a THUMBNAIL embedded document (image/wmf, thumbnail.wmf), consistent with the docProps thumbnail of the OOXML parsers. Two PowerPoint tests count one embedded document more because of it.

Verified against tika-server with /unpack: docx, xlsx, doc, xls and ppt files that carry a thumbnail yield it at depth 1 and its PNG rendering at depth 2.

https://issues.apache.org/jira/browse/TIKA-4855

…mation thumbnail

POIMetafileRenderer (poi-metafile-renderer) draws EMF and WMF images to a
PNG of a configurable width; Word's bitmap-in-WMF thumbnails, which POI has
no bounds for, are rendered from the bitmap. EMFParser and WMFParser are
RenderingParsers and emit the rendering as a RENDERING embedded document
with "emf-parser" / "wmf-parser": {"renderImage": true}, off by
default, the way the PDF parser emits page renderings. OfficeParser emits
the SummaryInformation thumbnail of the OLE2 formats (a WMF) as a THUMBNAIL
embedded document, as the OOXML parsers do with the docProps thumbnail.
@dschmidt
dschmidt force-pushed the metafile-rendering branch from 5cafd74 to e966adc Compare August 29, 2026 12:22
…o e.g. thumbnails

With "renderOnlyEmbeddedResourceTypes": ["THUMBNAIL"] the parsers render
the document's thumbnail but not the metafiles of embedded objects or
pictures; empty (the default) renders every image.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants