docxHtml nested HTML Table issue



  • We found an issue where docxHtml does not render content where the html has a nested table.
    The client would craft the html in CKEditor and create a html table that contains another table inside the parents TD.
    When using the docxHtml it throws an exception.

    Error while executing docx recipe
    (because) invalid docx meta child "row" found in cell
    Error: Invalid docx meta child "row" found in cell
        at convertDocxMetaToNodes (/app/node_modules/@jsreport/jsreport-docx/lib/postprocess/html/convertDocxMetaToNodes.js:192:15)
        at processParagraphHtmlEmbedContainer (/app/node_modules/@jsreport/jsreport-docx/lib/postprocess/html/index.js:130:28)
        at /app/node_modules/@jsreport/jsreport-docx/lib/postprocess/html/index.js:35:39
        at doReplace (/app/node_modules/@jsreport/jsreport-docx/lib/recursiveStringReplaceAsync.js:139:21)
        at replacerFn (/app/node_modules/@jsreport/jsreport-docx/lib/recursiveStringReplaceAsync.js:148:14)
        at assignReplacement (/app/node_modules/@jsreport/jsreport-docx/lib/recursiveStringReplaceAsync.js:102:10)
        at /app/node_modules/@jsreport/jsreport-docx/lib/recursiveStringReplaceAsync.js:110:12
        at Array.map (<anonymous>)
        at execute (/app/node_modules/@jsreport/jsreport-docx/lib/recursiveStringReplaceAsync.js:109:28)
        at processString (/app/node_modules/@jsreport/jsreport-docx/lib/recursiveStringReplaceAsync.js:152:10)
    wrapped by:
    Error: Error while executing docx recipe
    (because) invalid docx meta child "row" found in cell
        at module.exports (/app/node_modules/@jsreport/jsreport-core/lib/shared/createError.js:10:13)
        at WorkerReporter.createError (/app/node_modules/@jsreport/jsreport-core/lib/shared/reporter.js:53:12)
        at module.exports (/app/node_modules/@jsreport/jsreport-docx/lib/processDocx.js:117:20)
        at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
        at async module.exports (/app/node_modules/@jsreport/jsreport-docx/lib/recipe.js:35:28)
        at async invokeRender (/app/node_modules/@jsreport/jsreport-core/lib/worker/render/render.js:93:5)
        at async WorkerReporter._render (/app/node_modules/@jsreport/jsreport-core/lib/worker/render/render.js:148:7)
        at async /app/node_modules/@jsreport/jsreport-core/lib/worker/reporter.js:227:24
        at async processAndResponse (/app/node_modules/@jsreport/advanced-workers/lib/workerHandler.js:41:17)
    

    I have created a playground for anyone to see my issue.
    [https://playground.jsreport.net/w/nandihno/gURqcayb](link url)

    In this playground the HTML that it tries to render I first apply some regex to remove some garbage characters and make sure the html is clean of those characters. Thus the html will look like this

    <table style="border-collapse:collapse">
    	<tbody>
    		<tr>
    			<td style="border-bottom:1px solid black; border-left:1px solid black; border-right:1px solid black; border-top:1px solid black; vertical-align:top; width:576px">
    			<p><span style=""><span>Header 1</span></span></p>
    			</td>
    		</tr>
    		<tr>
    			<td style="border-bottom:1px solid black; border-left:1px solid black; border-right:1px solid black; border-top:none; height:93px; vertical-align:top; width:576px">
    			<table style="border-collapse:collapse">
    				<tbody>
    					<tr>
    						<td style="border-bottom:1px solid black; border-left:1px solid black; border-right:1px solid black; border-top:1px solid black; vertical-align:top; width:281px">
    						<p><span style=""><span>Deakin</span></span></p>
    
    						<ul>
    							<li><span style=""><span>Bullet 1</span></span></li>
    							<li><span style=""><span>Bullet 2</span></span></li>
    							<li><span style=""><span>Bullet 3</span></span></li>
    						</ul>
    						</td>
    						<td style="border-bottom:1px solid black; border-left:none; border-right:1px solid black; border-top:1px solid black; vertical-align:top; width:281px">
    						<p><span style=""><span>External</span></span></p>
    
    						<ul>
    							<li><span style=""><span>Bullet 1a</span></span></li>
    							<li><span style=""><span>Bullet 2a</span></span></li>
    							<li><span style=""><span>Bullet 3a</span></span></li>
    						</ul>
    						</td>
    					</tr>
    				</tbody>
    			</table>
    
    			<p> </p>
    			</td>
    		</tr>
    		<tr>
    			<td style="border-bottom:1px solid black; border-left:1px solid black; border-right:1px solid black; border-top:none; vertical-align:top; width:576px">
    			<p> </p>
    			</td>
    		</tr>
    	</tbody>
    </table>
    

    As displayed the HTML contains a nested table inside its parent TD. Yet docxHtml throws the exception.

    so far i have been able to identify if any html contains nested tables and then i extract the nested table and put it next to the parent table. But ideally docxHtml should be able to render this.

    Thanks


  • administrators

    hi @nandihno

    yes, this exception is on purpose, it is added there because nested tables are not supported yet, we don't have any priority for it at the moment, but check this for updates when it happens.


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.