js-wmf
js-wmf copied to clipboard
Support WMF files that start with META_PLACEABLE record
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.
Good catch! The initial problem was to support Word charts and image annotations, which are usually standard WMF. A PR would be appreciated :)
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 💯
hello, I am interested in such a version as well
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);
}
}
Add support for META_PLACEABLE record in my fork.
What about support for all the missing record types?