Steve,

Cfdocument encapsulates all content into a portable file. That means it has
to go out and "get" external resources. It uses the host header to do this.
When you request a cfdocument that has an embedded image with a relative
path it will use CFHTTP to "get" that image and format it for inclusion the
pdf file. That means that the SERVER has to be able to resolve the IP or URL
or whatever that you are using.  It's a common mistake that folks make when
they use Cfdocument. They think the tag uses CF mappings for inclusion of
things like images or css - but it does not. 

This is an important optimization point as well.  The more items you include
in a cfdocument that are "outside" of the calling page the more requests you
generate to your server. So if you had a document that included a 100
thumbnails it would require 101 http request to generate the page (the
calling request + 100 additional requests) even though the file sizes are
very small.  

A nice enhancement would be support for the "file" so we could add an img
url like  this:

<img src="file://d:\mysite\images\myimage.jpg" width="50" height="60">

....passing the request to the file system rather than HTTP.  This would be
more efficient in many/most cases.

I have a decent blog post on optimizing Cfdocument:

http://mkruger.cfwebtools.com/index.cfm/2006/2/16/cfdocument.performance

Mark A. Kruger, CFG, MCSE
(402) 408-3733 ext 105
www.cfwebtools.com
www.coldfusionmuse.com
www.necfug.com



-----Original Message-----
From: Steve Milburn [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, May 24, 2006 9:11 AM
To: CF-Talk
Subject: Weird cfdocument issue

I've just spent the last 30 minutes experiencing a strange issue with
cfdocument.  I've figured out the problem, but perhaps somebody here can
explain why this happens.

I had a dev server setup that I normally access just by IP address.  I have
a number of pages that use cfdocument to generate pdf output.  I have never
had any issues with this, and when moving the finished files up to the
production server accessed by domain name everything works fine.

For various reasons, I recently added an entry to my host file on my PC so I
can access my dev server by a domain name as well.  Then I noticed that any
images inside my cfdocument code would not appear.  I immediately suspected
a path issue in the <img> tag, since the web root can be different when the
server is accessed via IP vs a domain name.  
After looking this over, I noticed I was using all relative links and
everything should be fine there.  To make matters worse, if I simply removed
the opening and closing cfdocument tags and just output the HTML, the images
where fine.  It only occurred when the code was inside a cfdocument tag.

I really got confused when I noticed that it was not just with images
embedded with the <img> tag, but also with images generated by CF using
cfchart.  This entire time, any text on the page would output correctly,
just no images.  However, if I accessed the server by IP again, everything
was fine.

I eventually wised up and added the same entry to the host file on the dev
server as I had on my PC, and the cfdocuments were generating correctly.  I
was wondering if anyone out there could explain to me why the CF engine
needs to performa a dns lookup before returning the results of a cfdocument?

Thanks
Steve


---
---




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:241281
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to