• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1874
  • Last Modified:

CFPDF add image (logo) to PDF document

I have a PDf form in which I use CFPDF to populate data (text fields); I also need to be able to swap out a logo on the pdf form (e.g., jpg, or png).  How can I change an image in a pdf file using coldfusion tools.
0
sjterrell
Asked:
sjterrell
  • 7
  • 5
1 Solution
 
_agx_Commented:
Just a thought ... have you tried base64 encoding the image blob as suggested here?


ie
<cfimage action="read" source="myImage.jpg" name="myImage">
<cfset myImage = ToBase64(myImage)>

<cfpdfform source="myPDF.pdf" action="populate">
     ....
        <cfpdfformparam name="ImageField1" value="#myImage#">
    ....
</cfpdfform>

0
 
sjterrellAuthor Commented:
Thanks, we have tried the following:

*** CONVERT IMAGE TO BASE64
<cfimage action="read" source="Images/webtrax.jpg" name="myImage">
<cfset myImage = ToBase64(myImage)>


 <cfpdfform source="d:\websites\PECRM\html\pdfsource\CRM_01_ConvertingLeads2Sales.pdf"  overwrite="yes" destination="d:\websites\PECRM\html\pdfsource\prtCRM_01_ConvertingLeads2Sales.pdf" action="populate">
   
        <cfpdfformparam name="Back Builder Address" value="Zodiac Pool Systems2620 Commerce Way">    
        <cfpdfformparam name="Back Logo" value="">    
        <cfpdfformparam name="Front Logo" value="#myImage#" >     
        <cfpdfformparam name="Paragraph ##1" value="#par2#">    
        <cfpdfformparam name="Paragraph ##2" value="#par1#">    
        <cfpdfformparam name="Paragraph ##3" value="#par2#">    
        <cfpdfformparam name="Return Address" value="">    
        <cfpdfformparam name="Subhead ##1" value="Gail Row 1 Title #par1#">    
        <cfpdfformparam name="Subhead ##2" value="Gail Row 2 Title #par1#">    
        <cfpdfformparam name="Subhead ##3" value="Gail Row 3 Title #par1#">    
       
</cfpdfform>

The result is that the image on the rendered PDF is garbled text; no image.

0
 
_agx_Commented:
Can you attach a sample of your form?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
sjterrellAuthor Commented:
in the attached form, the boxes id as logo's are where I would like to put an image.
CRM-01-ConvertingLeads2Sales.pdf
0
 
_agx_Commented:
Looks like those are "text" fields. That's why result is just garbled text.  They need to be some sort of image field.  You'd have to ask an Acrobat expert on how to create an image field.
0
 
_agx_Commented:
Or you could skip the image field and add the image as an opaque watermark. The end result should be the same.
0
 
sjterrellAuthor Commented:
if we use the watermark, can you set the location?
0
 
_agx_Commented:
Yeah. cfpdf let's you set the watermark position (x,y coordinates from the top lefter corner)

<cfpdf
    position = "100,100"
    ...
 />
0
 
sjterrellAuthor Commented:
After much research; it is apparent that watermark is not a valid option since it only allows you to have one.  I solved the solution by using some java methods.
0
 
sjterrellAuthor Commented:
I've requested that this question be deleted for the following reason:

solved myself
0
 
_agx_Commented:
No. It allows multiple watermarks just fine

<cfdocument format="pdf" name="myPdf">
	<h1>Header 1</h1>
	<cfdocumentitem type="pagebreak"/>
	<h1>Header 2</h1>
</cfdocument>

<cfpdf action = "addwatermark"
	source ="myPdf"
	image="c:\path\image1.png"
	pages="1"
	name="myPdf"
	overwrite="true"	
	position="50,50" />

<cfpdf action = "addwatermark"
	source ="myPdf"
	image="c:\path\image2.png"
	pages="1"
	destination="c:\path\twoWatermarks.pdf"
	overwrite="true"	
	position="300,100" />

Open in new window

0
 
_agx_Commented:
I recommend #3. The asker said "watermark is not a valid option since it only allows you to have one", which isn't correct. The example in http:#a37116609 demonstrates that you can add multiple watermarks to a single pdf.

If the asker still wants to accept their own answer instead (using java instead) that's okay. But they should post the final code for the archives.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 7
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now