Orange is my favorite color

SCCA Tech FormFour years ago I detailed how to force image sizes in CFDocument using CSS with dimensions in inches. That’s worked well for a very long time but recently we introduced a new PDF report that uses a background image of a form with data overlaid on top.

In my development environment, this report printed as expected but we received reports that in production, there was a blank page inserted between each printed page. I couldn’t replicate it locally but I did see it on our live servers. Same code and same versions of ColdFusion (8.0.1 with chf3) but different results. It wasn’t until I put the two Acrobat windows on top of each other and flipped between them that I could see the entire page was being scaled. In the case of the production server, it was being scaled larger so that it overran the margins and triggered a second, blank page. Here’s the code:

<cfdocument pagetype="letter"

See in this image how the margin has disappeared when CFDocument scaled the page:

Disappearing right margin

With some trial and error I was able to determine that it was specifically the two fields at the top right of the report, Car Class and Car Number, that were determining whether or not the page was scaled. By increasing the width of the absolutely-positioned <div> tags used to display that data, I forced CFDocument to believe the content was wide enough and prevent scaling. In short, I changed the code like so:

<div class="data" style="top: 0.31in;
                  left: 6.9in;
                  width: 0.85in;">#vchVehicleNumber#</div>
<div class="data" style="top: 0.32in;
                  left: 7.07in;
                  width: 1in;">#vchVehicleNumber#</div>

You can compare how this impacted the rendering in this side-by-side image with the div size made visible with a background color:

Compare Right Margins

Left to right the right margins are captured from: Production server with 1in width and no blank pages, production server with 0.85in width and blank pages, development server with 0.85in width and no blank pages.

No rhyme or reason to this that I’m aware of but another nail in the coffin for CFDocument. The underlying icebrowser library may have been the best thing available when CFMX was released but I agree with Jason Delmore that CFDocument needs an overhaul!

1 Comment

  1. September and October updates » Pukka Software, Makers of said:

    on October 7, 2010 at 8:06 am

    [...] pages between each form and wasting paper. That’s not very Californian of us! Tech details available here for the morbidly [...]

{ RSS feed for comments on this post}