Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support WMF files that start with META_PLACEABLE record #1

Open
rossj opened this issue Jan 20, 2021 · 5 comments
Open

Support WMF files that start with META_PLACEABLE record #1

rossj opened this issue Jan 20, 2021 · 5 comments

Comments

@rossj
Copy link

rossj commented Jan 20, 2021

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.

@SheetJSDev
Copy link
Contributor

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

@wuniencheng
Copy link

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
Copy link

gaby64 commented Mar 22, 2022

hello, I am interested in such a version as well

@gaby64
Copy link

gaby64 commented Mar 22, 2022

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);
}
}

@Mictronics
Copy link

Add support for META_PLACEABLE record in my fork.
What about support for all the missing record types?

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

No branches or pull requests

5 participants