coldfusioncoldfusion-9cfdocument

CFDocument ignoring background color when in loop


I'm running a loop to build multiple PDFs. The background colors of pdf 2+ created in the loop just plain disappear. Doesn't matter if the background color is defined in CSS, as an HTML style, using hex code or just a color name.

This is not an issue if I were to create 2 pdfs in a row without a loop.

Any idea what gives?


Solution

  • This is a bug, it only effects cfdocument saved in memory, it does not effect cfdocuments that are displayed directly to the browser. If you have to save your document in memory, the workaround is pretty simple; use an include or cfc.

    myDocument.cfm

    <cfdocument name = "myDoc">
     ...
     ...
    </cfdocument>
    

    myLoop.cfm

    <cfloop ...>
      <cfinclude template= "myDocument.cfm">
    </cfloop>
    

    I mention this bug and workaround here: cfdocument prevent page breaks mid-row