我把头发拉过这个!我正在使用ColdFusion生成.rtf文件,如下所示,用于打印Avery邮件标签。出于某种原因,在第一列中的每个名称之前出现空格,但仅在第一行之后出现空格。这让我很难过,因为我查看了生成的源代码,并且在名称前没有看到额外的字符,即使我在文本编辑器中打开.rtf,我也可以手动删除该字符来修复它。谁能告诉我为什么有额外的空间?您可以通过以下URL下载实际的.rtf文件:
http://www.bitmojo.com/Avery-Label-Test.rtf
嗯,我想我无法发布图片...如果您需要澄清,请随时索取链接。
在此处添加此内容,因为评论时间过长:
我使用十多年前的CF_AVERYRTF.CFM自定义标签......据我所知,还没有更新过。我将编辑我的问题以添加实际生成的代码并保存RTF。它使用cfsavecontent,cfscript和writeoutput来创建作为.rtf文件保存到磁盘的变量,当我在.rtf写入磁盘之前cfdump该变量时,我没有在名称前看到任何额外的字符,但是当我在我的代码编辑器中打开.rtf文件源我在每个名称前面都看到一个空格,当我在mac上的文本编辑器中打开.rtf时,我只看到第一行后第一列中的名称之前的空格。那是什么让我发疯,看到不同的东西取决于我在哪里以及如何看待数据...这就是为什么我发布了示例文件,所以有人可以看看,至少验证我所看到的。这是我Mac上显示的症状图像(空间圈出)
screen shot http://www.bitmojo.com/Avery-Label-Screen-Shot.png
此处还有生成数据的代码:
<cfsavecontent variable="ThisTag.GeneratedRTF">
<cfscript>
// open RTF document with header information
writeOutput("{\rtf1\ansi\ansicpg1252\uc1 \deff0\deflang1033\deflangfe1033{\fonttbl{\f0\fswiss Arial;}{\f1\fswiss Helvetica;}{\f2\fswiss Impact;}{\f3\froman Times New Roman;}}");
writeOutput("{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;\red192\green192\blue192;\red255\green255\blue255;}");
writeOutput("{\info{\title VFIVE Label Generator (#request.rtfLabels.labeltitle# Output)}{\author cf_averyRTF $Revision: 1.17 $}{\operator cf_averyRTF resides at http://rtf.vfive.com}{\*\company VFIVE (http://www.vfive.com)}{\creatim\yr#Year(now())#\mo#Month(now())#\dy#Day(now())#\hr#Hour(now())#\min#Minute(now())#}{\version1}{\edmins0}{\nofpages1}{\nofwords0}{\nofchars0}{\nofcharsws0}{\vern1000}}\paperw#request.rtfLabels.paperw#\paperh#request.rtfLabels.paperh#\margl#request.rtfLabels.margl#\margr#request.rtfLabels.margr#\margt#request.rtfLabels.margt#\margb#request.rtfLabels.margb#");
if (Attributes.landscape)
{
writeOutput("\landscape");
}
writeOutput("\gutter#request.rtfLabels.gutter# \widowctrl\ftnbj\aenddoc\noxlattoyen\expshrtn\noultrlspc\dntblnsbdb\nospaceforul\horzdoc \jexpand\viewkind1\viewscale#request.rtfLabels.viewscale#\nolnhtadjtbl \fet0\sectd \linex#request.rtfLabels.linex#\sectdefaultcl");
// loop over each row in the dataset
for (ii = 1; ii LTE arrayLen(thisTag.assocAttribs); ii = ii + 1)
{
// if this is the first cell of a row, create the row (like <tr>)
if (NOT ((ii + request.rtfLabels.columns - 1) MOD request.rtfLabels.columns))
{
// output the <tr>-like row start, cellBoundary
writeOutput("\trowd \trrh#request.rtfLabels.trrhcell#\trkeep" & cellBoundary);
// output row setup (align, indent, etc)
writeOutput(" \pard\plain \q#request.rtfLabels.textalign# \li#request.rtfLabels.li#\ri#request.rtfLabels.ri#\widctlpar\intbl\faauto \f#request.rtfLabels.defaultfontface#\fs20\lang1033\langfe1033");
}
// output each individual cell header (like <td>)
writeOutput("{\#request.rtfLabels.bold#\fs#request.rtfLabels.defaultfontsize#\f#request.rtfLabels.defaultfontface# ");
// output barcode on top if appropriate
if (len(trim(thisTag.assocAttribs[ii].zipCode)) AND thisTag.assocAttribs[ii].barPos EQ "top")
{
writeOutput("{\field\flddirty{\*\fldinst { BARCODE }{\lang1024\langfe1024\noproof #ThisTag.AssocAttribs[ii].zipcode#}{\\u }}{\fldrslt }}\par");
}
// loop over the lines of content in this cell
for (jj = 1; jj LTE arrayLen(ThisTag.AssocAttribs[ii].arrCell); jj = jj + 1)
{
// content to be displayed?
if (len(trim(thisTag.assocAttribs[ii].arrCell[jj].content)) OR NOT thisTag.assocAttribs[ii].stripBlankLines)
{
// are we bolding this line of content?
if (thisTag.assocAttribs[ii].arrCell[jj].bold)
{
writeOutput("\b");
}
else
{
writeOutput("\b0");
}
writeOutput("\fs#ThisTag.AssocAttribs[ii].arrCell[jj].fs#\f#ThisTag.AssocAttribs[ii].arrCell[jj].f##ThisTag.AssocAttribs[ii].arrCell[jj].content#");
if (jj LT arrayLen(ThisTag.AssocAttribs[ii].arrCell))
{
writeOutput("\par");
}
}
}
// close out cell (like a </td>)
writeOutput("}{\fs#request.rtfLabels.defaultfontsize#\f#request.rtfLabels.defaultfontface# ");
// output barcode on bottom if appropriate
if (len(trim(thisTag.assocAttribs[ii].zipCode)) AND thisTag.assocAttribs[ii].barPos EQ "bottom")
{
writeOutput(" {\field\flddirty{\*\fldinst { BARCODE }{\lang1024\langfe1024\noproof #ThisTag.AssocAttribs[ii].zipcode#}{\\u }}{\fldrslt }}");
}
// prepare to close this cell </td>
writeOutput("\cell } ");
// close this cell out like a </td>
if (ii MOD request.rtfLabels.columns)
{
writeOutput(" \pard \q#request.rtfLabels.textalign# \li#request.rtfLabels.li#\ri#request.rtfLabels.ri#\widctlpar\intbl\faauto {\cell }");
}
else
{
writeOutput("\pard\plain \q#request.rtfLabels.textalign# \li#request.rtfLabels.li#\ri#request.rtfLabels.ri#\widctlpar\intbl\aspalpha\aspnum\faauto\adjustright \fs#request.rtfLabels.defaultfontsize#\f#request.rtfLabels.defaultfontface#\lang1033\langfe1033");
}
// if this is the last cell of a row, end it (like a </tr>) --->
if (NOT (ii MOD request.rtfLabels.columns))
{
// start close: output code + cellCloser + " \row }"
writeOutput("\pard\plain \q#request.rtfLabels.textalign# \li#request.rtfLabels.li#\ri#request.rtfLabels.ri#\widctlpar\intbl\aspalpha\aspnum\faauto\adjustright \fs#request.rtfLabels.defaultfontsize#\f#request.rtfLabels.defaultfontface#\lang1033\langfe1033 {\trowd \trrh#request.rtfLabels.trrhcell#\trkeep " & cellCloser & " \row }#chr(13)##chr(10)#");
// add an extra spacer row?
if (request.rtfLabels.useSpacer)
{
// output complete spacerRow as defined above
writeOutput(spacerRow);
}
}
// end of outer for loop
}
// close out document
writeOutput("\pard \q#request.rtfLabels.textalign# \li#request.rtfLabels.li#\ri#request.rtfLabels.ri#\widctlpar\aspalpha\aspnum\faauto\adjustright { \par }{ \par }}");
</cfscript>
</cfsavecontent>
答案 0 :(得分:1)
如果不看代码,我们就不能说太多。添加到@ Miguel-F所说的,如果你在这个过程中使用任何自己的函数,是否指定了output="false"
?
几乎可以肯定,你的代码的空白区域正在流行。
处理这个问题的一个相当简单的方法是尽可能使用CFScript而不是标签(无论如何,这是合理的建议,确保您的代码清晰简洁)。
UPDATE
如果您使用的是自定义标记,请确保围绕调用标记围绕<cfsilent>
标记,并围绕其中的所有标记发出任何内容。自定义标签可怕用于发出虚假空白。
答案 1 :(得分:0)
现在我已经解决了自己升级到ColdFusion 2016的问题,因此我将把它作为Adobe解决的ColdFusion中的一个错误写下来。