Skip to main content
Known Participant
April 4, 2012
Question

cfimage inside cfdocument problem

  • April 4, 2012
  • 3 replies
  • 11813 views

Very strange, but repeatable issue I've run into.  I'm using the barbecue Java barcode generator library to generate code128 compliant barcodes which are then handed to cfimage writeToBrowser to finally end up with printable packing/mailing labels.  When rendered to screen, everything works perfectly, but as soon as I wrap it in a cfdocument tag, so that we can generate as a pdf for printing on a label printer, I'm ending up with the wrong image on the wrong label in a few cases.  It's always the same records that end up reusing an image from an earlier record (and always the same earlier record).  I can check in the ColdFusion8\tmpCache\CFFileServlet\_cf_image folder and see that all the correct images were created by the cfimage tag, but for whatever reason, some of the images don't make it into the pdf, but are replaced by a different barcode from an earlier record.  I can't see any commonality between the two records and if I intentionally remove the earlier record from the query, the proper barcode shows up.

So, any ideas about where to go from here?  Anybody know anything about how cfdocument pulls in images and if there is any kind of caching or prechecking of the images before rendering.  I actually checked to make sure the two files didn't have the same MD5 sum to see if there was something happening there where CF thinks it's the same image.  They were not the same.

I've tried this on two CF 8.01 boxes with the same result.  Always the same records, same images, same problem, even if I limit the query to only the two problem records.  I'm totally stumped.  Anybody?

This topic has been closed for replies.

3 replies

Inspiring
October 9, 2015

This bug still exists in CF 10.  I'm running CF 10,0,16,293499 w/HF16, 64 bit, on Java 1.8.0_45 on Windows Server 2012

In my case, I am using the IDAutomation barcode aspx  to generate barcode images.  IDAutomation defaults to GIF format.  If CF creates a PDF document with, say, 100 unique barcodes, 1 of them will be displayed incorrectly - a previously generated barcode will appear in place of another.  It is repeatable when generating the same batch given the same barcode sequence - the incorrect barcode image(s) will appear at the same location in the document every time.  When I tell the IDAutomation control to generate JPEG images, the problem goes away.

Participant
February 9, 2016

How do you tell the IDAutomation control to generate JPEG images? I have the same problem

jeff_cAuthor
Known Participant
April 9, 2012

FWIW, I was able to get past this issue by changing the cfimage tag to produce jpg images rather than png.  Now, I have no way of knowing if this actually solved the problem or simply fixed it for these two images I was comparing and if I will now have to be on the lookout for other images with the same problem. 

I did get a reply from Rupesh Kumar (Adobe CF Engineer) from a question I submitted on his ColdFused blog where he stated that the thought this had been fixed in 9.01.  I assured him it had not and pointed him to the bug I filed.

Inspiring
April 9, 2012

jeff.c wrote:

I did get a reply from Rupesh Kumar (Adobe CF Engineer) from a question I submitted on his ColdFused blog where he stated that the thought this had been fixed in 9.01.  I assured him it had not and pointed him to the bug I filed.

Well at least now you have a firm confirmation of your suspicion it is a it is a bug. Since it sounds like a known issue, did he mention anything about cause or possible work-arounds?

Participating Frequently
August 31, 2012

I am still running into this issue in cf 9.01 as well..... so frustrating to have to use lossy jpegs to render my bar codes into a pdf.

Thanks for incredible troubleshooting and follow up Jeff, you are my hero.

Inspiring
April 4, 2012

Can you post your code?

jeff_cAuthor
Known Participant
April 4, 2012

Not sure it's helpful, but here's the code, at least the relevant parts.  As I said, I've confirmed that this is all doing what it's supposed to and if I take off the cfdocument, it renders to the screen perfectly every time.

<cfdocument format="PDF" pagewidth="4" pageheight="6.0" pagetype="CUSTOM" margintop="0.17" marginbottom="0.05" marginleft="0.17" marginright="0.17">

<cfset labelCounter = 1 />

<cfoutput query="qryGetShippingLabelData" group="Lab_Code">

  <!--- Do some stuff --->

  <cfoutput group="shipGroup">

    <cfloop from=1 to=#numLabels# index="i">

      <cfset bcText = "" />

      <cfif labelCounter NEQ 1><cfdocumentitem type="pagebreak" /></cfif>

      #labelHead#

      <cfoutput>

        <cfset bcText = bcText & numberFormat(study_id,"00000") & iif(singleSampleBox,1,numSamples) />

      </cfoutput>

                              <cfset bcText = numberFormat(Lab_ID,"00000") & bcText />

                              <p><cfimage action="writeToBrowser" source="#getCode128(bcText)#" /></p>

      #labelFoot#

      <cfset labelCounter = labelCounter + 1 />

    </cfloop>

  </cfoutput>

</cfoutput>

</cfdocument>

Inspiring
April 4, 2012

I notice there is lot of looping and grouping going on. Any chance it is related? If you output the "bcText" at each step (inside the pdf) is the value correct? Also, for grins you might output the image URL and confirm whether it is repeating, or the "bcText" is repeating.