• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

CFDocument and localURL weird behaviour

New Here ,
Apr 24, 2020 Apr 24, 2020

Copy link to clipboard

Copied

Tried posting earlier, but looks like my post wasn't successful so here goes again..

 

We have an old legacy application that we migrated from CF11 to CF2018. On migration I had noticed that pdfs were taking significant time to generate compared to the previous site/server version. Looking further I found Charlie's post regarding the localURL attribute setting. So trying this I have encountered some weird behaviour in that images/styles still don't load.

 

I ran the test code below:

 

 

<cfdocument name="pdfContent" saveAsName="test.pdf"  format="pdf" localurl="yes">
    <table width="100%" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td align="left">
          <font face="Arial, Helvetica, sans-serif" size="+2"><strong>Testing CFDOCUMENT </strong></font>
        </td>
      </tr>
      <tr><td colspan="6">
        using back slashes e.g. img src="images\googleLogo.png" <img src="\images\googleLogo.png"><!--- Works ---><br/>
        using back slashes and image e.g. image src="images\googleLogo.png" <image src="\images\googleLogo.png"><!--- Doesn't work ---><br/>
        using forward slashes e.g. src="images/googleLogo.png" <img src="/images/googleLogo.png"><!--- Doesn't work ---><br/>
        using forward slashes e.g. image src="images/googleLogo.png" <image src="/images/googleLogo.png"><!--- Doesn't work ---><br/>
      </td></tr>      
    </table>
</cfdocument>

<cfheader name="Content-Disposition" value="inline; filename=test.pdf">
<cfcontent variable="#toBinary(pdfContent)#" type="application/pdf" reset="Yes">

 

 

 

and get the following output:

 

image.png

Edited: to include correct screenshot.

Things I am noticing:

Forward slashes vs backslashes make a difference. Coldfusion's documentation for cfdocument uses the forward slashes in their example, and this doesn't work. 

and the <img> vs <image> tags make a difference.

 

Am I missing something simple here?

Views

554

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 25, 2020 Apr 25, 2020

Copy link to clipboard

Copied

s15, a few things:

  • the docs are flat wrong to use an image vs img tag. There is no such animal
  • the docs are also wrong to show / vs \, without clarifying the OS, and whether using localurl or not, because the difference matters.
    • On Windows, at least, with localurl=yes, it must be \ (since the call is made for a file on Windows).
    • Conversely, with localurl="no" (or if left to default to no), it must be / (since the call is made via an internal http call, using whatever web server is serving this cfml page, even though the request for the image is to a local file)

 

I have confirmed this (on Windows) for CF2018, 2016, and 11. And I agree that both variants (localurl yes or no) should be able to work with either slash (on any OS).

 

You could help others if you would file first a bug report (at tracker.adobe.com), reporting the doc mistake if an image tag, and to assert that it should clarify this matter of / vs \, depending on whether localurl yes or no (and depending on the OS).

 

Then you would still more people to file a feature request there, asking Adobe to change CF so that it works with either slash.

 

Finally, about your original need, to speed up your CFDOCUMENT processing, you didn't clarify: did the use of localurl help (when you used the img tag and the correct slash for your OS?)


/Charlie (troubleshooter, carehart.org)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 27, 2020 Apr 27, 2020

Copy link to clipboard

Copied

Hey Charlie

 

Thanks for your follow up! Sounds good I'll definitely file a bug report and also the other reports as you mentioned. I'm glad it wasn't something simple I was missing, as it was driving me nuts for the amount of time I spent on this.

 

With regards to the original requirement, enabling localurl actually did help to improve the cfdocument processing, so I guess Adobe did end up doing something right in that respect.. except I had to go through and alter all the img/style tags to utilize a fully qualified domain reference, eg. https://oursite.com/images/image.jpg for them to show up in the pdf.

 

Edit: Bug submitted - CF-4208140 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 29, 2020 Apr 29, 2020

Copy link to clipboard

Copied

LATEST

Great to hear, and thanks for the update--and for the bug report. I have added a vote and a comment (as you will see. I am pointing it out more for other readers. Go vote if you agree with the concerns raised here.)


/Charlie (troubleshooter, carehart.org)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation