pwndoc / pwndoc

Pentest Report Generator
https://pwndoc.github.io/pwndoc
MIT License
2.29k stars 424 forks source link

Custom Section image inclusion #79

Closed x3lq closed 3 years ago

x3lq commented 3 years ago

When creating a custom section with images, the text can be inserted but as soon as an image is added the template fails to be created.

It looks like the following in the frontend image

In the word template itself it looks like the following:

Bildschirmfoto 2021-01-25 um 16 10 56

As I couldn't figure out how you start a paragraph, which should be the following: {#cleanup}{/cleanup} I am not sure if this helps the problem.

The backend-logs are reporting the following: `Error:

{ TypeError: Cannot read property '0' of undefined at ImageModule.getRenderedPart (/app/node_modules/docxtemplater-image-module-free/js/index.js:180:54) at ImageModule.render (/app/node_modules/docxtemplater-image-module-free/js/index.js:134:17) at moduleRender (/app/node_modules/docxtemplater/js/render.js:14:30) at /app/node_modules/docxtemplater/js/render.js:44:26 at Array.map () at Object.render (/app/node_modules/docxtemplater/js/render.js:42:24) at loopOver (/app/node_modules/docxtemplater/js/modules/loop.js:305:35) at ScopeManager.functorIfInverted (/app/node_modules/docxtemplater/js/scope-manager.js:159:9) at ScopeManager.loopOverValue (/app/node_modules/docxtemplater/js/scope-manager.js:184:16) at ScopeManager.loopOver (/app/node_modules/docxtemplater/js/scope-manager.js:153:19) at LoopModule.render (/app/node_modules/docxtemplater/js/modules/loop.js:334:39) at moduleRender (/app/node_modules/docxtemplater/js/render.js:14:30) at /app/node_modules/docxtemplater/js/render.js:44:26 at Array.map () at Object.render (/app/node_modules/docxtemplater/js/render.js:42:24) at loopOver (/app/node_modules/docxtemplater/js/modules/loop.js:305:35) properties: { file: 'word/document.xml' } } `

Could you please add some clarity wether you need the paragraph or not and if so what it should be. Furthermore investigating the issue would be great, if I can be of any further assistance please say so

Kindest regards

yeln4ts commented 3 years ago

There is a description for HTML data in the doc: https://pwndoc.github.io/pwndoc/#/docxtemplate?id=html-values-from-text-editors

You have to add a paragraph after {%images}

nobox910 commented 3 years ago

@x3lq let try below {-w:p cleanup.text}{@text | convertHTML} {-w:p images}{%image} Image 1 - {caption}{/images}{/cleanup.text}

{%image} without 's'

2021-01-26_16-52-33
x3lq commented 3 years ago

Okay so we got it working.

In the end our issues were that we didn't close the paragraph, which caused the original issue. Yet it works for us with {%image}and NOT with {%images} as it states in the documentation. This might be an issue and maybe needs a fix in the Documentation.

Our working solution looks like the following:

Bildschirmfoto 2021-01-27 um 09 55 09

Thank you all for you help 👍

yeln4ts commented 3 years ago

Updated documentation