Support WMF files that start with META_PLACEABLE record #1

Open
opened 2021-01-20 19:57:44 +00:00 by rossj · 4 comments
rossj commented 2021-01-20 19:57:44 +00:00 (Migrated from github.com)

Hi there, according to MS-WMF 2.3.2.3, it seems that WMF files may start with a META_PLACEABLE record before the META_HEADER record. These files currently give a "Header: Type 52695 must be 1 or 2" error with js-wmf.

I think these files could be supported by updating image_size_prepped_bytes() to check for files that start with the META_PLACEABLE signature of 0x9AC6CDD7, and then skipping ahead 22 bytes to get to the actual META_HEADER record.

As for sample files, it looks like most of the "iPres Systems Showcase" WMF files are of this "placeable" variant.

I'm happy to work on a PR if you would like.

Hi there, according to [MS-WMF 2.3.2.3](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-wmf/828e1864-7fe7-42d8-ab0a-1de161b32f27), it seems that WMF files may start with a `META_PLACEABLE` record before the `META_HEADER` record. These files currently give a "Header: Type 52695 must be 1 or 2" error with js-wmf. I think these files could be supported by updating `image_size_prepped_bytes()` to check for files that start with the `META_PLACEABLE` signature of 0x9AC6CDD7, and then skipping ahead 22 bytes to get to the actual META_HEADER record. As for sample files, it looks like most of the ["iPres Systems Showcase"](https://www.webarchive.org.uk/datasets/ipres.ds.1/systems-showcase-files/collected/) WMF files are of this "placeable" variant. I'm happy to work on a PR if you would like.
SheetJSDev commented 2021-01-29 16:26:57 +00:00 (Migrated from github.com)

Good catch! The initial problem was to support Word charts and image annotations, which are usually standard WMF. A PR would be appreciated :)

Good catch! The initial problem was to support Word charts and image annotations, which are usually standard WMF. A PR would be appreciated :)
wuniencheng commented 2021-09-01 08:10:26 +00:00 (Migrated from github.com)

Hi, may I know is the pull request applied? I run into the same error when trying to display WMF files generated by MathType, a Word extension for editing math formulas. I will be very appreciative of any help on this issue 💯

Hi, may I know is the pull request applied? I run into the same error when trying to display WMF files generated by MathType, a Word extension for editing math formulas. I will be very appreciative of any help on this issue 💯
gaby64 commented 2022-03-22 20:55:22 +00:00 (Migrated from github.com)

hello, I am interested in such a version as well

hello, I am interested in such a version as well
gaby64 commented 2022-03-22 20:57:15 +00:00 (Migrated from github.com)

I tried creating my own code from this https://joseluisbz.wordpress.com/2013/08/06/obtaining-size-or-dimension-of-images/

but its not working

var uint8 = Uint8Array.from(atob(base64), c => c.charCodeAt(0));
var dV = new DataView(uint8.buffer);
var w, h;
var magic = dV.getUint32(0, true).toString(16).toUpperCase();
if(magic == '9AC6CDD7') {
w = dV.getUint16(10, true)-dV.getUint16(6, true);
h = dV.getUint16(12, true)-dV.getUint16(8, true);
}
else {
var PWMF = 18;
var SizeR;
while(PWMF < dV.byteLength) {
	SizeR = dV.getUint32(0, true);
	var m = dV.getUint16(4, true).toString(16).toUpperCase();
	console.log(m);
	if (m == "0C02") { //020C
		w = dV.getUint16(PWMF+8, true);
		h = dV.getUint16(PWMF+6, true);
	}
	PWMF += (2*SizeR);
}
}
I tried creating my own code from this https://joseluisbz.wordpress.com/2013/08/06/obtaining-size-or-dimension-of-images/ but its not working ``` var uint8 = Uint8Array.from(atob(base64), c => c.charCodeAt(0)); var dV = new DataView(uint8.buffer); var w, h; var magic = dV.getUint32(0, true).toString(16).toUpperCase(); if(magic == '9AC6CDD7') { w = dV.getUint16(10, true)-dV.getUint16(6, true); h = dV.getUint16(12, true)-dV.getUint16(8, true); } else { var PWMF = 18; var SizeR; while(PWMF < dV.byteLength) { SizeR = dV.getUint32(0, true); var m = dV.getUint16(4, true).toString(16).toUpperCase(); console.log(m); if (m == "0C02") { //020C w = dV.getUint16(PWMF+8, true); h = dV.getUint16(PWMF+6, true); } PWMF += (2*SizeR); } } ```
Sign in to join this conversation.
No description provided.