Skip to main content
Inspiring
March 9, 2020
Question

The type for attribute format of tag document could not be determined

  • March 9, 2020
  • 1 reply
  • 929 views

In my application, I am getting an error saying "The type for attribute format of tag document could not be determined". This is happening during PDF generation using cfdocument tag. Note that we are working with PDF files in Memory (ie , we are using the coldfusion option to write a PDF file to a variable by using the name attribute). Attaching the stack trace here.

 

    This topic has been closed for replies.

    1 reply

    Charlie Arehart
    Community Expert
    Community Expert
    March 9, 2020

    Abdul, the error says that you have not set a valid value for the "format" attribute of the cfdocument tag. You say you want a pdf, so you need to add format="pdf", as indicated in the cf docs for the tag.

     

    Or do you think you are doing that already? 

    /Charlie (troubleshooter, carehart. org)
    Inspiring
    March 9, 2020

    Thanks Charlie for your response. Yes we do this via attributeCollection as below,

     

    <cfset attributes.attrCollection = {
    fontembed="true",
    localUrl="yes",
    format="PDF",
    pagetype="A4",
    unit="cm",
    pageWidth="21",
    pageHeight="29.7",
    marginleft="0",
    marginright="0",
    margintop="5",
    overwrite="true",
    bookmark="true"
    } />

     

    The above variable we set to attributes scope since we generate PDF in CF thread. Also please note that when we try regenerating pdf 2 or 3 times this issuse never happens.

    Charlie Arehart
    Community Expert
    Community Expert
    March 9, 2020

    OK, interesting. So first, wrap the cfdocument in a try/catch, and when it fails, dump out the attributes scope. You may well find that somehow it's NOT got the values that you think it does--in that moment. And in seeing what IS (or is NOT ) in the dump, you may better be able to tell where the problem is happening.

     

    Second, if that doesn't get you anywhere, you could try a different scope than attributes. I do realize that the attributes scope is what's recommended by Adobe (such as here, https://helpx.adobe.com/coldfusion/developing-applications/developing-cfml-applications/using-coldfusion-threads/using-thread-data.html, even thought it's something that was creatd for use with CFML custom tags, an old concept).

     

    But just as a sanity-check, what if you used the "request" scope instead? The doc there indicates that it would be supported. I realize the docs indicate that CF supposedly adds single-thread protection to use of the attributes scope, but I'm just throwing out an idea.

     

    Indeed, finally, you say that "when we try regenerating pdf 2 or 3 times this issuse never happens." Can you clarify what you mean? Is it that this error only happens on the first call to create the PDF, but not subsequent ones? Is that about multiple calls in your browser to the same request, over and over? Or do you mean that within the code of this page, if called only once, it somehow sets things up to call multiple PDF generation actions? However you answer, that may be a clue as to why the problem happens. It sure sounds like some sort of race condition (despite the supposed protection of the attributes scope, mentioned in that doc page I linked to.)

     

    WIll be interested to see how things sort out.

    /Charlie (troubleshooter, carehart. org)