0

我正在研究 ColdFusion,试图将 HTML 表格导出到 PDF 文档。此 HTML 表格从外部 CSS 文件派生其样式。问题是导出时,表格格式未在 pdf 文档中导出。我需要将表格导出为在浏览器上呈现的内容(连同其格式)。

以下是相同的代码。

内容.cfm

<cfsavecontent variable="pdfREPORT">
<table id="dep" class="main_table" cellpadding="0">
    <tr class="h1">

                    <th>cell1</th>
                    <th>cell2</th>
                    <th>cell3</th>
                    <th>cellN</th>
    </tr>
            .
    .
    .
            <cfoutput query="qry1">
                <tr>
                        <td>#qry1.col1#</td> 
                        <td>#qry1.col2#</td> 
                        <td>#qry1.col3#</td> 
                        <td>#qry1.colN#</td> 
                </tr>                  
    </cfoutput>     
</table>
</cfsavecontent> 

extract_to_pdf.cfm

<cfsetting enablecfoutputonly="true">
<cfheader name="Content-Disposition" value="inline;filename=test.pdf">
<cfcontent type="application/pdf">
<cfdocument format="PDF" localurl="yes" marginTop=".25" marginLeft=".25" marginRight=".25" marginBottom=".25"
        pageType="custom" pageWidth="8.5" pageHeight="10.2" mimetype="text/html">
<html> 
    <head>      
        <style>
            <cfinclude template = "styles/tableStyle.css">
        </style>
    </head>
    <body>
        <cfoutput>#Form.pdfREPORT#</cfoutput>
    </body>
</html>
</cfdocument>

非常感谢任何帮助。

4

1 回答 1

3

显示您正在使用的代码将帮助我们回答这个问题,但是,您的cfdocument块中是否有您的 CSS 链接?如果你这样做了,但它仍然无法正常工作,请尝试:

<cfdocument ...>
    <html> 
        <head>      
            <style>
                <cfinclude template = "yourCSSfile.css">
            </style>
        </head>
        <body>
            <table>
                ...
            </table>
        </body>
    </html>
</cfdocument>
于 2013-03-05T12:56:44.043 回答