使用XSL-FO渲染或转换pdf中的html表

时间:2014-01-07 09:35:43

标签: pdf pdf-generation jira velocity xsl-fo

我正在尝试将Table Grid类型的字段中的数据导出为PDF格式。在实现它的同时,我得到了导出到PDF O / P的此表格网格字段的以下html代码。我试图将此HTML表转换为XSL-FO并将其输出为PDF。对不起,我完全不喜欢这种做法。如何将此HTML表格转换为PDF作为最终的O / P.任何人都可以分享将此HTML表格转换为XSL-FO表并将其输出为PDF的确切方法。

下面是XSL-FO和Velocity模板代码,用于获取customfield对象的HTML引用,然后使用 $ pdfRenderer 工具我尝试在PDF导出中显示表格网格值。

<!-- Table Grid Customfield 'customfield_10300' -->
    #set ($customfieldId = "customfield_10300")
    #set ($customfield = $customFieldManager.getCustomFieldObject($customfieldId))
    #set ($moduleDescriptor = $customfield.getCustomFieldType().getDescriptor())
    #set ($fieldLayoutItem = ${fieldLayout.getFieldLayoutItem($customfieldId)})
    #set ($htmlMarkup = $moduleDescriptor.getViewHtml($customfield, "htmlMarkup",  $issue, $fieldLayoutItem)) 

    <fo:table space-before="3mm" border="thin solid #CCCCCC">
      <fo:table-body>
          <fo:table-row>
           <fo:table-cell padding="4px">
               <fo:block background-color="#EEEEEE" padding="4px" font-weight="bold" start-indent="4px" end-indent="4px">$i18n.getText($customfield.name):
               </fo:block>
             </fo:table-cell>
      <fo:table-cell padding="4px">                                <fo:block>$pdfRenderer.asRendered($issue, $customfieldId, $htmlMarkup)       </fo:block>
   </fo:table-cell>
 </fo:table-row>
</fo:table-body>

但是,此 $ htmlMarkup 会显示以下表格网格自定义字段的完整HTML代码。

<div id="customfield_10300_grid-container" class="idalkogrid-view" style="overflow-y: visible; overflow-x:visible;" rel="customfield_10300" name="idalko-grid-field">
<table id="customfield_10300_grid"></table>
    <div id="customfield_10300_grid_pager"></div>
        <div id="customfield_10300_filter"></div>
            <table class="grid" border="0" cellspacing="0" cellpadding="0" style="width: 100%;">
            <tr bgcolor="#f0f0f0">
                <th>Summary</th>
                <th>Assignee</th>
                <th>Status</th>
                <th>Date due</th>
            </tr>
            <tr bgcolor="#ffffff">
                <td style="border: 1px solid #CCCCCC; padding: 2px;"> Table Grid Summary1 </td>
                <td style="border: 1px solid #CCCCCC; padding: 2px;"> admin </td>
                <td style="border: 1px solid #CCCCCC; padding: 2px;"> Open </td>
                <td style="border: 1px solid #CCCCCC; padding: 2px;"> 2014-01-14 </td>
            </tr>
</table> 
</div>

如何使 $ htmlMarkup 变量在PDF中显示具有适当值的表格网格

1 个答案:

答案 0 :(得分:0)

您要求的JIRA加载项JIRA PDF View Plugin,正式支持自3.4.0版以来的Table Grid Editor自定义字段。

这意味着它需要任何自定义编码,默认情况下,表字段将导出为PDF。

请参阅产品文档中的details

(免责声明:此问题与商业产品有关,我是开发人员。)

相关问题