View comments | RSS feed

cfdocument

Description

Creates PDF or FlashPaper output from a text block containing CFML and HTML.

Category

Data output tags

Syntax

<cfdocument 
backgroundvisible = "yes" or "no"
encryption = "128-bit" or "40-bit" or "none"
format = "PDF" or "FlashPaper"
filename = "filename"
fontembed = "yes" or "no"
marginbottom = "number"
marginleft = "number"
marginright = "number"
margintop = "number"
mimetype = "text/plain" or "text/xml" or "image/jpeg" or "image/png" or "image/gif"
name = "output variable name"
orientation = "portrait" or "landscape"
overwrite = "yes" or "no"
ownerpassword = "password"
pageheight = "page height in inches"
pagetype = "page type"
pagewidth = "page width in inches"
permissions = "permission list"
scale = "percentage less than 100">
src = "url or path relative to web root"
srcfile = "absolute path of file"
unit = "in" or "cm"
userpassword = "password"
HTML and CFML code </cfdocument>

See also

cfreport, cfdocumentitem, cfdocumentsection

History

ColdFusion MX 7 Updater: Added the src, srcfile, and mimetype attributes.

ColdFusion MX 7: Added this tag.

Attributes

Attribute Req/Opt Default Description

format

Required

 

Specifies the report format:

  • PDF
  • FlashPaper

filename

Optional

 

Specifies the name of a file to contain the PDF or FlashPaper output.

If you omit the filename attribute, ColdFusion MX streams output to the browser.

overwrite

Optional

no

Specifies whether ColdFusion MX overwrites an existing file. Used in conjunction with the filename attribute

name

Optional

 

Specifies the name of an existing variable into which the tag stores the PDF or FlashPaper output.

pagetype

Optional

letter

Specifies the page size into which ColdFusion generates the report:

  • legal: 8.5 inches x 14 inches.
  • letter: 8.5 inches x 11 inches.
  • A4: 8.27 inches x 11.69 inches.
  • A5: 5.81 inches x 8.25 inches.
  • B4: 9.88 inches x 13.88 inches.
  • B5: 7 inches x 9.88 inches.
  • B4-JIS: 10.13 inches x 14.31 inches.
  • B5-JIS: 7.19 inches x 10.13 inches.
  • Custom: custom height and width. If you specify custom, you must also specify the pageheight and pagewidth attributes, can optionally specify margin attributes, and can optionally specify whether the units are inches or centimeters.

pageheight

Optional

 

Specifies the page height in inches (default) or centimeters. This attribute is only valid if pagetype=custom. To specify page height in centimeters, include the unit=cm attribute.

pagewidth

Optional

 

Specifies the page width in inches (default) or centimeters. This attribute is only valid if pagetype=custom. To specify page width in centimeters, include the unit=cm attribute.

orientation

Optional

portrait

Specifies the page orientation:

  • portrait
  • landscape

margintop

Optional

 

Specifies the top margin in inches (default) or centimeters. To specify the top margin in centimeters, include the unit=cm attribute.

marginbottom

Optional

 

Specifies the bottom margin in inches (default) or centimeters. To specify the bottom margin in centimeters, include the unit=cm attribute.

marginleft

Optional

 

Specifies the left margin in inches (default) or centimeters. To specify the left margin in centimeters, include the unit=cm attribute.

marginright

Optional

 

Specifies the right margin in inches (default) or centimeters. To specify the right margin in centimeters, include the unit=cm attribute.

unit

Optional

in

Specifies the default unit for the pageheight, pagewidth, and margin attributes:

  • in: inches.
  • cm: centimeters.

encryption

Optional

None

(format="PDF" only) Specifies whether the output is encrypted:

  • 128-bit
  • 40-bit
  • none

ownerpassword

Optional

 

(format="PDF" only) Specifies an owner password.

userpassword

Optional

 

(format="PDF" only) Specifies a user password.

permissions

Optional

 

(format="PDF" only) Specifies one or more of the following permissions:

  • AllowPrinting
  • AllowModifyContents
  • AllowCopy
  • AllowModifyAnnotations
  • AllowFillIn
  • AllowScreenReaders
  • AllowAssembly
  • AllowDegradedPrinting

Separate multiple permissions with a comma.

fontembed

Optional

yes

Specifies whether ColdFusion embeds fonts in the output:

  • yes: embed fonts.
  • no: do not embed fonts.

Selective: embed all fonts except Java fonts and core fonts. For more information, see Usage.

backgroundvisible

Optional

no

Specifies whether the background prints when the user prints the document:

  • yes: include the background when printing.
  • no: do not include the background when printing.

scale

Optional

Calculated by ColdFusion

Specifies a scale factor as a percentage. Use this option to reduce the size of the HTML output so that it fits on that paper. Specify a number less than 100.

src

Optional

 

Specifies the URL or the relative path to the web root. You cannot specify both the src and srcfile attributes.

srcfile

Optional

 

Specifies the absolute path of a file that is on the server. You cannot specify both the src and srcfile attributes.

mimetype

Optional

text/html

Specifies the MIME type of the source document. Commom MIME types include:

  • text/plain
  • text/xml
  • image/jpeg
  • image/png
  • image/gif

Usage

Use the cfdocument tag to render HTML and CFML output into PDF or FlashPaper format. ColdFusion MX does not return HTML and CFML outside of the
<cfdocument> </cfdocument> pair.

The cfdocument tag can render HTML that supports the following standards:

The cfdocument tag does not support the Internet Explorer-specific HTML generated by Microsoft Word.

You can use the src, srcfile, and mimetype attributes to create PDF or FlashPaper output from a secified file or URL. You use the src and srcfile attributes instead of using the cfhttp tag to display the result in the cfdocument tag. Do not use the src or srcfile attributes with any other content inside the cfdocument tag, because ColdFusion ignores any body content you specify in the cfdocument tag when you use the src or srcfile attribute.

The PDF or FlashPaper document returned by the cfdocument tag overwrites any previous HTML in the input stream and ignores any HTML after the </cfdocument> tag.

You cannot embed a cfreport tag in a cfdocument tag.

When you use the cfdocument tag, ColdFusion MX creates a new scope named cfdocument. This scope contains the following variables:

Note: The cfdocument scope variables are reserved for page number rendering. Do not use them in ColdFusion expressions. For example, the following code does not work:

<cfif cfdocument.currentpagenumber gt 1>
   <cfoutput>#cfdocument.currentpagenumber-1#</cfoutput>
</cfif>

Example

<cfdocument format="flashpaper">
<p>This is a document rendered by the cfdocument tag.</p>

<table width="50%" border="2" cellspacing="2" cellpadding="2">
  <tr>
    <td><strong>Name</strong></td>
    <td><strong>Role</strong></td>
  </tr>
  <tr>
    <td>Bill</td>
    <td>Lead</td>
  </tr>
  <tr>
    <td>Susan</td>
    <td>Principal Writer</td>
  </tr>
  <tr>
    <td>Adelaide</td>
    <td>Part Time Senior Writer</td>
  </tr>
  <tr>
    <td>Thomas</td>
    <td>Full Time for 6 months</td>
  </tr>
  <tr>
    <td>Michael</td>
    <td>Full Time for 4 months</td>
  </tr>
</table>
</cfdocument> 

ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | KnowledgeBase | Bug Reporting

Version 7

Comments


No screen name said on Feb 15, 2005 at 11:23 AM :
I have been trying out the example for cfdocument - the example works fine when using flashpaper, but when switched to pdf only a blank screen is displayed.
jrunrandy said on Feb 16, 2005 at 8:16 AM :
Try closing and re-opening your browser. The browser is attempting to use
the cached, FlashPaper, version.
nitrog7 said on Mar 3, 2005 at 6:15 AM :
Can the cfdocument be embedded/inline with other content on the page?

There isn't a height and width attribute to resize the generated swf (flashpaper) file. When the cfdocument tag is used, it takes up the whole page.
nitrog7 said on Mar 3, 2005 at 6:58 AM :
Figured it out...

You create a seperate file with the cf document tag and then embed that page as a flash file (and in the flash params, specify the width and height), it just takes some time to load up.
john_stephenson said on Mar 8, 2005 at 10:49 AM :
Stylesheet problem: make sure your css link tag is located under the cfdocument tag (not above).
soonersak said on Mar 12, 2005 at 10:42 PM :
Does the tag work with cfchart inside of it? My page comes up blank when I'm use cfhart withinn cfdocument.
Project 8 said on Mar 13, 2005 at 12:32 PM :
I get the same thing when I run the page... CWSëQxÚä½ |Ôŵ8>»É&›„HH`€„÷›€y? ÙÄM@¤jØd7Ù…Í`µFŒˆZQŞ‚¨E­­µŞ|P|VlíÅV[j[¯õZkmí½í¯ÍoΙ™ïw¾ Øë½ŸÏÿó·eóıÎwgΜ9sΙ3gúˆ­Ñ‡ ÉN"UÖááỈ…ԝøÁñbÉ&ô?ká¹ 9›b¥É·$%Yè+)§éÿB ߉!‘oZÆéO¸oİùC ×׺õÉò³)‰¢H/r’ØH½å<¡U“-×_O 2ÒûG½cËx:5ïöÅÇÖ÷?şã{Ó#©ùìE“zZŽÿÌí~8“¶$*²ñŠž'¯ÓßdZQ±¥‘î®.òç?ÿ™|òÉÇd`×Ù¶mi[×FÊV–‘“'O’C‡‘[n¹…lݺ•”O,}qÊş]ÛGmߞô؍c+O®)¿Í5}..

does something extra need to installed or enabled on the server for this tag to work? Thanks.
jrunrandy said on Mar 14, 2005 at 1:31 PM :
mijoo and Project 8. This problem is usually
caused by the following: 1) display a cfdocument
page that has a syntax error. 2) Fix the error,
3) Redisplay the page: garbage characters display.

This is actually and IE bug and you can get around
it by opening and closing the browser.

soonersak: you cannot use cfchart in cfdocument. This
restriction is mentioned in the ColdFusion MX
Developer's Guide, but we neglected to mention it
on this page. To use cfchart in PDF/FlashPaper output,
use the ColdFusion ReportBuilder with or without
the cfreport tag.
hotHouseAlastair said on Mar 16, 2005 at 3:24 AM :
I'm finding that when using cfdocument to create a PDF it'll cut the top of the first line of text on the second page of text.

any ideas?

see: http://www.parins.org/resources/myReport.pdf
EricGyenes said on Mar 16, 2005 at 3:58 PM :
When launching a page with cfdocument tag from a form I get the IE security warning when using SSL.

I can't get it to go away using <cfsavecontent>

Has anyone got a fix for this?

Oddly enough, if I launch the page without using a form submission it works. Only I cannot pass all the variables I need without a form submission.
Mike Yang said on Mar 16, 2005 at 9:46 PM :
I am using cfdocument trying to display a gif file.
I noticed that if there is space or spaces within the GIF file name then the result page won't display the image and only display a small red X where the image is. Anybody has a idea how to make it work without change all the file names?
Thanks
tzimmerman said on Mar 21, 2005 at 9:15 AM :
Jason,
See http://livedocs.macromedia.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=ColdFusion_Documentation&file=00001475.htm. You probably need to create a cffont.properties.zh file. You should be able to copy the cffont.properties.ja file. Then make sure you have the available fonts on the server.
bleedinorange said on Mar 22, 2005 at 9:06 AM :
When I try to use cfdocument, I'm putting the opening and closing cfdocument tags within a condition and it bombs. ie. <cfif #url.pdf# eq 'Y'><cfdocument format='pdf'></cfif> and at the end of the document: <cfif #url.pdf# eq 'Y'></cfdocument></cfif>. I get a "context validation error" that states that the end tag, </cfdocument> requires a matching start tag. What's up with that?
jrunrandy said on Mar 29, 2005 at 2:45 PM :
bleedinorange:
I'm sorry to say that cfdocument was not designed to work within a conditional statement.

I have filed this as doc bug 59995.
cusinger said on Apr 2, 2005 at 1:23 PM :
I can't get images to appear in a pdf created by <cfdocument>

Code:
<cfdocument format="pdf" filename="invoices/testing2.pdf" overwrite="yes">

<table cellspacing="1" cellpadding="1" border=1><tr>

<td width="361" rowspan="4" ><img src="#form.logo#"></td>
<td valign="top"><h1>INVOICE3</h1></td></tr></table>

</cfdocument></cfoutput>

I've tried relative addresses, full addresses, and neither work.
iots190 said on Apr 4, 2005 at 6:14 AM :
Did you try putting the <cfoutput> tags around just the image part? Looks like you have an ending tag but no beginning tag.
aupmann said on Apr 6, 2005 at 12:26 PM :
I am trying to include a background image on a pdf created with cfdocument. I can see it when I preview my code in dreamweaver but no image appears when I create a pdf. Any ideas?
No screen name said on Apr 8, 2005 at 7:44 AM :
When we creat a PDF with images, the images sometimes are blown out of proportion. In other words, it appears the images are "zoomed" within the PDF. Is there a way to prevent this?
Boberto said on Apr 11, 2005 at 7:00 AM :
I have found an issue with cfdocument and resolved it.

If you create a PDF with images and your server is behind a firewall and you can't resolve your website when you're behind the firewall, cfdocument will not be able to display images. To get by this I had to install a local DNS server behind the firewall so that the java program that creates the PDF can resolve the website. Adding an entry to a host file does not work.
jedimatt said on Apr 11, 2005 at 9:30 AM :
Mike Yang

Or anyone else who is experiencing the problem with spaces in image files when using cfdocument.

To make a image appear in either a Flash paper or pdf doc when the image has spaces in the file name:

i.e.

my image.gif

you can use the following function:

URLEncodedFormat()

So wrap this function around your image file name like:

URLEncodedFormat(my image.gif)

which should output as my%20image.gif

The function does the following:
Generates a URL-encoded string. For example, it replaces spaces with %20, and non-alphanumeric characters with equivalent hexadecimal escape sequences. Passes arbitrary strings within a URL (ColdFusion automatically decodes URL parameters that are passed to a page).

This has been proven and works in my situation.

Hope this helps anyone

Matt
jedimatt said on Apr 12, 2005 at 12:59 AM :
Cutting top margin in pdf output problem.

Why don't people try experiementing with the tag properties to remove small problems with the cfdocument outputs instead of jumping straight in and saying things are not working properley and has anyone fixed the problem.

It took me 1 minute to sort out the pdf output cutting off the top of the second page problem by adding in a small top margin like:

<cfdocument format="pdf" pagetype="a4" margintop="0.1">

Problem fixed.

This may vary for different printers/setups so you will need to experiement with it.

I am no expert but i used my common sense to fix two issue with this tag in a very short space of time.
sharpie81 said on Apr 12, 2005 at 12:44 PM :
Thanks for your common sense post JediMatt. I HAVE used the margin attribute with the cfdocument tag and the margin attribute with the cfdocumentsection tag and have still had the same problems with dynamic output being chopped of on subsequent pages. I'm sure I'm not the only person who has had this problem.
fiffy said on Apr 14, 2005 at 6:59 AM :
Did anyone find out why images appear blown out (zoomed) sometimes? It seems like this happens on a random basis...
No screen name said on Apr 14, 2005 at 9:51 AM :
Hi Fiffy - this "image zooming" is happening to us frequently. I hope Macromedia responds to this. It's a major problem given the ammount of images we're including in our PDFs.
mijoo said on Apr 14, 2005 at 11:30 AM :
I am having same problem as sharpie81. I tried almost everything and it still chopping my data on subsequent pages when I run dynamic page.
Please... anyone have solution for this.. is this bug with the tag?
mijoo said on Apr 15, 2005 at 9:49 AM :
It seems like no one has answer for the chopping data off problem with this tag. I have posted under the forums too and no anwer. I am sure more people are having this problem. I really need to find solution soon.. help anyone!!
No screen name said on Apr 25, 2005 at 10:20 AM :
From my experience: The cfdocument tag DOES NOT support all CSS functions. for me, the problem was using "text-transform: capitalize;"

the way i ended up having to get around this was creating a small script to convert first letters of a string to uppercase:
<cfset last1 = Left(getclient.last, 1)>
<cfset last2 = Right(getclient.last, len(getclient.last)-1)>
<cfset newlastname = #ucase(last1)# & #last2#>


Another thing I have found is that the Red Xs that other users have complained of appearing in their PDFs rather than their embedded images is because of the developers edition. When using a licensed version, you will be able to embed images and remove the ugly developer tag on your PDFs.


Hope this helps anyone like myself who didnt find the answers they needed when coming to Macromedia Livedocs for help.
justinbiggs said on Apr 25, 2005 at 3:53 PM :
Has anyone tried to create a document with the size of 5x7 inches with 0" margins? Whenever I try to with an image that is exactly 5x7 it puts a white margin around the right and bottom sides of my image, however when I double the document size to 10x14 and double the width of my image it works just fine and bleeds to the edge of the document. Is this a glich? Does cfdocument have any minimum document dimensions?
No screen name said on Apr 26, 2005 at 3:06 PM :
in addition to my previous post, i needed to be able to capitalize multiple words... here is my solution:

<cfset companynamearray = ListToArray(companyname, " ")>

<cfif ArrayLen(companynamearray) gt 1> <!--- IF ITS MORE THAN ONE WORD --->
<span class="caps">
<cfloop index="i" to="#ArrayLen(companynamearray)#" from="1" step="1">
<cfset companynametouse = #trim(companynamearray[i])#>
<cfif len(companynametouse) gt 1>
<cfset companyname1 = Left(#companynametouse#, 1)>
<cfset companyname2 = Right(#companynametouse#, len(#companynametouse#)-1)>
<cfset newcompanyname = #ucase(companyname1)# & #lcase(companyname2)#>
<cfelseif len(companynametouse) eq 1>
<cfset newcompanyname = #companynametouse#>
</cfif>
#trim(newcompanyname)#
</cfloop>
<br>
</span>
<cfelseif ArrayLen(companynamearray) eq 1> <!--- IF ITS A SINGLE WORD --->
<cfset companynametouse = #trim(companyname)#>
<cfset companyname1 = Left(#companynametouse#, 1)>
<cfset companyname2 = Right(#companynametouse#, len(#companynametouse#)-1)>
<cfset newcompanyname = #ucase(companyname1)# & #lcase(companyname2)#>
<span class="caps">#newcompanyname#<br>
</span>
</cfif>
ASandstrom said on Apr 27, 2005 at 10:39 AM :
To justinbiggs:
I have entered this as a bug (# 60120).
wwwmaster said on May 9, 2005 at 10:24 AM :
It seems that several people are having the issue where images randomly appear with an unusual zoom effect, yet no one has logged it as a bug.
ASandstrom said on May 10, 2005 at 7:03 AM :
You can report bugs by clicking the Bug Reporting link that appears below the page content and above the comments on any LiveDocs page. When submitting a bug, the more specific, and therefore reproducible, the example is, the better.
No screen name said on May 10, 2005 at 4:07 PM :
very true. i have had the same issues.


basically due to all of the bugs, i have had to completely stop all cfdocument development in my company.
Thadeaus said on May 12, 2005 at 8:53 AM :
To: Boberto
Thanks so much for your hint. The firewall was blocking the cfdocument tag for getting embedded images. I added a host entry for my website on that server and it worked fine. Didn't want to add a DNS server to the DMZ.
jbauschatz said on May 12, 2005 at 2:15 PM :
Can I force a page break? I am trying to print several pages worth of records review. The content only occupies half the printed page, and I need one record per page.
tedxas said on May 16, 2005 at 2:36 PM :
jbauschatz: insert this where you want a pagebreak:

<cfdocumentitem type = "pagebreak"/>
jimfree said on May 18, 2005 at 10:22 AM :
Regarding problem with lines being chopped off at top and bottom margins while outputing dynamic information with the CFDOCUMENT tag.

As far as setting top margin is concerned I've discovered you have to allow for headers. If you have a header that uses the top 1 inch and set the margin to .1 a lot of text disappears behind the header. In my particular case I had to set it to 1.1 to get it below the header.

I solved most but not all of the chopping off problem by putting everything in tables. When a row doesn't fit on one page it forces the whole row to the next page and by having at least one blank line in front of the text in at least one cell it seems to force it down enough.

Even with all that I still have some instances where the lines are split in half. It would be nice to have the ability to check for approximate location within the page and force a break at a specific point. That would allow us to check when we hit say the 10 inch point and force a page break.
No screen name said on May 23, 2005 at 2:52 PM :
Is there a list of styles that work with cfdocument? For example, I am using text-transform:uppercase and it doesn't work at all (either in a css sheet, or style tag). What's up with that?
No screen name said on May 23, 2005 at 4:00 PM :
Also, when will cfdocument support CSS3 styles? I realize some things are not finalized yet, but the child selectors (nth-child(odd) for example) are *very* helpful... this behavior is very difficult to mimic in coldfusion.
No screen name said on May 24, 2005 at 8:32 AM :
Another question/problem, strange white-space appears when using tags within a p tag, for example, the code:

<cfdocument>
<p>If you have not yet read the Read Me First pamphlet you received with your course materials, please do so before continuing. It contains information you need to know to successfully complete this course. The Read Me First pamphlet is also available on the Internet at <u>http://blah.htm</u>.</p>
</cfdocument

Produces strange white-space in the pdf document where the <u> tags are.... I have changed the <u> tags to several different tags, but always wind up with the same result: strange white space.
Hanszon said on May 24, 2005 at 9:12 AM :
Has anyone tried to, or does anyone know how I can, achieve vertical page breaks on a generated PDF? I have a dynamically generated table that is breaking in the middle of a column, but as my content is variable length, the breaking column is not consistent across all instances of the page
No screen name said on May 24, 2005 at 9:32 AM :
Hanszon: You can use a CSS style page-break-after to achieve this. It would look like:
table {
page-break-after:always;
}
Obviously you would use an id or class so that it wouldn't break after *every* table
No screen name said on May 24, 2005 at 9:47 AM :
As much as I love making comment after comment, this is getting frustrating. It appears there is a problem with the pdf output using the right-side margin... it works in flashpaper but not adobe... I'd normally assume macromedia was trying to sabotage adobe but now that they've been bought by them... :)
Anyway, here is the problem:

<cfdocument format="pdf" marginleft="0" marginright="0">
<p>Dear Student: Welcome to this course. As you take this course, you are embarking on a fascinating adventure. Gaining knowledge and developing our abilities are also among the most fulfilling experiences in our lives. Some text, here is some text, here is some text, here is some text, here is some text, here is some text, here is some text, here is some text, here is some text, here is some text, here is some text, here is some text, here is some text, here is some text, here is some text, here is some text, here is some text, here is some text, here is some text, here is some text, here is some text, here is some text, here is some text, here is some text, here is some text, here is some text, here is some text, here is some text, here is some text, here is some text, here is some text, here is some text, here is some text, here is some text, here is some text, here is some text, here is some text, here is some text, </p>
</cfdocument>

With format="pdf", the wrapping is really, really screwed up. If you text-align:center the p tag, you'll notice that only the last line is centered across the "entire" page. The other lines use an "invisible" margin on the right side... I've even tried using width:8.5in and all that does is shrink the content... is this a bug?
Anyway, it works with format="flashpaper" just fine.
Ben
Hanszon said on May 25, 2005 at 3:59 AM :
No screen name

Page-break-after doesn't appear to work but thanks for the suggestion. BTW cfdocumentitem type="pagebreak" does not work consistently for me - anyone else found this tag erratic?

With regard to your alignment problem - try using a 100% width div wrapper around the p tag. I've found this sorted out a few of my problems with size and alignment on tables - it may work for your paragraph but I haven't tried it.
No screen name said on May 25, 2005 at 1:04 PM :
Thanks for the info, Hanszon... I've gotten page-break to work for me, so I don't know if you have a special circumstance or what... regardless, I can't use this anymore because even if I get that right-side margin working with the width:100% idea you had, cfdocument doesn't work with @page:left and @page:right selectors. I need to have different margins on each page (basically, margins on the outside are larger than the inside margins... any idea how to do that without selectors since they don't work!!!!)
wwwmaster said on May 25, 2005 at 9:02 PM :
it would be nice if someone at MM would acknowledge the image bug, or at least explain why it happens randomly. I would give the code that results in the issue, but it appears to be happening to all of the images on my page in both PDF and Flashpaper output.
TechFreeAgent said on May 30, 2005 at 6:06 PM :
I am having the same issue with an image being zoomed on a pdf page. While researching some possible workarounds, I found that the "img" specification states that the width and height attributes, when used with percentages, will take up the available space.

So, I created a table cell with width and height set to the exact width and height of my image. Then, I played with the height and width settings of the img tag.

While not scientific, I found that a width of 65% and height of 75% came very close in many cases of rendering the image in the PDF very closely to the actual image. Don't ask why, it just seems to work until we get better answers.

So, that is my solution to at least get my current project rolling. Our images are also DataMatrix barcodes, so "exploding" images in PDF are not a good thing!
jjayzin said on Jun 1, 2005 at 9:05 PM :
I've experienced the frustrating image zoom issue as well. I played around with table cells and outside of table cells, div's all with exact pixel dimensions and percentages... I was unable to resolve the issue consistently with any of the above.

It's resulted in a few images here or there appearing to be chopped - specifically the right side and bottom.

Another frustrating issue is that every page I create seems to have a second blank page.. anyone else get that?
scott_j said on Jun 6, 2005 at 9:05 AM :
Does anybody know if cfdocument can be used to create pdfs with high resolution images, i.e CMYK JPEGS ? When I try to do this i get a red cross in the pdf where the image should be. I am currently only using the developer edition, does the full version allow CMYK JPEGS to be embedded ?

Thanks in advance.
CFwire said on Jun 8, 2005 at 1:35 PM :
When using cfdocument format pdf, how does one get the lines on their form thin? Mine all seem to be a vary of FAT lines.
ccapodilupo said on Jun 8, 2005 at 1:27 PM :
Hopefully Macromedia will implement bug 59995 (cfdocument working with conditional statements) as we were hoping to use it like we use cfcontent (wrapped inside <cfif URL.export_excel EQ "Yes"> ). However, here is some code to prevent placing your exportable content in two places:

<!--- Must save the stuff to be converted to a PDF as a variable --->
<cfsavecontent variable="content">
<Cfdump var="#get_slice#">
</cfsavecontent>

<!--- Execute this for PDF generation --->
<cfif URL.convert_to_PDF EQ "Yes">
<cfdocument format="pdf" backgroundvisible="true"> --->
<cfoutput>#content#</cfoutput>
</cfdocument>
</cfif>

<!--- Normal HTML display --->
<cfoutput>#content#</cfoutput>
Packer_Fan said on Jun 21, 2005 at 12:39 PM :
I think it would be great if there would be an attribute for "Fit on Single Page". It would solve a lot of issues, at least for me.
cf_whocares said on Jun 21, 2005 at 1:38 PM :
I am getting this error when I use cfdocument tag, does anyone know why?

The error was: null null
The error occurred on line 49

12:03:33.033 - java.lang.NoClassDefFoundError Exception

line 49 is where cfdocument tag starts.

Thanks.
cvleon said on Jun 22, 2005 at 10:49 AM :
Hanszon, I've found that cfdocumentitem type="pagebreak" doesn't work if you're using it inside an HTML table. It has to be a top-level item within the cfdocument tag, if that makes any sense.
Kevin Benore said on Jun 22, 2005 at 8:54 PM :
I have spent a great deal of time trying to tweak my way out of this report chop off problem. I have come to the conclusion that this is a CFDOCUMENT formatting bug in CF7. I have managed to figure a work around for this problem by doing the following:
1. Remove the <cfdocumentitem type="header"> and <cfdocumentitem type="footer">
2. Nex set the <cfdocument format = "PDF" pagetype="letter" margintop = "0" marginbottom = "0"> .

If you leave the header and/or footer items in and set the margins to 0 you will receive the following error:

<B>An exception occurred when performing document processing.</b>
The cause of this exception was that: coldfusion.document.DocumentInvalidHeaderFooterSizeException: Header size is currently set to margintop=0.0..

When the margins are set to "0" it seems to adjust itself out so it won't cut anything off. The only issue is when it generates the report in PDF and viewing it on screen looks a bit funky but when it prints it does not chop it off. The print function will give you the standard .5 in margin you need so it looks good.

MacroMedia definately needs to set specific margin guidelines in place with this tag as it does not take into account for the heading and page break functions. This is a great new addition to CF but a little "fine tuning" and bug fixes are certainly needed.
JimmyDoubts said on Jun 24, 2005 at 11:10 AM :
Does anybody know if the generated PDF is 508-compliant (i.e., supports Adobe's PDF tag structure).

Thanks.
JimmyDoubts said on Jun 24, 2005 at 11:46 AM :
Never mind. I just looked at some PDFs created from cfdocument and they didn't have Adobe's PDF tags. The lack of support for PDF tags is disappointing since it makes cfdocument inappropriate for PDF creation in organizations that have to be 508-compliant. The world does not need more inaccessible PDFs. Is there a plan/timetable for adding PDF tag support to cfdocument?
Krzzna said on Jun 28, 2005 at 11:43 AM :
I have createad a Visitor badging system, that shows combines a photo, bar code image and a Signature image to create a badge using CFDOCUMENT format=flashpaper. The images get stretched or they don't appear completely etc.. I have to submit my form couple of times, and it might work 1 in 30 times. If i refresh the page that has flashpaper, it takes a while to load. Any solution to the image porblems, that everyone is facing...???
No screen name said on Jul 6, 2005 at 5:48 PM :
Someone from Macromedia please followup with a work around or bug for that zooming image problem with cfdocument. Seems none of the work arounds other user's provided fixes this random problem.
acram said on Jul 7, 2005 at 5:08 AM :
In response to soonersak's question and jrunrandy's reply...

I was able to use CFChart within a CFDocument without any problems. Are you sure this is not supported? The CFChart was a .png.
EliyahuHabari said on Jul 7, 2005 at 11:37 AM :
Could someone from Macromedia please give us a status on fixing CFDOCUMENT chopping of bug? All the brilliant ideas of removing headers, footer and setting margins to 0 are defeating the purpose of this tag.
When you have to produce a document with specific margins, footers and headers you can't "play" with margins or remove required headers/footer.
Further along, when a number of documents with individual margins/headers/footers need to be combined into one master document it becomes even a bigger problem.
This functionality was a great sales pitch and a reason why I convinced my company to by CF7, now all those like me are screwed.
We need an official akgnowledgement of this bug and most importantly a fix.
Ilya Bari,
IT Director,
E-Bode Systems.
mudboy said on Jul 8, 2005 at 7:21 AM :
I have a feeling about the cfdocument image issue. Is it possible that the text is being rendered at 72DPI ('standard' web resolution) but the images are being displayed at 96DPI ('standard' screen resolution, at least on my PC)? Judging by the scale that images are being blown up (and this is affecting me on the project that I am working on currently), that seems to make sense to me. Perhaps it might be worthwhile to add a resolution attribute to the cfdocument tag? That way, I could also generate print-ready proofs at 300DPI or higher, which would be REALLY nice to be able to do.

Elya Bari, I was having the same problem with margins but found that by using CFDOCUMENTSECTION and putting the margins there rather than in the parent CFDOCUMENT tag, I was able to specify page-specific margins. In my case, I am fortunate in that each header contains a single line from a query result set, so I can count the records returned from that query, do a simple line-height calculation (line height is set in my CSS file), and pass in a dynamic margintop and marginbottom value.

Still, the bugs in CFDOCUMENT, the functionality that showed the most promise in MX7 (at least to me), range from annoying to maddening. Perhaps the worst part is that it isn't one or two bugs in a single aspect of CFDOCUMENT, it's the myriad bugs (or unexpected behaviors) that appear in almost every aspect of CFDOCUMENT which is the most frustrating thing to me. I can afford to buy either MX7 server OR ActivePDF, not both, so if Macromedia wants more money from me in the future, they had better fix this functionality. Hopefully the Adobe buyout will bring some really solid PDF generation capabilities to CF and we'll be able to put all of these issues behind us.
seancoyne said on Jul 13, 2005 at 5:29 AM :
http://www.macromedia.com/cfusion/knowledgebase/index.cfm?id=fd71533&pss=rss_coldfusion_fd71533

Quote:
"59868 cfdocument tag now scales images properly 3"
Tom Nunamaker said on Jul 18, 2005 at 4:58 PM :
We were having the image sizing problems with HF2 and saw the note HF3 fixed that. I installed HF3 and ran a PDF page. It did display the images correctly, but also got JRUN stuck at 99% CPU utlization. I had to reboot the server to "fix" it. Any idea why that might be occurring?
Office_Space said on Jul 21, 2005 at 2:50 PM :
Regarding bug 59995 (cfdocument working with conditional statements), I found that by adding the following code just above the </cfdoument> tag, the page would display in html format:

<CFIF #OutputToPDF# is 0><!--- Allows for HTML version of report to display --->
<cfabort>
</cfif>

</cfdocumentsection>
</cfdocument>

</body>
</html>
No screen name said on Jul 22, 2005 at 5:18 PM :
I have a table displayed in CFdoucment and it displays fine. However, when I try to change the color of the border, I cannot get it to work. It always stays as grey. Any suggestions or ideas would be helpful
Office_Space said on Jul 22, 2005 at 5:46 PM :
Try this: <table border=0 STYLE="border: 2px solid #000080">
No screen name said on Jul 26, 2005 at 11:16 AM :
cfdocument is creating pdf with what appears to me a completely arbitrary page break. Has anyone else seen this behavior? Are there any "rules" that people have found that need to be applied to html in order to make it work.

For instance, the background attribute doesn't work consistantly...use css class instead.
No screen name said on Jul 26, 2005 at 12:32 PM :
update to above page break issue:

It appears that if you are using tables in your html and that html document extends beyond the boundaries of the page cfdocument chooses to create a page break before the last table that fits completely on a page. This can cause a page break at a completely inappropriate spot if you aren't careful.
dweeres said on Jul 28, 2005 at 10:05 AM :
not sure if this is the right place fo this - but I am not getting any response on the forums.

The images do not show up in the <cfdocument>

<cfdocument format="pdf">
<html><body>
<img src="/images/reportlogo.jpg">
<img src="/images/reportlogo1.jpeg">
<img src="/images/reportlogo1.gif">
</body></html>
</cfdocument>

But they show up when displayed without the <cfdocument> (html)

Any suggestions would be VERY helpful

Thanks
ddborowitz said on Jul 28, 2005 at 2:27 PM :
I figured out a hack for per-page headers/footers. This all goes in your cfdocumentitem:

<style type="text/css">
.NotPage#cfdocument.currentpagenumber# {
display: none;
}

.Page1 {
display: none;
}

span.Page#cfdocument.currentpagenumber# {
display: inline;
}

/* div.Page#cfdocument.currentpagenumber# {
display: block;
} */
</style>

<span class="Page1">Page-1-only content goes here</span>
<span class="NotPage1">Non-page-1 content goes here</span>

It shouldn't be tough to modify this for arbitrary page numbers. Of course, it is far less flexible than _actual_ dynamic content, but for my purposes at least, it works fine.
cynicat said on Aug 8, 2005 at 1:09 PM :
It seems that after much searching and fumbling the only way that I can consistently ensure that the first line is not cropped off in a .pdf is to use 70% scaling and to include the below which just puts a dummy header on the page and I don't care if it gets cropped.

<cfdocumentitem type = "header">&nbsp;</cfdocumentitem>
MadamQueen said on Aug 10, 2005 at 5:28 PM :
"no matter what I try, I get a box with a red "x" on it instead of the image. "

I went through the same thing and finally resolved the problem by using an absolute URL with the internal ip address: example:

<img src="http://www.127.0.0.1/images/imagename.jpg" />

(substitute your internal IP address for the 127.0.0.1 in my example. It did not work locally, but worked on the remote CF server when the page was uploaded.
fschneider said on Aug 10, 2005 at 5:40 PM :
MadamQueen, thanks that seems to do the trick at least for the moment, but it doesn't seem right to have to do that. Do you know if this is a reported bug and/or Macromedia has a patch to fix it? What if the server ip changes, I hate to hard code it in there. Is there a way to query to get the ip address currently in use?
MadamQueen said on Aug 10, 2005 at 5:57 PM :
I agree that it doesn't seem right and I have searched high and low but haven't seen it reported as a bug or included in the documentation on using <cfdocument>

I'm no MM expert but in my opinion it should be considered a bug and fixed on their next upgrade.
t.sarmis said on Aug 18, 2005 at 3:19 AM :
You can't use the cfdocument.currentpagenumber and cfdocument.totalpagenumber scopes outside the cfdocumentitem tags.
Is this a bug or is designed such as?
Is there a trick to use it inside th cfdocument body? I need the evaluation of page number to display different data in pages body.
Could someone reply??
iots190 said on Aug 24, 2005 at 2:16 PM :
Does anyone know if cfdocument can use the style sheets when included using <link>? When I run the page as HTML, it uses my style sheets, but when I try it with cfdocument, its just plain. Here is the code that is between the cfdocument tags. Thanks! :)

<!-- Start Employee Site headwhite.txt -->

<script language="javascript" src="/ssi/apps/browserdetect.js"></script>
<script language="javascript" src="/ssi/apps/internal_cssdefinition.js"></script>

<noscript>
<link rel="stylesheet" type="text/css" href="\css\apps\app.css" />
</noscript>
<!-- End Employee Site headwhite.txt -->

<table width="50%" cellspacing="0" cellpadding="0" class="separatedSM">
<tr class="HeaderRow">
<td>Name</td>
<td>Role</td>
</tr>
<tr class="RowOne">
<td>Bill</td>
<td>Lead</td>
</tr>
<tr class="RowTwo">
<td>Susan</td>
<td>Principal Writer</td>
</tr>
</table>
asoldner said on Aug 26, 2005 at 12:29 PM :
iots190

You have to put the <link> tag to your css stylesheet inside the <cfdocument> tag.
Erewan said on Sep 1, 2005 at 8:23 AM :
When using the cfdocument to generate a pdf from another webpage, it breaks up the page into pages on the PDF document. Is there a way to make it shrink everything down to the size of paper i have specified:
<cfdocument format="pdf"
pagetype="legal">
laser_razor said on Sep 2, 2005 at 10:30 AM :
I'm not sure if this will help anyone... I'm not even sure if it's good form... However, I managed to include a style sheet in the following way:

<cffile action="read" file="c:/my_app/main.css" variable="myStyle">

<cfdocument format="pdf" filename="..." overwrite="yes"... pagetype="letter">

<html>
<head>
<title></title>
</head>
<body>

<cfdocumentsection>

<cfdocumentitem type="header">...</cfdocumentitem>

<style><cfoutput>#myStyle#</cfoutput></style>

<p class="larger_headings"><cfoutput>My Report</cfoutput></p><br>

<p class="content"><cfoutput>My content</cfoutput></p>

<cfdocumentitem type="footer">...</cfdocumentitem>

</cfdocumentsection>

</body>
</html>
</cfdocument>
Coreth said on Sep 19, 2005 at 10:02 AM :
Will CFDocument listen to the media attribute of the link tag, when including CSS? If yes, does it respond as screen or print? or something else?
MarkMetcalf said on Sep 26, 2005 at 11:13 AM :
I applied HotFix 3 to ColdFusionMX7 and I was still having the image problem. The work around I found that seems to be working 100% of the time is to, create the table cell with the same Height and Width of the image and instead of using the IMG tag, I set the table cells background to my image.

<tr>
<td width="490" height="118" background="Images/my_image.gif">
</td>
</tr>

Keep in mind, backgroundvisible attribute must be set to 'yes'.
ASandstrom said on Oct 17, 2005 at 11:09 AM :
There is a tech note:
"Flash Player 8 issue with cfdocument and cfreport"
at
http://www.macromedia.com/cfusion/knowledgebase/index.cfm?id=a8a77279
eblackey101 said on Oct 20, 2005 at 2:50 PM :
It appears that images are cached when using the cfdocument tag. This is great until you have an image that needs to change everytime the document is rendered. It seems like there needs to be an attribute called cacheimages or something. To get around this, I am adding ?foo=#DateFormat(now(),'yyyymmddhhmmss')# to the end of my image src.
mistergin said on Nov 13, 2005 at 1:57 PM :
Acting on the above tip to try 65/75% for the image, I noticed that even at 85 it was running close to the border so I tried 100% for the height and width and BOOM, it works!

So if you're having image scaling issues, try setting the td cell width height to the image size and set the height/width of the image to 100%.
asimkins said on Jan 28, 2006 at 1:05 PM :
Regarding missing images in generated pdf files: I've seen many workarounds suggested but I found a really simple solution. Use the file: protocol in the img src if the file is local. I.e. src=file:///c:/somedir/somefile.gif. Note that 3 slashes are necessary after file:. Hope this helps someone.
andrewteg said on Apr 3, 2006 at 12:51 PM :
Another thing to remember is that CFDOCUMENT does not read authenticated sessions so if you are doing a PDF report in a password protected area of your site it's best to put the imags in a non-password protected folder.
No screen name said on Apr 25, 2006 at 3:55 PM :
Coreth:

cfdocument will use a stylesheet that is specified for print media.

ex/ <link rel="stylesheet" type="text/css" href="myPrintStyle.css" media="print" />
No screen name said on Jun 14, 2006 at 5:11 AM :
Solved: margen issue ...
Try to define the style element body in a css file with the following params: margin 0px; padding: 0px; ... The "padding 0px;" is the most importend param ... hope this helps ... pirre
No screen name said on Jun 21, 2006 at 9:09 AM :
I have noticed a bit of funkyness with background images. If i were to use an image 1px tall and repeat it among the y axis, it seemed to enlarge it in size by about 10 times.

I am calling the background image on a div by css using background-image: url(); Without the use of the background-repeat: repeat-y; it would not display the image at all (although it would display it in a html file).

If I re-made the background image to something very large, it would work correctly. So instead of a 1px image that would repeat 1000 times on the y axis, I made it 1000px tall and it seemed to fix the problem.

Hope that helps somebody.
bradwood.com said on Oct 6, 2006 at 1:15 PM :
Look at: http://www.bradwood.com/cfdocumenttest/

We are experiencing a handful of anomalies with the cfdocument tag when generating PDF's.

*One* of which is that text surrounded by <u> </u> exhibits strange behavior such as extra spaces (which are underlined) magically appearing before and or after the text.

Example <u>test</u> would have extra "______" at the end of it-- sometimes all the way to the end of the page.

I have run 4 tests.

a) PDF Generation using cfdocument on a Windows server using CF 7.0.2
b) FlashPaper Generation using cfdocument on a Windows server using CF 7.0.2
c) PDF Generation using cfdocument on a Liniux server using CF 7.0.2
d) FlashPaper Generation using cfdocument on a Liniux server using CF 7.0.2

a) Works! 51 KB File
b) Works! 57 KB File
c) Broken! 2 KB File!!!!!!
d) Works! 56 KB File

The problem does in fact seem to be limited to PDF files on Linux servers.
And why the heck is the file so small???

All of these test files are available for you to view at www.bradwood.com/cfdocumenttest. Please check them out to prove I'm not completely insane.

Thanks.

~Brad
cvleon said on Oct 10, 2006 at 7:43 AM :
Brad, I've had the same problem with PDFs generated on Linux. I've had to
strip all of the HTML tags out of my content before putting it into a
CFDocument PDF. This is a serious limitation of CFDocument, and I
sincerely hope it can be fixed with a patch!
mackaboogie said on Oct 22, 2006 at 6:44 PM :
Basic Best Practices (or more like, best luck for me):

-If creating new images set the dpi to 96 not 72.
-Use inline css
-Use css to insert background images (ie. background: white url(filename.jpg) no-repeat fixed;
- CSS, set font-size using pt not px
-Include any calls to imported files (css) within the cfdocument region
- define as many cfdocument attributes as are applicable (format, pagetype, margin, backgrounvisible, fontembed)
- for tables, define widths using percentages instead of absolutes
- Make sure to install non-system fonts on the server that will be rendering the PDF
- Only install true type fonts (using CF admin), some Type 1 fonts will ruin the formatting of the \\CFusionMX7ib\neo-document.xml file rendering the font manager in the CF admin to break.
Chemical_One said on Dec 20, 2006 at 4:40 AM :
Hi all,

for those looking for a quick fix to embed repeating images, or just images. One solution that found itself being very efficient was using the CFreport tag. You can also use the coldfusion report builder if you need to do this in the most easyest manner possible. You can then reuse it when needed and overwrite the image file used with cffile to update the report/document/whateveryouredoing.file
: )
tgm2002 said on Jan 27, 2007 at 8:38 AM :
style="border-bottom: 1px dotted #000000;" doesn't work - no border is produced...

style="border-bottom: 1px dashed #000000;" or style="border-bottom: 1px solid #000000;" both work fine.
RBC said on Mar 2, 2007 at 9:12 AM :
It would be nice if the docs said something about the expected extention for flashpaper. Somewhere it should just say "use swf for the extention for flash paper' (dummy)
RBC said on Mar 2, 2007 at 9:55 AM :
Also, the documents make no mention of page size minimums, but there is one--for instance the page width must be 2 inches (which is a problem for me, because I am trying to make individual labels for printing on a label printer)
mike.bacso said on Apr 9, 2007 at 8:01 AM :
Not sure if this has been mentioned before, (I did not read through everyone's comments) but I have found that the extra blank page inserted at the end of a cfdocument may be due to a <body> tag padding. I have eliminated it by adding body { padding: 0px; margin: 0px; } to the cfdocument's css.
mike.bacso said on Apr 10, 2007 at 5:29 AM :
In addition to my previous comment... the margin: 0, padding: 0 fixed it on multiple pages, but i was still getting an extra blank page on single page documents. Adding body, html { height: auto; } to the css seems to have fixed that however.
The other Jack said on Apr 10, 2007 at 9:27 AM :
Text clipping/chop off problem: Until there is a better fix, I have found that by
setting scale="95" in the cfdocument tag solves the problem of text being
chopped off at the tops and bottoms of the pages.
No screen name said on Sep 11, 2007 at 10:53 AM :
I have a problem with <CFDOCUMENT> paginating and honoring the formatting at the same time in both PDF and FlashPaper. I removed my <HTML> and <BODY> tags because I read somewhere that they mess up <CFDOCUMENT>.

If I run my report one person at a time, I can ignore pagination and the report looks fine. If the report runs to multiple pages, there is no predicting where the page will break, and there are no page numbers, but that’s fine.

However, when I put virtually the same code inside a <CFOUTPUT> (<CFDOCUMENT> is outside the <CFOUTPUT> because there is report data before that output) in order to run reports for multiple people, I start having problems.

Originally I attempted to use <cfdocumentitem type = "pagebreak"/> right before </CFOUTPUT> to get pagination, but the result was a blank page or two at the beginning and no page break between people.

My second option was to use <CFDOCUMENTSECTION> around the <CFOUTPUT> (I actually tried putting it in various places with no success.) I discovered that the pagination worked fine but I lost data formatting.

1. The font was changed to a larger size and possibly a different face.
2. Those rows that were formatted as:
<table>
<tr>
<table>
<tr>
<td>Question1</td>
<td>Answer1</td>
<td>Question2</td>
<td>Answer2</td>
</tr>
</table>
</tr>
</table>

were changed to an appearance of

<table>
<tr>
<table>
<tr>
<td>Question1</td>
<td>Answer1</td>
</tr>
<tr>
<td>Question2</td>
<td>Answer2</td>
</tr>
</table>
</tr>
</table>

There are some that were actually setup that way, and there were some set up with a single <TD>. Those tables with one or two <TD> elements remained that way, but the ones with four became two <TR> with two <TD>

3. An added factor is that the <TD> widths are table driven so as to be able to adjust how closely a question (first or third column) is followed by its answer (second or fourth column).

The bugs appear to be:
1. <cfdocumentitem type = "pagebreak"/> not working inside a <CFOUTPUT>.
2. <CFDOCUMENTSECTION> changing the font and various table elements of the report.
No screen name said on Sep 21, 2007 at 6:21 AM :
for wrong-sized IMG in cfdocument (which also affected cfcharts-pngs ..)

check out latest cfdocument-hotfix:
http://kb.adobe.com/selfservice/viewContent.do?externalId=kb402093&sliceId=1

or cum-hotfix after that.

this seem to fix badly-sized IMGs

Great News (after a couple of years -or so- pdf-printing can be used without that "ups.. sorry - sometimes images are not rendered correctly - try again")

Thanks for that anyways
sekora said on Nov 13, 2007 at 8:36 AM :
I ran into the issue with image sizes being blown up. I found a blog entry that suggested using in vs px for the image width and adding it to the style attribute vs the width attribute of the img tag. It seemed to work.

Example:
<img style="width: 2in;" src="/images/citynet_csr_header.gif" border="0"/>
Jamie_22 said on Apr 24, 2008 at 7:25 AM :
This is how I eliminate the invisible margin on the right hand side of PDF documents:

<cfdocument format="pdf" marginright="0" marginleft="0" unit="cm">
<cfoutput>
<html>
<body style="position: relative; left: 60px;">
content goes here
</body>
</html>
</cfoutput>
</cfdocument>

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/7/htmldocs/00000236.htm