<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ColdFused? &#187; cfdocument</title>
	<atom:link href="http://www.rupeshk.org/blog/index.php/category/coldfusion/cfdocument/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.rupeshk.org/blog</link>
	<description>My Views on ColdFusion, Java and related technologies</description>
	<lastBuildDate>Mon, 21 Jun 2010 12:40:32 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>New &#8216;EvalAtPrint&#8217; attribute in CFDocumentItem</title>
		<link>http://www.rupeshk.org/blog/index.php/2008/06/evalatprint/</link>
		<comments>http://www.rupeshk.org/blog/index.php/2008/06/evalatprint/#comments</comments>
		<pubDate>Mon, 30 Jun 2008 20:28:00 +0000</pubDate>
		<dc:creator>Rupesh Kumar</dc:creator>
				<category><![CDATA[cfdocument]]></category>
		<category><![CDATA[coldfusion]]></category>

		<guid isPermaLink="false">http://rupesh106.wordpress.com/2008/06/30/new-evalatprint-attribute-in-cfdocumentitem/</guid>
		<description><![CDATA[A new evalAtPrint attribute has been added to cfdocumentitem tag in ColdFusion 801 which is applicable when the item type is header or footer. The default value of this attribute is false.
Note: The cfdocumentitem behavior with the default evalAtPrint value is identical to the behavior in ColdFusion MX 7, but differs from the behavior of [...]]]></description>
			<content:encoded><![CDATA[<p>A new evalAtPrint attribute has been added to cfdocumentitem tag in ColdFusion 801 which is applicable when the item type is header or footer. The default value of this attribute is false.</p>
<p><strong>Note:</strong> The cfdocumentitem behavior with the default evalAtPrint value is identical to the behavior in ColdFusion MX 7, but differs from the behavior of the ColdFusion 8 release.</p>
<p>When the evalAtPrint attribute value is false, the default value, ColdFusion evaluates the cfdocumentitem tag body at the same time when it is processing the cfdocument tag. This is the behavior identical to CFMX7. In this case you can use CFDocument variables (TotalPageCount, CurrentPageNumber, TotalSectionpageCount and CurrentSectionpageNumber) only inside cfoutput and not in any expression because the page numbers are not known unless the cfdocument body content is evaluated and layed out.</p>
<p>In order to use CFDocument variables in expression inside CFDocumentItem tagbody, you should set evalAtPrint to true as shown in the following example.</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfdocument</span> <span style="color: #0000FF;">format</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;pdf&quot;</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfdocumentitem</span> <span style="color: #0000FF;">type</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;header&quot;</span> evalAtPrint<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;true&quot;</span><span style="color: #0000FF;">&gt;</span></span>
       <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfif</span> <span style="color: #0000FF;">&#40;</span>CFDocument.currentPageNumber % <span style="color: #FF0000;">2</span> <span style="color: #0000FF;">eq</span> <span style="color: #FF0000;">0</span><span style="color: #0000FF;">&#41;</span><span style="color: #0000FF;">&gt;</span></span>
           <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfoutput</span><span style="color: #0000FF;">&gt;</span></span> Page is even<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfoutput</span><span style="color: #0000FF;">&gt;</span></span>
       <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfelse</span><span style="color: #0000FF;">&gt;</span></span>
           <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfoutput</span><span style="color: #0000FF;">&gt;</span></span> Page is odd<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfoutput</span><span style="color: #0000FF;">&gt;</span></span>
       <span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfif</span><span style="color: #0000FF;">&gt;</span></span>
   <span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfdocumentitem</span> <span style="color: #0000FF;">&gt;</span></span>
   Document body…
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfdocument</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>

<p>In this case, ColdFusion evaluates the cfdocumentitem tag body when it prints the header or footer, not when it evaluates the cfdocument tag body. This ensures that the cfdocument tag body is already evaluated and layed out and page number information is available when cfdocumentitem tag is being evaluated</p>
<p>A side effect of this is, if a variable is used inside both cfdocument and cfdocumentitem, cfdocumentitem tag will only see the final value of that variable. In the following example, cfdocumentitem will always get 11 as value of ‘I’ and hence all the headers will print ‘Chapter 11’.</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfdocument</span> <span style="color: #0000FF;">format</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;pdf&quot;</span> <span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfloop</span> <span style="color: #0000FF;">from</span><span style="color: #0000FF;">=</span><span style="color: #FF0000;">1</span> <span style="color: #0000FF;">to</span><span style="color: #0000FF;">=</span><span style="color: #FF0000;">10</span> <span style="color: #0000FF;">index</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;i&quot;</span><span style="color: #0000FF;">&gt;</span></span>
   <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfdocumentsection</span><span style="color: #0000FF;">&gt;</span></span>
   <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfdocumentitem</span> <span style="color: #0000FF;">type</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;header&quot;</span> <span style="color: #0000FF;">&gt;</span></span>
       <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfoutput</span><span style="color: #0000FF;">&gt;</span></span>Chapter <span style="color: #0000FF;">#i#</span><span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfoutput</span><span style="color: #0000FF;">&gt;</span></span>
   <span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfdocumentitem</span> <span style="color: #0000FF;">&gt;</span></span>
DocumentSection body
   <span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfdocumentsection</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfloop</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfdocument</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>

<p>To handle this, you can now pass the variable into the cfdocumentitem tag as a custom attribute, as shown in the following example:</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfdocument</span> <span style="color: #0000FF;">format</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;pdf&quot;</span> <span style="color: #0000FF;">&gt;</span></span>
   <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #000000;">strong</span><span style="color: #0000FF;">&gt;&lt;</span><span style="color: #990000; font-weight: bold;">cfloop</span> <span style="color: #0000FF;">from</span><span style="color: #0000FF;">=</span><span style="color: #FF0000;">1</span> <span style="color: #0000FF;">to</span><span style="color: #0000FF;">=</span><span style="color: #FF0000;">10</span> <span style="color: #0000FF;">index</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;i&quot;</span><span style="color: #0000FF;">&gt;&lt;/</span><span style="color: #000000;">strong</span><span style="color: #0000FF;">&gt;</span></span>
       <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfdocumentsection</span><span style="color: #0000FF;">&gt;</span></span>
           <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #000000;">strong</span><span style="color: #0000FF;">&gt;&lt;</span><span style="color: #990000; font-weight: bold;">cfdocumentitem</span> <span style="color: #0000FF;">type</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;header&quot;</span> evalAtPrint<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;true&quot;</span> no <span style="color: #0000FF;">=</span> #i#<span style="color: #0000FF;">&gt;</span></span>
               <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfoutput</span><span style="color: #0000FF;">&gt;</span></span>Chapter <span style="color: #0000FF;">#attributes.no#</span><span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfoutput</span><span style="color: #0000FF;">&gt;</span></span> <span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #000000;">strong</span><span style="color: #0000FF;">&gt;</span></span>
               <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfif</span> <span style="color: #0000FF;">&#40;</span>CFDocument.currentPageNumber % <span style="color: #FF0000;">2</span> <span style="color: #0000FF;">eq</span> <span style="color: #FF0000;">0</span><span style="color: #0000FF;">&#41;</span><span style="color: #0000FF;">&gt;</span></span>
                   <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfoutput</span><span style="color: #0000FF;">&gt;</span></span> Page is even<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfoutput</span><span style="color: #0000FF;">&gt;</span></span>
               <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfelse</span><span style="color: #0000FF;">&gt;</span></span>
                   <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfoutput</span><span style="color: #0000FF;">&gt;</span></span> Page is odd<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfoutput</span><span style="color: #0000FF;">&gt;</span></span>
               <span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfif</span><span style="color: #0000FF;">&gt;</span></span>
           <span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfdocumentitem</span> <span style="color: #0000FF;">&gt;</span></span>
           Document Body.
       <span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfdocumentsection</span><span style="color: #0000FF;">&gt;</span></span>
   <span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfloop</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfdocument</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.rupeshk.org/blog/index.php/2008/06/evalatprint/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Images and CFDocument performance</title>
		<link>http://www.rupeshk.org/blog/index.php/2007/12/images-and-cfdocument-performance/</link>
		<comments>http://www.rupeshk.org/blog/index.php/2007/12/images-and-cfdocument-performance/#comments</comments>
		<pubDate>Sat, 15 Dec 2007 03:31:00 +0000</pubDate>
		<dc:creator>Rupesh Kumar</dc:creator>
				<category><![CDATA[cfdocument]]></category>
		<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://rupesh106.wordpress.com/2007/12/14/images-and-cfdocument-performance/</guid>
		<description><![CDATA[Sometime back one of our customer reported that using png images in cfdocument makes it very very slow. I could not replicate it with any png image but it did happen with his png image.
Today, Andy reported a similar issue but this time it was for jpeg images. In both the cases, performance hit is [...]]]></description>
			<content:encoded><![CDATA[<p>Sometime back one of our customer reported that using png images in cfdocument makes it very very slow. I could not replicate it with any png image but it did happen with his <a href="http://www.welshkatz.com/1652BE/print/Masthead.png">png image</a>.
<p>Today, Andy reported a <a href="http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:54540">similar issue</a> but this time it was for jpeg images. In both the cases, performance hit is huge and it does not happen with all the images. </p>
<p>I spent a significant amount of time debugging it today and it turns out that the reason for both the issues are same &#8211; there is something special about these images and that is <a href="http://en.wikipedia.org/wiki/Colorspace">colorspace</a>. All these images actually had a different colorspace than what java imaging uses. Because of this, when we need the pixel values of image to print it on pdf (by calling BufferedImage.getRGB()), it tries to convert this colorspace to RGB colorspace and that is very very costly. That is where the entire time goes. So how do you fix it? I opened all the images in an image editor and saved it again. This time it got saved in standard RGB colorspace and the time taken to create the pdf got reduced from 110 sec to 1.5 seconds. That is huge!!! Isn&#8217;t it? But can you control all the images over the web? NO.. right? Read on.. there is more to this story. </p>
<p>A little bit of looking up on web pointed me to <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4705399">this Sun bug</a> which is the exact same bug which we were hitting. Thankfully it got fixed in mustang i.e JDK1.6 which ColdFusion8 uses by default. But hey wait a second.. Didn&#8217;t Andy say that he is seeing it on ColdFusion 8? why do we still see this happening when it is fixed in JDK1.6? It appears that this bug was fixed only in core JDK api but not in JAI (Java advanced imaging) codecLib that ColdFusion 8 uses. So what do we do now? You can do either of these two </p>
<ol>
<li>Remove clibwrapper_jiio.jar from &#8220;lib&#8221; folder. </li>
<li>Or, set this system property to the JVM. <b><span style="font-family:courier;">-Dcom.sun.media.imageio.disableCodecLib=true</span></b> . You can set this in [cf-install_dir]/runtime/bin/jvm.config if you are using standalone coldfusion server. </li>
</ol>
<p>You should keep in mind that codecLib libraries are native libraries which are meant to increase the java imaging performance. So disabling it might degrade the performance of CFImage somewhere. Also keep in mind that removing this jar or disabling codecLib will not result into any loss of functionality &#8211; it just means that all image operations will be pure java. </p>
<p>There is <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6529318">another related Sun&#8217;s bug</a> which I thought might be useful to you. Image loading might get very slow if the server is running in debug mode. Your server is running in debug mode if you see something like this in your jvm.config or VM startup option.</p>
</p>
<pre>
<div class="code">-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005</div>
</pre>
<p>This bug got introduced in JDK1.6 and does not exist on 1.5. So make sure that you are not running the server in debug mode.</p>
<p>To summarise, you can do following to increase the performance of image loading in cfdocument.
<ol>
<li>If you are on JDK1.5, there is not much you can do. The only option is to change the colorspace of images. I will try to see if we can address this in ColdFusion code. </li>
<li>If you are on JDK1.6,<br /> 
<ul>
<li>Disable codecLib as mentioned above. </li>
</ul>
<ol>      </ol>
<ul>
<li>Disable debug mode by removing the complete debug string mentioned above </li>
</ul>
<ol>    </ol>
</li>
<li>In addition to this, you might want to use &#8216;localurl&#8217; attribute for cfdocument tag. <a href="http://coldfused.blogspot.com/2007/07/enhancements-to-cfdocument-in.html">See this</a> for more details. </li>
<p></ol>
]]></content:encoded>
			<wfw:commentRss>http://www.rupeshk.org/blog/index.php/2007/12/images-and-cfdocument-performance/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Missing text in pdf created by CFDocument</title>
		<link>http://www.rupeshk.org/blog/index.php/2007/12/missing-text-in-pdf-created-by-cfdocument/</link>
		<comments>http://www.rupeshk.org/blog/index.php/2007/12/missing-text-in-pdf-created-by-cfdocument/#comments</comments>
		<pubDate>Thu, 13 Dec 2007 01:27:00 +0000</pubDate>
		<dc:creator>Rupesh Kumar</dc:creator>
				<category><![CDATA[cfdocument]]></category>
		<category><![CDATA[coldfusion]]></category>

		<guid isPermaLink="false">http://rupesh106.wordpress.com/2007/12/12/missing-text-in-pdf-created-by-cfdocument/</guid>
		<description><![CDATA[I had heard about people not getting images in the generated pdf but this one was something new and spooky. Yesterday Andy Matthews posted it on cf-talk where he says that for his content, though a pdf containing 15 pages gets created but only the first page has some content and rest of the pages [...]]]></description>
			<content:encoded><![CDATA[<p>I had heard about people not getting images in the generated pdf but this one was something new and spooky. Yesterday <a href="http://www.commadelimited.com/">Andy Matthews</a> <a href="http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:54485">posted</a> it on cf-talk where he says that for his content, though a pdf containing 15 pages gets created but only the first page has some content and rest of the pages are blank. I ran his code on my machine and sure enough it was happening. All the content including text and image on all the pages except the first page was gone. So what was wrong? I simplified his code and here is a simple example which you can try.</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfdocument</span> <span style="color: #0000FF;">format</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;pdf&quot;</span><span style="color: #0000FF;">&gt;</span></span>
Text Outside div
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #000000;">div</span> <span style="color: #0000FF;">style</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;width:300px;overflow:auto;&quot;</span><span style="color: #0000FF;">&gt;</span></span>
 This is text inside the div. Will it show up?
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #000000;">div</span><span style="color: #0000FF;">&gt;&lt;</span><span style="color: #000000;">br</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfdocument</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>

<p>In the generated pdf you will see only &#8220;Text Outside div&#8221;. Spooky.. isn&#8217;t it? The reason it happened was because of css style <strong>&#8216;overflow:auto&#8217;</strong>. The rendering engine used by CFDocument underneath does not handle overflow:auto and it simply ignores the content in the div. The weird part is &#8211; it considers that content for all rendering calculations including page number and page break calculation.
<p>Something you should watch out for if you use css styles in cfdocument. A workaround for the time being is not to use overflow:auto style. So modifying the above code like this will make it work.</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfdocument</span> <span style="color: #0000FF;">format</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;pdf&quot;</span><span style="color: #0000FF;">&gt;</span></span>
Text Outside div
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #000000;">div</span> <span style="color: #0000FF;">style</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;width:300px;&quot;</span><span style="color: #0000FF;">&gt;</span></span>
 This is text inside the div. Will it show up?<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #000000;">div</span><span style="color: #0000FF;">&gt;&lt;</span><span style="color: #000000;">br</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfdocument</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.rupeshk.org/blog/index.php/2007/12/missing-text-in-pdf-created-by-cfdocument/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>CFDocument hotfix for ColdFusion 8 released</title>
		<link>http://www.rupeshk.org/blog/index.php/2007/09/cfdocument-hotfix-for-coldfusion-8-released/</link>
		<comments>http://www.rupeshk.org/blog/index.php/2007/09/cfdocument-hotfix-for-coldfusion-8-released/#comments</comments>
		<pubDate>Thu, 20 Sep 2007 23:47:00 +0000</pubDate>
		<dc:creator>Rupesh Kumar</dc:creator>
				<category><![CDATA[cfdocument]]></category>
		<category><![CDATA[coldfusion]]></category>

		<guid isPermaLink="false">http://rupesh106.wordpress.com/2007/09/20/cfdocument-hotfix-for-coldfusion-8-released/</guid>
		<description><![CDATA[We have released a cumulative hotfix for CFDocument related issues in ColdFusion 8. Bugs being addressed in this hotfix are

PDF/Flashpaper document generated in CF8 are nearly 70% scaled down than CFMX 7. This was making document appear smaller in CF8 as compared to CF7.
Using cfdocumentitem in a loop inside cfdocument causes the error, &#8220;routines cannot [...]]]></description>
			<content:encoded><![CDATA[<p>We have released a <a href="http://kb.adobe.com/selfservice/viewContent.do?externalId=kb402584&amp;sliceId=1" target="_blank">cumulative hotfix</a> for CFDocument related issues in ColdFusion 8. Bugs being addressed in this hotfix are</p>
<ul>
<li>PDF/Flashpaper document generated in CF8 are nearly 70% scaled down than CFMX 7. This was making document appear smaller in CF8 as compared to CF7.</li>
<li>Using cfdocumentitem in a loop inside cfdocument causes the error, &#8220;routines cannot be declared more than once&#8221;.</li>
<li>StackOverFlowError when a large document with table is created. A simple report with over 1500 table row causes this problem. More complex, but shorter documents have also resulted in this error. This was a pretty nasty one and it deserves a separate blog entry <img src='http://www.rupeshk.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> .</li>
</ul>
<p>You can download the hotfix directly from <a href="http://www.adobe.com/support/coldfusion/ts/documents/kb402584/hf800-70403.zip" target="_blank">here</a>. You would need to extract the hotfix jar from the downloaded zip file and apply that jar. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.rupeshk.org/blog/index.php/2007/09/cfdocument-hotfix-for-coldfusion-8-released/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Enhancements to CFDocument in ColdFusion 8</title>
		<link>http://www.rupeshk.org/blog/index.php/2007/07/enhancements-to-cfdocument-in-coldfusion-8/</link>
		<comments>http://www.rupeshk.org/blog/index.php/2007/07/enhancements-to-cfdocument-in-coldfusion-8/#comments</comments>
		<pubDate>Thu, 19 Jul 2007 11:51:00 +0000</pubDate>
		<dc:creator>Rupesh Kumar</dc:creator>
				<category><![CDATA[cfdocument]]></category>
		<category><![CDATA[coldfusion]]></category>

		<guid isPermaLink="false">http://rupesh106.wordpress.com/2007/07/19/enhancements-to-cfdocument-in-coldfusion-8/</guid>
		<description><![CDATA[As you all know, CFDocument tag is used to easily create pdf or flashpaper documents from HTML/CFML content. ColdFusion 8 has added lot of enhancements to it and in this post we will talk about those enhancements.  
1. Bookmark : You can create bookmarks for each section of the pdf using &#8220;bookmark&#8221; attribute. The [...]]]></description>
			<content:encoded><![CDATA[<p>As you all know, CFDocument tag is used to easily create pdf or flashpaper documents from HTML/CFML content. ColdFusion 8 has added lot of enhancements to it and in this post we will talk about those enhancements.  </p>
<p>1. <strong>Bookmark</strong> : You can create bookmarks for each section of the pdf using &#8220;bookmark&#8221; attribute. The bookmark created is of only one level and its name is set to the documentsection&#8217;s name. Here is a sample code for creating pdf with bookmarks.  </p>
<div class="code">
<pre>&lt;cfdocument format="PDF" bookmark="yes"&gt;   &lt;cfdocumentsection name="Introduction"&gt;       &lt;h3&gt;Introduction&lt;/h3&gt;       &lt;p&gt;The introduction goes here.&lt;/p&gt;   &lt;/cfdocumentsection&gt;   &lt;cfdocumentsection name="Chapter 1"&gt;       &lt;h3&gt;Chapter 1: Getting Started&lt;/h3&gt;       &lt;p&gt;Chapter 1 goes here.&lt;/p&gt;   &lt;/cfdocumentsection&gt;   &lt;cfdocumentsection name="Chapter 2"&gt;       &lt;h3&gt;Chapter 2: Building Applications&lt;/h3&gt;       &lt;p&gt;Chapter 2 goes here.&lt;/p&gt;   &lt;/cfdocumentsection&gt;   &lt;cfdocumentsection name="Conclusion"&gt;       &lt;h3&gt;Conclusion&lt;/h3&gt;       &lt;p&gt;The conclusion goes here.&lt;/p&gt;   &lt;/cfdocumentsection&gt;&lt;/cfdocument&gt;</pre>
</div>
<p>2. <strong>Proxy Support</strong> : With ColdFusion 8, you can now provide proxy configuration to cfdocument for retrieving external content like images. This will be useful in situation where the machine hosting ColdFusion is connected to the external world via a proxy. The new attributes added for this (which are self explanatory) are listed below</p>
<ul>
<li>proxyHost</li>
<li>proxyPort</li>
<li>proxyUser</li>
<li>proxyPort </li>
</ul>
<p>3. <strong>Content from URL : </strong>Though this was added in 7.0.2, I think it makes sense to add here because it was not there in 7. <img src='http://www.rupeshk.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  Have you ever created or wanted to create a pdf from a web page? If yes, then the new attribute &#8220;<strong>src</strong>&#8221; in cfdocument and cfdocumentsection tag makes it very easy to do this. Here is an example to do this.</p>
<div class="code">&lt;cfdocument format=&#8221;pdf&#8221; <strong>src</strong>=&#8221;http://www.google.com&#8221; /&gt;</div>
<p>
<p> 4. <strong>Basic Authentication</strong> : If the CFDocument body contains a resource (e.g; image or URL) that is protected with basic authentication, ColdFusion 7 can not retrieve it and it was one of the reason for getting &#8220;red-x&#8221; for images. (See <a href="http://coldfused.blogspot.com/2005/11/missing-images-in-cfdocument.html">my old post</a> on this). ColdFusion 8 addresses this by adding these two attributes to cfdocument and cfdocumentsection tag.</p>
<ul>
<li>authuser &#8211; user name to be used for basic authentication.</li>
<li>authpassword &#8211; password to be used for basic authentication.</li>
</ul>
<p>5. <strong>User Agent : </strong>There are some cases where the web server is configured to allow requests only from a certain set of browsers (User agents to be precise) to prevent spiders and bots from overloading the server. In ColdFusion 7, when CFDocument creates a URLConnection for an image, it sends a &#8220;User-Agent&#8221; header, that looks like &#8220;User-Agent:Java/1.4.2_07&#8243;, in the HTTP request. If the web server does not recognize &#8220;Java&#8221; user-agent, it returns a status code of 404 (resource not found) and hence the images can not be displayed. ColdFusion 8 adds a new attribute &#8220;user-agent&#8221; to address this.</p>
<ul>
<li>user-agent : User agent to be used for making http connection. The default value will now be &#8220;ColdFusion&#8221;. If this also does not work, you can use the same string that browsers like IE or firefox use. This attribute has been added to &lt;cfdocument&gt; and &lt;cfdocumentsection&gt; tag.</li>
</ul>
<p>6. <strong>PDF name</strong> : When a pdf generated by cfdocument is sent to the browser and you try to save it, the browser will prompt with the cfm name for the pdf which is generally not desirable.  With ColdFusion 8, you can provide the appropriate name in &#8220;saveAsName&#8221; attribute of cfdocument.</p>
<ul>
<li>saveAsName &#8211; Name that appears in the &#8217;saveAs&#8217; dialog when you try to save the pdf from the browser (Generally File -&gt; saveAs). This name will not work if you use &#8220;save&#8221; dialog of the pdf plugin.</li>
</ul>
<p>Here is a sample code for the same.</p>
<div class="code">
<pre>&lt;cfdocument format="pdf" saveAsName="mypdf"&gt; &lt;p&gt;This is a PDF document.&lt;/p&gt;&lt;/cfdocument&gt;</pre>
</div>
<p>7. <strong>Local URLs : </strong>When CFDocument body contains a relative URL, ColdFusion will resolve the relative URL to an absolute URL and will send an HTTP request for this url. A side effect of this is &#8211; Server ends up sending HTTP request even for local URL or images that are lying on the local file system which obviously hurts the performance. In ColdFusion 8, we have added a new attribute &#8220;localURL&#8221; to cfdocument tag which if enabled, will try to resolve the relative URLs as file on the local machine.</p>
<ul>
<li>localURL : &#8220;true&#8221; | &#8220;false&#8221; &#8211; It should be enabled if the images used in cfdocument body are on the local machine. This would make the cfdocument engine retrieve the images directly from the file system rather then asking the server for it over http. </li>
</ul>
<p>This attribute helps reducing the load from the server so that the same web server thread can now serve user request instead of serving local images to CFDocument. This also addresses some of the &#8220;missing image&#8221; problems which I mentioned <a href="http://coldfused.blogspot.com/2006/09/workaround-for-cfdocument-missing_19.html" target="_blank">here</a>. Here is a sample code using this attribute.</p>
<div class="code">
<pre>&lt;cfdocument format="PDF" localUrl="true"&gt; &lt;table&gt;  &lt;tr&gt;     &lt;td&gt;bird&lt;/td&gt;     &lt;td&gt;&lt;image src="images/bird.jpg"&gt;&lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;     &lt;td&gt;Rose&lt;/td&gt;     &lt;td&gt;&lt;image src="images/rose.jpg"&gt;&lt;/td&gt;  &lt;/tr&gt; &lt;/table&gt;&lt;/cfdocument&gt;</pre>
</div>
<p>8. <strong>Section Page Counts : </strong>CFDOCUMENT scope contains two new variables which give you the page counts for document section.</p>
<ul>
<li>TOTALSECTIONPAGECOUNT &#8211; total no of pages in the current section</li>
<li>CURRENTSECTIONPAGENUMBER &#8211; Current page number in the current section.</li>
</ul>
<p>9. <strong>Dynamic header and footer : </strong>CFDOCUMENT scope variables can now be used in expressions inside &lt;cfdocumentitem&gt; which makes it possible to have dynamic header and footers. You can now build logic for header/footer content based on the page number. Here is a sample code which prints section title if the page is even and prints the page no otherwise. Below is a code snippet which creates a dynamic header.</p>
<div class="code">
<pre>    &lt;cfdocumentitem type="header"&gt;       &lt;cfif (cfdocument.currentpagenumber mod 2) is 0&gt;           &lt;cfoutput&gt;#sectionTitle#&lt;/cfoutput&gt;       &lt;cfelse&gt;           &lt;cfoutput&gt;#cfdocument.currentpagenumber# of #cfdocument.TOTALPAGECOUNT#&lt;/cfoutput&gt;        &lt;/cfif&gt;   &lt;/cfdocumentitem&gt;</pre>
</div>
<p>10. We have also fixed most of the CFDocument related bugs e.g text chopping, image cropping or red-x, image scaling, &#8220;Document has no pages&#8221; etc.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rupeshk.org/blog/index.php/2007/07/enhancements-to-cfdocument-in-coldfusion-8/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>New CFDocument hotfix released !</title>
		<link>http://www.rupeshk.org/blog/index.php/2007/06/new-cfdocument-hotfix-released/</link>
		<comments>http://www.rupeshk.org/blog/index.php/2007/06/new-cfdocument-hotfix-released/#comments</comments>
		<pubDate>Mon, 18 Jun 2007 16:44:00 +0000</pubDate>
		<dc:creator>Rupesh Kumar</dc:creator>
				<category><![CDATA[cfdocument]]></category>
		<category><![CDATA[coldfusion]]></category>

		<guid isPermaLink="false">http://rupesh106.wordpress.com/2007/06/18/new-cfdocument-hotfix-released/</guid>
		<description><![CDATA[We have released ColdFusion MX 7.02 &#8211; CFDocument Cumulative Hot Fix that fixes lot of CFDocument related issues.Some of the important issues that we fixed in this hotfix are
1. Text getting chopped / clipped2. Image zoom or image cropped3. Header/Footer overwriting the text in the page body.
If you use cfdocument, it is a must have [...]]]></description>
			<content:encoded><![CDATA[<p>We have released <a href="http://www.adobe.com/go/kb402093">ColdFusion MX 7.02 &#8211; CFDocument Cumulative Hot Fix</a> that fixes lot of CFDocument related issues.<br />Some of the important issues that we fixed in this hotfix are</p>
<p>1. Text getting chopped / clipped<br />2. Image zoom or image cropped<br />3. Header/Footer overwriting the text in the page body.</p>
<p>If you use cfdocument, it is a must have hotfix for you.</p>
<p>You can download the hotfix <a href="http://kb.adobe.com/support/coldfusion/ts/documents/kb402093/hf702-65719.zip">here</a> but do not forget to read the instructions to apply this hotfix. Enjoy !</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rupeshk.org/blog/index.php/2007/06/new-cfdocument-hotfix-released/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Accessing password protected URL</title>
		<link>http://www.rupeshk.org/blog/index.php/2007/02/accessing-password-protected-url/</link>
		<comments>http://www.rupeshk.org/blog/index.php/2007/02/accessing-password-protected-url/#comments</comments>
		<pubDate>Sun, 25 Feb 2007 20:12:00 +0000</pubDate>
		<dc:creator>Rupesh Kumar</dc:creator>
				<category><![CDATA[cfdocument]]></category>
		<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://rupesh106.wordpress.com/2007/02/25/accessing-password-protected-url/</guid>
		<description><![CDATA[How do you access a password protected URL (requiring basic authentication) programmatically? well, there are two ways

If you know that the URL is protected : This is the simple one. Since you know the URL is protected, add the required authorization header in the request and you are done. What if you are not making [...]]]></description>
			<content:encoded><![CDATA[<p>How do you access a password protected URL (requiring basic authentication) programmatically? well, there are two ways</p>
<ol>
<li>If you know that the URL is protected : This is the simple one. Since you know the URL is protected, add the required authorization header in the request and you are done. What if you are not making the socket connection but instead using java.net.URL or java.net.URLConnection to retrieve the content of url? You can use setRequestProperty() method of URLConnection to add any request header you want. So the code would look like

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #003399;">URL</span> url <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">URL</span><span style="color: #009900;">&#40;</span>someurlstring<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">URLConnection</span> conn <span style="color: #339933;">=</span> url.<span style="color: #006633;">openConnection</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">String</span> encoding <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> sun.<span style="color: #006633;">misc</span>.<span style="color: #006633;">BASE64Encoder</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">encode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;username:password&quot;</span>.<span style="color: #006633;">getBytes</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
conn.<span style="color: #006633;">setRequestProperty</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Authorization&quot;</span>, <span style="color: #0000ff;">&quot;Basic &quot;</span> <span style="color: #339933;">+</span> encoding<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">InputStream</span> in <span style="color: #339933;">=</span> conn.<span style="color: #006633;">getInputStream</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
...</pre></div></div>

</li>
<li>What if you dont know in advance whether the URL is protected or not? You can not arbitrarily add the authorization heder for all the URLs. The answer to this is &#8220;java.net.Authenticator&#8221;. You need to install an instance of java.net.Authenticator using setDefault() method of Authenticator. Whenever URLConnection sees that the url is protected, it will use this installed authenticator to get the username and password and set the required authorization header automatically.<br />
Here is how the code snippet for doing this</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #003399;">Authenticator</span>.<span style="color: #006633;">setDefault</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> MyAuthenticator<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
....
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MyAuthenticator <span style="color: #000000; font-weight: bold;">extends</span> <span style="color: #003399;">Authenticator</span>
<span style="color: #009900;">&#123;</span>
 <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #003399;">PasswordAuthentication</span> getPasswordAuthentication<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
 <span style="color: #009900;">&#123;</span>
     <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">PasswordAuthentication</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;username&quot;</span>, <span style="color: #0000ff;">&quot;password&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>This particular technique is particularly useful for people who need a workaround for retrieving password protected images in cfdocument. Here is what you need to do.</p>
<ul>
<li>Use the source below to create Authenicator class

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.net.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MyAuthenticator <span style="color: #000000; font-weight: bold;">extends</span> <span style="color: #003399;">Authenticator</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> user<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> passwd<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> MyAuthenticator<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> user, <span style="color: #003399;">String</span> passwd<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">user</span> <span style="color: #339933;">=</span> user<span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">passwd</span> <span style="color: #339933;">=</span> passwd<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #003399;">PasswordAuthentication</span> getPasswordAuthentication<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">PasswordAuthentication</span><span style="color: #009900;">&#40;</span>user, passwd.<span style="color: #006633;">toCharArray</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Compile this and put MyAuthenticator.class in wwwroot/WEB-INF/classes.</li>
<li>Put the following code in your application.cfm or application.cfc

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfif</span> not <span style="color: #800080; font-weight: bold;">IsDefined</span><span style="color: #0000FF;">&#40;</span><span style="color: #009900;">&quot;Application.authenticator&quot;</span><span style="color: #0000FF;">&#41;</span><span style="color: #0000FF;">&gt;</span></span>
      <span style="color: #808080; font-style: italic;">&lt;!--- Do initializations ---&gt;</span>
      <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> authenticator<span style="color: #0000FF;">=</span> <span style="color: #800080; font-weight: bold;">createObject</span><span style="color: #0000FF;">&#40;</span><span style="color: #009900;">&quot;java&quot;</span>, <span style="color: #009900;">&quot;java.net.Authenticator&quot;</span><span style="color: #0000FF;">&#41;</span><span style="color: #0000FF;">&gt;</span></span>
      <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> myauthenticator <span style="color: #0000FF;">=</span> <span style="color: #800080; font-weight: bold;">createObject</span><span style="color: #0000FF;">&#40;</span><span style="color: #009900;">&quot;java&quot;</span>, <span style="color: #009900;">&quot;MyAuthenticator&quot;</span><span style="color: #0000FF;">&#41;</span>.init<span style="color: #0000FF;">&#40;</span><span style="color: #009900;">&quot;username&quot;</span>, <span style="color: #009900;">&quot;password&quot;</span><span style="color: #0000FF;">&#41;</span><span style="color: #0000FF;">&gt;</span></span>
      <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> authenticator.setDefault<span style="color: #0000FF;">&#40;</span>myauthenticator<span style="color: #0000FF;">&#41;</span><span style="color: #0000FF;">&gt;</span></span>
      <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> <span style="color: #0000FF;">Application</span>.authenticator<span style="color: #0000FF;">=</span>myauthenticator<span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfif</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>

<p>replace &#8220;username&#8221; and &#8220;password&#8221; with actual username and password.</li>
<li>give the request for the cfdocument page for which you were getting the red-x for image. The images should appear this time.</li>
</ul>
</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.rupeshk.org/blog/index.php/2007/02/accessing-password-protected-url/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Connecting to URL from behind a proxy server</title>
		<link>http://www.rupeshk.org/blog/index.php/2006/09/connecting-to-url-from-behind-a-proxy-server/</link>
		<comments>http://www.rupeshk.org/blog/index.php/2006/09/connecting-to-url-from-behind-a-proxy-server/#comments</comments>
		<pubDate>Wed, 20 Sep 2006 19:11:00 +0000</pubDate>
		<dc:creator>Rupesh Kumar</dc:creator>
				<category><![CDATA[cfdocument]]></category>
		<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://rupesh106.wordpress.com/2006/09/20/connecting-to-url-from-behind-a-proxy-server/</guid>
		<description><![CDATA[I needed a way to set the proxy information on URL/URLConnection and I could not find any good way. One simple way that java recommends is to set the information as system property. These properties are &#8220;http.proxyHost&#8221; and &#8220;http.proxyPort&#8221;. 
So it can either be set as jvm arguments like 
-DproxySet=true -Dhttp.proxyHost=proxyIP -DproxyPort=port
or set them in [...]]]></description>
			<content:encoded><![CDATA[<p>I needed a way to set the proxy information on URL/URLConnection and I could not find any good way. One simple way that java recommends is to set the information as system property. These properties are &#8220;http.proxyHost&#8221; and &#8220;http.proxyPort&#8221;. </p>
<p>So it can either be set as jvm arguments like 
<div class="code">-DproxySet=true -Dhttp.proxyHost=proxyIP -DproxyPort=port</div>
<p>or set them in the code using System.setProperty()</p>
<p>However since this is a system property, it gets set on the VM itself and hence it is not dynamic. In ColdFusion, since tags like &#8216;cfhttp&#8217; keep them dynamic, I wanted a similar behaviour. After looking around for a while, I noticed that this capability was added in Java 1.5 aka Tiger release. (Is it only me? I keep hitting things which I feel is lacking in java API and then I find them added in 1.5 <img src='http://www.rupeshk.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  )</p>
<p>In Java 1.5, you can use 
<div class="code">URLConnection conn = url.openConnection(proxy); // added in 1.5</div>
<p>where proxy is an object of <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/net/Proxy.html">java.net.Proxy</a>. Pretty neat.</p>
<p>However this was not a solution for me as we are still developing on JDK1.4 (need to consider all the application servers that we have to  support). I stumbled upon an interesting article by <a href="http://bdn.borland.com/article/0,1410,29783,00.html">Daniel Horn</a> who faced the exact same problem. And guess what he did? Since you send an HTTP request to the proxy and then proxy sends out the actual request, he created the URL object by passing proxyHost and proxyPort as IP and port and then he gave the target url string as &#8216;file&#8217; argument. This is what he did.</p>
<div class="code">String actualUrl = &#8220;http://www.adobe.com&#8221;;<br />URL url = new URL(&#8221;http&#8221;, proxyHost, proxyPort, actualUrl);<br />URLConnection conn = url.openConnection();<br />..<br />..</div>
<p>And it works ! Brilliant !! I wonder why this is not documented in the java API.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rupeshk.org/blog/index.php/2006/09/connecting-to-url-from-behind-a-proxy-server/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>A workaround for cfdocument missing images</title>
		<link>http://www.rupeshk.org/blog/index.php/2006/09/a-workaround-for-cfdocument-missing-images/</link>
		<comments>http://www.rupeshk.org/blog/index.php/2006/09/a-workaround-for-cfdocument-missing-images/#comments</comments>
		<pubDate>Tue, 19 Sep 2006 18:57:00 +0000</pubDate>
		<dc:creator>Rupesh Kumar</dc:creator>
				<category><![CDATA[cfdocument]]></category>
		<category><![CDATA[coldfusion]]></category>

		<guid isPermaLink="false">http://rupesh106.wordpress.com/2006/09/19/a-workaround-for-cfdocument-missing-images/</guid>
		<description><![CDATA[This is with reference to the post Missing images in CFDocument. There are some cases when the images are locally on the machine running ColdFusion but even then cfdocument is not able to show the images. The reasons could be
1) ColdFusion is behind a firewall because of which it is not able to send any [...]]]></description>
			<content:encoded><![CDATA[<p>This is with reference to the post <a href="http://coldfused.blogspot.com/2005/11/missing-images-in-cfdocument.html">Missing images in CFDocument</a>. There are some cases when the images are locally on the machine running ColdFusion but even then cfdocument is not able to show the images. The reasons could be<br />
1) ColdFusion is behind a firewall because of which it is not able to send any HTTP request (even though to itself).<br />
2) The images are under a protected directory which needs authentication. Since cfdocument can not send authentication information currently, it is not able to fetch the image.<br />
3) ColdFusion is using HTTPS and it is not configured properly to trust itself. So cfdocument can not send a https request to itself.<br />
4) Any other reason which is preventing CFDocument from sending request to the local server.</p>
<p>If the images are on local machine, it is possible to use the file url for images (or CSS,javascripts, etc). CFDocument in that case will not send requests for the images over HTTP and fetch the image directly from the file system. Here is a simple way to use the file url.</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfdocument</span> <span style="color: #0000FF;">format</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;pdf&quot;</span><span style="color: #0000FF;">&gt;</span></span>
 <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfoutput</span><span style="color: #0000FF;">&gt;</span></span>
   Some html content
   <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #000000;">br</span><span style="color: #0000FF;">&gt;</span></span>
   <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #000000;">img</span> <span style="color: #0000FF;">src</span><span style="color: #0000FF;">=</span>#localUrl<span style="color: #0000FF;">&#40;</span><span style="color: #009900;">&quot;img1.gif&quot;</span><span style="color: #0000FF;">&#41;</span>#<span style="color: #0000FF;">&gt;&lt;</span><span style="color: #000000;">br</span><span style="color: #0000FF;">&gt;</span></span>
   <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #000000;">img</span> <span style="color: #0000FF;">src</span><span style="color: #0000FF;">=</span>#localUrl<span style="color: #0000FF;">&#40;</span><span style="color: #009900;">&quot;images/img.jpg&quot;</span><span style="color: #0000FF;">&#41;</span>#<span style="color: #0000FF;">&gt;</span></span>
 <span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfoutput</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfdocument</span><span style="color: #0000FF;">&gt;</span></span>
&nbsp;
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cffunction</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;localUrl&quot;</span> <span style="color: #0000FF;">&gt;</span></span>
  <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfargument</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;file&quot;</span> <span style="color: #0000FF;">/&gt;</span></span>
  <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> <span style="color: #0000ff;">var</span> fpath <span style="color: #0000FF;">=</span> <span style="color: #800080; font-weight: bold;">ExpandPath</span><span style="color: #0000FF;">&#40;</span><span style="color: #0000FF;">file</span><span style="color: #0000FF;">&#41;</span><span style="color: #0000FF;">&gt;</span></span>
  <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> <span style="color: #0000ff;">var</span> f<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;&quot;</span><span style="color: #0000FF;">&gt;</span></span>
  <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> f <span style="color: #0000FF;">=</span> <span style="color: #800080; font-weight: bold;">createObject</span><span style="color: #0000FF;">&#40;</span><span style="color: #009900;">&quot;java&quot;</span>, <span style="color: #009900;">&quot;java.io.File&quot;</span><span style="color: #0000FF;">&#41;</span><span style="color: #0000FF;">&gt;</span></span>
  <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> f.init<span style="color: #0000FF;">&#40;</span>fpath<span style="color: #0000FF;">&#41;</span><span style="color: #0000FF;">&gt;</span></span>
  <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfreturn</span> f.toUrl<span style="color: #0000FF;">&#40;</span><span style="color: #0000FF;">&#41;</span>.<span style="color: #800080; font-weight: bold;">toString</span><span style="color: #0000FF;">&#40;</span><span style="color: #0000FF;">&#41;</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cffunction</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>

<p>basically here I have an UDF which converts any path to local URL and then I am using that UDF in &#8217;src&#8217; attribute of image. This can be used to fetch images, css or any other similar contents from the local machine. You should note the &lt;cfoutput&gt; right under cfdocumet tag that allows the evaluation of UDF before it goes to cfdocument body.. This workaround is applicable only when the these contents are present on the same machine as ColdFusion.</p>
<p>This workaround has another advantage too. Normally when CFDocument body has any images, it fetches those images by sending HTTP request to the local server which is served by web threads. This has its own overhead. In a way, CFDocument uses server resource for getting something which is available locally on the server. This resource can instead be used to serve actual client http requests. Converting the image path to local urls will not go through  HTTP and thus should have a better performance.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rupeshk.org/blog/index.php/2006/09/a-workaround-for-cfdocument-missing-images/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Hotfix for CFDocument thread hang in CF7.0.1 standard.</title>
		<link>http://www.rupeshk.org/blog/index.php/2006/05/hotfix-for-cfdocument-thread-hang-in-cf7-0-1-standard/</link>
		<comments>http://www.rupeshk.org/blog/index.php/2006/05/hotfix-for-cfdocument-thread-hang-in-cf7-0-1-standard/#comments</comments>
		<pubDate>Thu, 04 May 2006 15:40:00 +0000</pubDate>
		<dc:creator>Rupesh Kumar</dc:creator>
				<category><![CDATA[cfdocument]]></category>
		<category><![CDATA[coldfusion]]></category>

		<guid isPermaLink="false">http://rupesh106.wordpress.com/2006/05/04/hotfix-for-cfdocument-thread-hang-in-cf7-0-1-standard/</guid>
		<description><![CDATA[There was a problem in CF7.0.1 standard edition where if you hit any error in a page using CFDocument, any other page using cfdocument will hang. This was a threading issue we had for standard edition and was logged as bug 61378.
This was fixed in the hotfix 1 and is available at http://www.adobe.com/support/coldfusion/ts/documents/aae43964/chf7010001.jar
However I would [...]]]></description>
			<content:encoded><![CDATA[<p>There was a problem in CF7.0.1 standard edition where if you hit any error in a page using CFDocument, any other page using cfdocument will hang. This was a threading issue we had for standard edition and was logged as bug 61378.</p>
<p>This was fixed in the hotfix 1 and is available at <br />http://www.adobe.com/support/coldfusion/ts/documents/aae43964/chf7010001.jar</p>
<p>However I would recommend you to use hotfix 2 at<br />http://www.adobe.com/support/coldfusion/ts/documents/aae43964/chf7010002.jar<br />See the details of this hotfix at http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=aae43964</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rupeshk.org/blog/index.php/2006/05/hotfix-for-cfdocument-thread-hang-in-cf7-0-1-standard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
