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

Has anyone found a way to support the equivalent of localurl processing CFHTMLtoPDF?

Community Expert ,
May 02, 2018 May 02, 2018

Copy link to clipboard

Copied

Some readers may know that CFDOCUMENT has long had a default behavior that if you had an img src (or similar html tag) that pointed to a local file, CF would under the covers turn that into an HTTP call to get the image, which could cause performance or even functionality problems.

And CF8 added a new optional attribute to change that behavior: LocalURL.  (See my blog post from 2011 for more on that: http://www.carehart.org/blog/client/index.cfm/2011/11/19/perf_fix_via_cfdocument_localurl_attribute.)

Sadly, it seems that the new CFHTMLtoPDF (added in CF11) works the same way (I've confirmed by viewing web server logs showing it creating URLs to get images via the web server), and yet it does NOT offer that LocalURL attribute to change that behavior.

Has anyone else encountered or solved this?  I have done a lot of searching about it, to no avail.

I did find that the underlying WKHTML kit does itself offer a --enable-local-file-access option, but it's only for use with the WKHTMLtoPDF that it uses, and upon which CFHTMLtoPDF is based (https://wkhtmltopdf.org/usage/wkhtmltopdf.txt). But I cannot see any way to pass in such an argument to CFHTMLtoPDF.


/Charlie (troubleshooter, carehart.org)

Views

455

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
Enthusiast ,
May 02, 2018 May 02, 2018

Copy link to clipboard

Copied

LATEST

Hi Charlie

You can use a data URI - that is a base64 encoded string representation using the data: scheme in the src attribute of the img tag.

Here's a code example:

<cfhtmltopdf>

  <h1>Hello World</h1>

  <cfoutput><img src="data:image/png;base64,#toBase64(fileReadBinary(ExpandPath("./foundeo.png")))#"></cfoutput>

</cfhtmltopdf>

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