Link to home
Start Free TrialLog in
Avatar of cj_ervin
cj_ervin

asked on

PDF Creation Different on Operating Systems

I have a page in Coldfusion where I dynamically create a PDF with cfdocument and CSS. My development machine is a Windows 7 64-bit with ColdFusion 8 development version. Then I used cfdocument to create a full page landscape document (used as a certificate) that is w-11 X h-8.5 inches. I used CSS to put in text pulled from a database so the the PDFs are dynamic.

But when I put it up onto the server is does not work. It shrinks the background, all the dynamic text is in the wrong place or not showing up and then there is an extra 1 to 2 inches around the entire "certificate". The server is a Windows Server 2003 with ColdFusion 8. I am not sure what would make the difference. It is very frustrating that it works flawlessly on my development machine, but will not work on the server.

Any ideas what I can do to fix it or what in the world would make the difference?
Avatar of s8web
s8web

Can we take a peek at your code?
Avatar of cj_ervin

ASKER

Here is the Code. Where is says something goes here, it is a Query Variable that goes there and that part works fine, it just is lined up in the wrong place on the server because of the shrinkage of the background and the extra 1-2 inches of extra white space around the entire certificate

 
<!--- pageheight="8.5"
		pagewidth="11" --->
	
	<cfoutput>
	<cfdocument
			name="certificate"
			format="PDF"
			pagetype="letter"
			orientation = "landscape"
			margintop="0"
			marginbottom="0"
			marginright="0"
			marginleft="0"
			unit="in"
			fontembed="true"
			backgroundvisible="true"
			localurl="true">
	
			<cfoutput>
	
				
				<html>
				<head>
					<style type="text/css">
	
						body {
							background-image: url( "Certificate-BG.jpg" ) ;
							background-position: center center ;
							background-repeat: no-repeat ;
							font-family: arial ;
							margin: 0px 0px 0px 0px ;
							padding: 0px 0px 0px 0px ;
							background-color:white;
							}
	
						div##certpic,
						div##employeename,
						div##coursename,
						div##coursedate,
						div##signaturefile,
						div##trainername {
							position: absolute ;
							text-align: left ;
							}
	
						div##type,
						div##employeename,
						div##coursedate {
							font-size: 26px ;
							font-weight: bold ;
							text-align: center ;
							}
	
						div##datetext{
							font-size: 14px ;
							}
	
						div##certpic{
							left: 50px ;
							top: 200px ;
							width: 200px ;
							}
						div##employeename {
							left: 350px;
							top: 245px ;
							width: 575px ;
							}
						div##coursename {
							left: 350px;
							top: 285px ;
							width: 575px ;
							height: 65px ;
							font-size: 26px ;
							font-family:"Times New Roman", Times, serif;
							text-align: center ;
							font-style: italic;
							}
							
						div##coursedate {
							left: 350px;
							top: 355px ;
							width: 575px ;
							}
							
						div##signaturefile {
							left: 600px ;
							top: 405px ;
							width: 265px ;
							text-align: center ;
							}
							
						div##trainername {
							font-size: 12px ;
							text-align: center ;
							left: 617px ;
							top: 475px ;
							width: 230px ;
							}
					</style>
				</head>
				<body>
					<div id="certpic">
						<img src="Employee_Photo_Goes_Here.JPG" width="250" height="250" alt="" />
					</div>
					<div id="employeename">
						Employee Name Goes Here - #qQueryName.EmployeeName#
					</div>
					<div id="coursename">
						Course Title Goes Here - #qQueryName.CourseTitle#
					</div>
					<div id="coursedate">
						Date Course Was Taken Goes Here - Formatted December 31, 2011
					</div>
					<div id="signaturefile">
						<img src="Images/Signatures/Signature_Image_Goes_Here.jpg" width="150" height="50" alt="" />
					</div>
					<div id="trainername">
						Course Trainers Name Goes Here  - #qQueryName.TrainerName#
					</div>
				</body>
				</html>
	
			</cfoutput>
		</cfdocument>
	<cfoutput>

	
	
	<!--- Set the content and reset the output buffer. --->
	<cfcontent type="text/html" />

	<cffile action="write" file="\Certificates\Certificate-#DateFormat(Now(), 'mm-dd-yyyy')#-#TimeFormat(Now(), 'hh-mm-ss-tt')#.pdf" output="#certificate#">

Open in new window


I have added 2 pdfs (with the picture covered over and names replaced with text that should be there. The first one is the correct one and works perfect on my machine, the second one is from the server. Also you will see that the image and text is smaller on the messed up one from the server.
Should-LOOK-LIKE-12-30-2011-07-3.pdf
Messed-Up-One-On-Server-12-30-20.pdf
I know it seems like you shouldn't, but in this case you need a valid DocType. I would go with an html4 DocType. That doesn't explain why it's different in production vs. local, but I've seen stranger. If you're running a slightly different version on production vs. testing...

Give it a shot and see what happens.
Also, it might be a bit annoying at this point but you might want to reset the css before you define all your css. A quick and dirty way (see snippet). You will most likely have to tweak some things, but if the docs look consistently weird, we can call it progress :)

I suspect that your dev environment is using a slightly different parser than your production environment.

Is your Server 2003 the 64bit or 32bit flavor? If it's 32bit, my theory is supported.
<style type="text/css">
*{margin:0;padding:0}
img, fieldset, a{border:none;outline:none}

/*The rest*/

Open in new window

What is the exact size of the background image (certificate document)?

I tried these 3 with no avail:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

And even tried this one.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


I also added the css reset to the page.

But none of the above is working.


The Background Document Size is: Width - 14.583in and Height - 11.264in and Resolution is 72 pixel/inch  (Pixel dimensions are 1050x811 px)

I just got a reply back from the server admistrator for the server my client is using and this is his answer: 32 bit on that win sbs 2003. So it is a 32 bit server and my development box is 64 bit.
ASKER CERTIFIED SOLUTION
Avatar of SidFishes
SidFishes
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It looks like The First Hot Fix might be the issue:

70239       CFDocument in ColdFusion 8 was producing documents that were smaller than same document produced in ColdFusion MX 7. Note: This same hot fix is part of chf8000001. No problem is caused by this duplication.

I will try to update or get the system admin guy to do the update. I will let you know if that takes care of the issue, Might not be for a few days with the holidays. I hope that solves it.
It fixed the problem. Thanks for the help and great advice. It worked like a charm.

Thanks,
CJ