我把我的头发拉到这个上面!我正在使用 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 上的症状图像(带圆圈的空格)
屏幕截图 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>