forked from wvbe/docxml
-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
I triaged the problem to the following summary but not sure what is the correct way to fix it.
If the document.xml contains image that has an anchor it crashes
<w:drawing>
<wp:anchor allowOverlap="1" behindDoc="0" distB="0" distT="0" distL="114300"
if everything stays the same and anchor is changed to inline it passes
<w:drawing>
<wp:inline distB="114300" distT="114300" distL="114300" distR="114300">
it comes down to this line in fromNode for Image class
const inlineNode = evaluateXPathToFirstNode(`./${QNS.wp}inline`, node);
if I change it to
const inlineNode = evaluateXPathToFirstNode(`./${QNS.wp}anchor`, node);
Brute force "solution" doesn't crash but I presume it doesn't work as intended for anchor use case
let inlineNode
try {
inlineNode = evaluateXPathToFirstNode(`./${QNS.wp}inline`, node);
} catch (error) {
inlineNode = evaluateXPathToFirstNode(`./${QNS.wp}anchor`, node);
}
Below two DOCX files that reproduce the problem (anchor and inline version of the same image), document.xml is the sme except this single change.
describe('docxml visitor debug', () => {
it('debug docx', async () => {
const archive_inline = await fs.readFile(path.join(__dirname, '.data/debug_min_inline.docx'))
const docx_inline = await Docx.fromArchive(archive_inline)
// below it crashes
const archive_anchor = await fs.readFile(path.join(__dirname, '.data/debug_min_anchor.docx'))
const docx_anchor = await Docx.fromArchive(archive_anchor)
})
})
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels