Javascript jsPDF向表中添加错误的空格

Javascript jsPDF向表中添加错误的空格,javascript,html,angularjs,jspdf,Javascript,Html,Angularjs,Jspdf,我正在尝试使用jsPDF的fromHTML函数将html表转换为pdf。这在很大程度上是可行的,但是对于我的一个屏幕,表被错误地添加了。是显示屏幕上的输入、输出以及屏幕另一部分正确生成的输出的图像 以下是表格的HTML: <table class="table table-condensed"> <thead> <tr> <th></th> <th>{{

我正在尝试使用jsPDF的fromHTML函数将html表转换为pdf。这在很大程度上是可行的,但是对于我的一个屏幕,表被错误地添加了。是显示屏幕上的输入、输出以及屏幕另一部分正确生成的输出的图像

以下是表格的HTML:

<table class="table table-condensed">
    <thead>
        <tr>
            <th></th>
            <th>{{ report.leftHeader }}</th>
            <th>{{ report.rightHeader }}</th>
            <th>Difference</th>
        </tr>
    </thead>
    <tbody id="tableBody">
        <tr ng-repeat="metric in report.leftMetrics">
            <td>{{ metric.label }}</td>
            <td ng-switch="metric.leftEditable && !printerFriendly">
                <input ng-switch-when="true" ng-model="metric.leftValue" ng-change="report.updateComputedValues(metric);" min="0" required />
                <span ng-switch-default>{{ metric.leftValue | numberFormat : metric.dataType }}</span>
            </td>
            <td ng-switch="metric.rightEditable && !printerFriendly">
                <input ng-switch-when="true" ng-model="metric.rightValue" ng-change="report.updateComputedValues(metric)" min="0" required />
                <span ng-switch-default>{{ metric.rightValue | numberFormat : metric.dataType }}</span>
            </td>
            <td>{{ metric.rightValue - metric.leftValue | zeroDifference | numberFormat : metric.dataType }}</td>
        </tr>
    </tbody>
</table>

{{report.leftHeader}
{{report.rightHeader}
差别
{{metric.label}
{{metric.leftValue}numberFormat:metric.dataType}
{{metric.rightValue}numberFormat:metric.dataType}
{{metric.rightValue-metric.leftValue |零差| numberFormat:metric.dataType}
为了帮助那些不知道角度的人理解发生了什么,该表为leftMetrics数组中的每个值添加了一个正文行,并且在每行中,如果输入框是可编辑的,则显示一个输入框;如果为只读或打印为pdf,则显示一个范围。“| numberFormat…”是一个角度过滤器,其作用只是将值的显示更改为货币、十进制、整数等


正如您所看到的,跨度内没有换行符,但无论出于何种原因,jsPDF都在添加它们。我尝试过移除过滤器,以确保它们不会增加中断,但这并没有改变任何事情。我一直在查看函数的源代码,但也看不到任何会添加中断的内容。以前有没有人见过这个问题,或者有没有线索告诉我下一步应该去哪里寻找这个问题的解决方案?

在逐步执行jsPDF fromHTML函数后,结果证明它的工作是正确的。出现此问题是因为上面的span标记在jsPDF中的table函数正在读取的单元格的textContent属性中添加了空格。通过对ng开关进行返工,我能够通过后备方案中的一些冗余绕过跨度使用