Skip to main content
March 25, 2008
Question

Images and text in a pdf

  • March 25, 2008
  • 8 replies
  • 686 views
Hello everyone,

I have a problem I have not been able to solve. I have a client that needs to dynamically generate a page based on a query that will include up to 4 records with images. That part works just fine. The problem is with the pdf that needs to be generated in the next step. the pdf needs to have a hi-res background and the records-with hi-res images need to be layed over that background. I've tried cfdocument and cfpdf without any luck. Are the pdf functions in CF appropriate at all for this task? Can anyone suggest a third party utility if not? Thanks!
This topic has been closed for replies.

8 replies

Participating Frequently
March 25, 2008
As I know there is a "Background" feature in DDX. I would expect having same functionality.
March 25, 2008
Thanks for the reply Oguz. The background I am using is 8.5x11. Do you think DDX might work for this?
Participating Frequently
March 25, 2008
I have tried following code to generate a background image in CF8 and it worked without any problem.

<cfdocument format="PDF" pagetype="letter" margintop="0" marginbottom="0" marginright="0" marginleft="0" orientation="landscape" backgroundvisible="yes">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>cfDocument Test</title>
<style type="text/css">
<!--
body {
background-image: url(flashflexair.jpg);
margin:0;
padding:2em;
}
-->
</style></head>

<body>
Unicode ğĞüÜıİşŞöÖçÇ
</body>
</html>
</cfdocument>


"flashflexair.jpg" is an image with the size of 3200 px.

Yes the load was a bit longer than normal process but I think this is a general issue with other server side solutions.
March 25, 2008
I actually went through those tutorials last night, but didn't see a way to do what I need to do. Long story short, I need the following to output on a pdf with a high-res background image;

<meta http-equiv="Content-type" content="text/html; charset=utf-8">

<!---Insert a test image name if field is undefined--->
<cfdocument format="pdf" orientation="landscape" saveAsName="test.pdf">
<html>
<head>
</head>
<cfoutput>
<body>
<!---Create the pdf--->
<p>Memo: #memo#</p>
<table align="left">
<tr>
<td><p>#form.name1#</p><br/></td>
<td><p>#form.name2#</p><br/></td>
</tr>
<tr>
<td><p><img src="#image1#" ></p><br/></td>
<td><p><img src="#image2#" ></p><br/></td>
</tr>
<tr>
<td><p>#content1#</p><br/></td>
<td><p>#content2#</p><br/></td>
</tr>
<tr>
<td><p>#form.name3#</p><br/></td>
<td><p>#form.name4#</p><br/></td>
</tr>
<tr>
<td><p><img src="#image3#"></p><br/></td>
<td><p><img src="#image4#"></p><br/></td>
</tr>
<tr>
<td><p>#content3#</p></td>
<td><p>#content4#</p></td>
</tr>
</table>
</body>
</cfoutput>
</cfdocument>
Participating Frequently
March 25, 2008
First I can suggest to check the demos in Ray Camden's blog for PDF usage.

http://www.coldfusionjedi.com/index.cfm/2007/7/9/ColdFusion-8-Working-with-PDFs-Part-1

You can find some related post below.

Second, please share some code that we can see what would be the part that may need optimization.
March 25, 2008
Thanks for the reply! We are using CF 8. I tried setting the backgound of the page with a hi-res image to create a background and generate the page from that, but it took about 30 seconds to load (too long for the client). I would not be opposed to using a pdf and cfform tag, as long as I can remove the white text areas (so they show like labels) and I can insert the images from the query. Or just writing to the pdf that already has a background would work too. just need to get it working.
Participating Frequently
March 25, 2008
Sorry for second post. There is a lag on Adobe servers and needed to hit twice.
Participating Frequently
March 25, 2008
If you have CF8 these request can be apply with some little tricks. But if you are working with old CF version you can try to check out Adobe Exchange or cftagstore.com for commercial solutions.

If you can share some of your problems we can trey to figure out together.