- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我知道以前有人问过这个问题,但解决方案是 2.5 多年前的,所以我问是否有人设计或知道使用 CF9 解决问题的更优雅的解决方案。任何人都可以确认 CF10 是否支持“page-break-inside: avoid”规则?
How can I prevent page-break in CFDocument from occuring in middle of content?
COLDFUSION: cfdocument and forcing a pagebreak
这几乎就是我的做法。我估计,根据它是什么类型的页面,我可以在必须强制分页之前容纳 9 或 11 行数据。当然,这很容易破裂,所以如果有人知道解决方案的任何演变,我将不胜感激。
最佳答案
我相信我找到了一个伪解决方案。这基本上就是我在上面的评论中所说的。我做了一个最好的猜测,看看它是否适合使用 cfpdf 的 getInfo.totalPages 的值。如果合适,很好,将其合并到最终文档中,如果不合适,请再试一次少一行。
这样做的缺点是它会减慢速度,并且您不能使用 cfdocument 使之变得简单的某些东西,例如弄乱页眉和页脚。话虽如此,该解决方案的第 2 部分可能是记录适合页面中的行数,而不是合并页面并使用 cfdocument 和这些值作为循环约束再次重建整个文档,并在之后强制分页.事实上,下面的解决方案已经有点耗时,因此在 cfdocument 标签内再次构建它可能不适用于高流量站点。
错误解决方法:看起来 cfdocument 有一个错误,当使用 name 属性将文档保存到内存时,它会删除背景颜色。解决方法是将 cfdocument 标记删除到外部文件中。我看到一位程序员将其放入 cfc,我发现可以使用简单的 cfinclude。
我希望有人觉得这有帮助,如果您知道更好的方法,请发表评论。
<cfset reviewText = "Lorem ipsum dolor sit amet, + lots of characters.">
<cfset estimatedRowsPerPage = 7> <!--- This is the max number of records you want to try on each page. The larger the gap between max and actual will slow down the process. Used to reset attemptedRowsPerPage if the value changes --->
<cfset attemptedRowsPerPage = estimatedRowsPerPage> <!---- number of rows attempted to add to the page --->
<cfset totalRowsOutput = 0><!--- this is the number of records successfully saved to the final PDF --->
<cfset recordCount = 20> <!--- this is the query's record count --->
<!--- cfpdf cannot create a file from scratch and cfdocument requires some content so a container object cannot be created without at least one page. This page will be deleted later --->
<cfdocument format="pdf" marginbottom=".25" margintop=".25" marginleft=".25" marginright=".25" name = "finalDocument">Delete me</cfdocument>
<cfloop condition="totalRowsOutput lt recordCount">
<!--- create what *should* be a single page document --->
<cfdocument format="pdf" marginbottom=".25" margintop=".25" marginleft=".25" marginright=".25" name = "testDocument">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>A title</title>
</head>
<body>
<table border="1">
<tr>
<td>Row:</td>
<td>Title:</td>
<td>Author:</td>
<td>Price:</td>
<td>Average Rating:</td>
<td>Reviews:</td>
</tr>
<cfoutput>
<cfloop from = "1" to = "#attemptedRowsPerPage#" index = "i">
<tr>
<td>
#i#
</td>
<td nowrap="nowrap">
#mid(reviewText,1,randRange(4,10))#
</td>
<td nowrap="nowrap">
#mid(reviewText,20,randRange(8,20))#
</td>
<td>
$10.00
</td>
<td>
#randRange(1,5)#
</td>
<td>
#mid(reviewText,1,randRange(10,700))#
</td>
</tr>
</cfloop>
</cfoutput>
</table>
</body>
</html>
</cfdocument>
<!--- get the document info to see if the page count = 1 --->
<cfpdf action="getinfo" source="testDocument" name="testInfo">
<cfif testInfo.totalPages gt 1>
<!--- if the page count is greater than 1 we need to try again with one less record. --->
<cfset attemptedRowsPerPage -= 1>
<cfelse>
<!--- merge the new single page to the final document --->
<cfpdf action = "merge" name = "finalDocument">
<cfpdfparam source="finalDocument">
<cfpdfparam source="testDocument">
</cfpdf>
<cfset totalRowsOutput += attemptedRowsPerPage>
<!--- if the page count = 1, we need to increment the startAttempt and reset the attemptedRowsPerPage unless attemptedRowsPerPage = recordCount --->
<cfif totalRowsOutput lt recordCount>
<!--- don't try to output more than exist --->
<cfset attemptedRowsPerPage = estimatedRowsPerPage+totalRowsOutput lt recordCount ? estimatedRowsPerPage : recordCount-totalRowsOutput>
</cfif>
</cfif>
</cfloop>
<!--- delete the manditory page needed to create our final document --->
<cfpdf action="deletePages" pages="1" source="finalDocument" name="finalDocument">
<!--- see "http://www.raymondcamden.com/index.cfm/2007/7/12/ColdFusion-8-Working-with-PDFs--A-Problem" to see why you need toBinary --->
<cfcontent type="application/pdf" variable="#toBinary(finalDocument)#">
关于coldfusion - cfdocument 防止在行中分页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12061281/
我正在使用 Coldfusion10 并遇到此错误: The following information is meant for the website developer for debuggin
我知道以前有人问过这个问题,但解决方案是 2.5 多年前的,所以我问是否有人设计或知道使用 CF9 解决问题的更优雅的解决方案。任何人都可以确认 CF10 是否支持“page-break-inside
如何在创建 PDF 的 cfdocument 中调整页脚的大小? My Header This text I want to be my foo
使用 cfdocument 时,我们的某些页面的顶行被切断,导致无法阅读。我知道 7 中有一个错误,据说在 8 中已修复。我们正在使用 8,0,1,195765,但问题仍然存在。我所有的搜索都将我引向
我有一个通过 CFDocument 标签生成的 PDF。当它生成 PDF 时,您单击“打印机”图标以弹出打印对话框。对于页面大小调整和处理,如果将其设置为“适合”或“缩小超大页面”,则打印效果很好。如
在这里,根据我的业务逻辑,我应该支持所有语言。所以我根据国家/地区选择显示了一个字符串。我这边一切正常。但是遇到问题 cfdocument .在这里,我想出了我的示例/演示代码。 注意:我已经看过 C
我正在使用 cfdocument 创建一个多页文档(使用动态文本创建,因此可以有任意数量的页面,甚至一页)。 我可以用 为每一页添加页脚,但有什么办法只能在文档的最后一页添加页脚? 谢谢。 最佳答案
我正在 ColdFusion 中创建动态 PDF,但遇到“分页”问题。相关页面可能有 1 条记录,或最多 60 条以上记录。每条记录显示在表的 2 行中。一些返回的记录在页面之间拆分(第一行位于第一页
下面的 HTML/CSS 在最近的浏览器中有效,但在 CF9 的 cfdocument 中无效。有人有想法吗? 我知道什么?是的!我知道 CF 的 cfdocument 支持一组有限的 CSS 属性。
我正在使用 cfdocument 标签从 html/css 动态生成一个 PDF 文件。有些内容 block 我不想跨越多个页面。 经过一些搜索,我发现根据文档支持样式“page-break-insi
我一直在使用 Coldfusion cfdocument 生成 PDF。然而,自从我的试用期到期后,我的 PDF 文件上就出现了这个难看的水印,上面写着“Adobe ColdFusion Develo
我通过 cfdocument 生成一个 pdf 文件并将其发送给用户。但是图像没有出现在该 pdf 文档中。 我不确定我应该使用什么类型的路径绝对/相对以及 localurl 属性的值应该是什么? 最
我有一个使用 创建 PDF 的小脚本写一个PDF。它看起来像这样(最小化代码): ☒ 当我的数据包含像 ☐ 这样的高 ASCII 字符时(☑) 我收到一个错误:
我在 CFdocument 上看到参数,例如高度、宽度和单位,但没有 DPI。如何设置 DPI? 最佳答案 我认为这是不可能的。 PDF 是后记,因此任何文本都可以很好地缩放,如果您的图像质量不适合打
实际的 table 比我要给你看的模型大很多,但这个模型确实解释了这个问题。请转http://www.monteandjanicechan.com/test_table.cfm 表格中网格线的粗细在
我目前正在使用 cfdocument 标签创建 PDF。该 PDF 只不过是一堆指向其他 PDF 的链接。 所以我创建了这个 PDF 索引,链接都是 HREF Another PDF 如果我将 loc
我有以下 cfdocument 代码:
我正在使用 CFDOCUMENT 在 CF9.0.1 中创建 PDF。但是,每次我使用 CFDOCUMENT 生成新的 PDF 时,输入相同,MD5 哈希值似乎不同。 测试代码很简单: I am ha
是否有解决方法可以使用 cfdocument 标签将页面/文件另存为 Excel 工作表而不是 PDF 文件? 我已经设置了一个流程来制作 pdf 文件并将其通过电子邮件发送出去,并且希望我的客户可以
今天早上我在使用 cfdocument 标记时遇到了一些问题。当用户运行报表时,报表就会挂起。该报告已运行多年,没有出现任何问题。我什至取出了所有代码并只添加了以下内容。 this is a test
我是一名优秀的程序员,十分优秀!