ColdFusion PDF生成-cfdocument的其他选项

ColdFusion PDF生成-cfdocument的其他选项,pdf,coldfusion,webkit,cfdocument,Pdf,Coldfusion,Webkit,Cfdocument,我只是想知道是否有其他选项可以使用,可以利用web kit API实现ColdFusion 或者,如果有一个Java版本,但是上面有一个很好的ColdFusion包装器,这比解决Java的所有复杂问题都要简单。我在幕后使用iText。为此,我创建了一个非常强大的打印框架(用于打印表单)和报告框架(表格报告)。多年来,我对它进行了微调,它可以生成数十万行的PDF,没有问题。它可以深入4个孩子,并具有许多功能/设置。对不起,太宽了。如果你走这条路,我可以在细节上提供帮助 我在onApplicatio

我只是想知道是否有其他选项可以使用
,可以利用web kit API实现ColdFusion


或者,如果有一个Java版本,但是上面有一个很好的ColdFusion包装器,这比解决Java的所有复杂问题都要简单。

我在幕后使用iText。为此,我创建了一个非常强大的打印框架(用于打印表单)和报告框架(表格报告)。多年来,我对它进行了微调,它可以生成数十万行的PDF,没有问题。它可以深入4个孩子,并具有许多功能/设置。对不起,太宽了。如果你走这条路,我可以在细节上提供帮助

我在onApplicationStart中使用JavaLoader()加载iText(以及我的应用程序中需要的其他JAR)


然后,在报告框架中,这就是开始初始化所有内容的方式。(这只是一个小片段,其中涉及的内容远不止这些,但如果你决定这样做的话,应该足以让你开始胡闹了)


pathAndFile=request.reportDir.fpath&request.reportDir.pdfFile;
session.reports[libRptId].pathAndFile=pathAndFile;
加载器=服务器['1111-2222-3333444455556666']//我们的iText版本目前是2.1.3(是的,我们需要尽快更新)
document=loader.create(“com.lowagie.text.document”);
PdfWriter=loader.create(“com.lowagie.text.pdf.PdfWriter”);
FileOutputStream=createObject(“java”、“java.io.FileOutputStream”);
myFile=CreateObject(“java”,“java.io.File”).init(pathAndFile)//仅用于在生成pdf时获取实时显示在屏幕上的文件大小
Color=createObject(“java”、“java.awt.Color”);
element=loader.create(“com.lowagie.text.element”);
Chunk=loader.create(“com.lowagie.text.Chunk”);
PageSize=loader.create(“com.lowagie.text.PageSize”);
HeaderFooter=loader.create(“com.lowagie.text.HeaderFooter”);
Rectangle=loader.create(“com.lowagie.text.Rectangle”);
段落=loader.create(“com.lowagie.text.paration”);
PdfPCell=loader.create(“com.lowagie.text.pdf.PdfPCell”);
PdfPTable=loader.create(“com.lowagie.text.pdf.PdfPTable”);
Phrase=loader.create(“com.lowagie.text.Phrase”);
Font=loader.create(“com.lowagie.text.Font”);
FontFactory=loader.create(“com.lowagie.text.FontFactory”);

我们使用一个名为的小应用程序,它允许您从任何HTML页面创建PDF。它与命令行一起工作,因此您可以使用
来运行它。 我还使用以下代码确保PDF在输出前已完全成形:

<cfset truePDF = "false">
<cfloop condition="NOT truePDF">
    <cfif fileExists("#pathname##filename#")>
        <cffile action="read" file="#pathname##filename#" variable="pdfContent">
        <cfif findNoCase('%%EOF',right(pdfContent,1024)) GT 0>
            <cfset truePDF = "true">
        </cfif>
    </cfif>
</cfloop>
<cfoutput>#pdfContent#</cfoutput>

#PDF内容#

您使用的是哪个版本的ColdFusion?足够高,可以有一个cfpdf标签吗?@user125264,我添加了更多细节来回答。
<cfscript>
    pathAndFile      = request.reportDir.fpath&request.reportDir.pdfFile;
    session.reports[libRptId].pathAndFile = pathAndFile;
    loader           = server['1111-2222-3333444455556666']; //Our iText version which currently is 2.1.3 (yes, we need to update soon)
    document         = loader.create("com.lowagie.text.Document");
    PdfWriter        = loader.create("com.lowagie.text.pdf.PdfWriter");
    FileOutputStream = createObject("java", "java.io.FileOutputStream");
    myFile           = CreateObject("java","java.io.File").init(pathAndFile); //Only used for getting the file size to display on screen in real-time as the pdf is being generated
    Color            = createObject("java", "java.awt.Color");
    element          = loader.create("com.lowagie.text.Element");
    Chunk            = loader.create("com.lowagie.text.Chunk");
    PageSize         = loader.create("com.lowagie.text.PageSize");
    HeaderFooter     = loader.create("com.lowagie.text.HeaderFooter");
    Rectangle        = loader.create("com.lowagie.text.Rectangle");
    Paragraph        = loader.create("com.lowagie.text.Paragraph");
    PdfPCell         = loader.create("com.lowagie.text.pdf.PdfPCell");
    PdfPTable        = loader.create("com.lowagie.text.pdf.PdfPTable");
    Phrase           = loader.create("com.lowagie.text.Phrase");
    Font             = loader.create("com.lowagie.text.Font");
    FontFactory      = loader.create("com.lowagie.text.FontFactory");
</cfscript>

<!--- Define our different fonts --->
<cfset fontTitle       = FontFactory.getFont("Arial", 10,                 Font.BOLD,       Color.BLACK)>
<cfset fontSubRptTitle = FontFactory.getFont("Arial", 10,                 Font.BOLDITALIC, Color.BLACK)>
<cfset fontStandard    = FontFactory.getFont("Arial", 8,                  Font.NORMAL,     Color.BLACK)>
<cfset fontHeader      = FontFactory.getFont("Arial", 9,                  Font.NORMAL,     Color.GRAY)>
<cfset fontFooter      = FontFactory.getFont("Arial", 9,                  Font.NORMAL,     Color.GRAY)>
<cfset fontColHeader   = FontFactory.getFont("Arial", rpt.fontsizeLabel,  Font.BOLD,       Color.BLACK)>
<cfset fontData        = FontFactory.getFont("Arial", rpt.fontsize,       Font.NORMAL,     Color.BLACK)>

<cfset marginTop    =  round(72 / (100 / (rpt.marginTop * 100))) >
<cfset marginright  =  round(72 / (100 / (rpt.marginright * 100))) >
<cfset marginbottom =  round(72 / (100 / (rpt.marginbottom * 100))) >
<cfset marginleft   =  round(72 / (100 / (rpt.marginleft * 100))) >

<!--- Page Setup (PageSize and Margins)  For the margins 18 = .25inches --->
<cfif rpt.pagetype eq "letter">
    <cfif rpt.orientation eq "portrait">
        <cfset document = document.init(PageSize.LETTER, marginleft, marginright, marginTop, marginbottom)>
    <cfelse><!--- Landscape --->
        <cfset document = document.init(PageSize.LETTER.rotate(), marginleft, marginright, marginTop, marginbottom)>
    </cfif>
<cfelseif rpt.pagetype eq "legal">
    <cfif rpt.orientation eq "portrait">
        <cfset document = document.init(PageSize.LEGAL, marginleft, marginright, marginTop, marginbottom)>
    <cfelse><!--- Landscape --->
        <cfset document = document.init(PageSize.LEGAL.rotate(), marginleft, marginright, marginTop, marginbottom)>
    </cfif>
<cfelseif rpt.pagetype eq "ledger">
<!--- We found that ledger logic is backward from letter and legal. Long edge is portrait 11 X 17 and landscape mode = 17 X 11 --->
    <cfif rpt.orientation eq "portrait">
        <cfset document = document.init(PageSize.LEDGER.rotate(), marginleft, marginright, marginTop, marginbottom)>
    <cfelse><!--- Landscape --->
        <cfset document = document.init(PageSize.LEDGER, marginleft, marginright, marginTop, marginbottom)>
    </cfif>
</cfif>
<cfset writer = PdfWriter.getInstance(document, FileOutputStream.init(pathAndFile))> <!--- Init the variable "document" that we write to --->
<cfset truePDF = "false">
<cfloop condition="NOT truePDF">
    <cfif fileExists("#pathname##filename#")>
        <cffile action="read" file="#pathname##filename#" variable="pdfContent">
        <cfif findNoCase('%%EOF',right(pdfContent,1024)) GT 0>
            <cfset truePDF = "true">
        </cfif>
    </cfif>
</cfloop>
<cfoutput>#pdfContent#</cfoutput>