How to embed an image in a PDF using cfpdfform
Asked Answered
T

2

6

I'm dynamically generating a PDF with a few variables but also need to be able to embed an image on the PDF. Anyone have any experience doing this using ?

Tillotson answered 21/5, 2010 at 18:1 Comment(1)
Are you using cfpdf or cfpdfform?Annetteannex
A
1

You use a regular HTML image tag.

However for good print quality images you need to use an image that has larger dimensions than you might use in the document.

For example:

<img src="/path/to/my_picture.1280x800.jpg" style="width:320px;height:200px;" />

So in that example the width/height of the image file is at 4x what is displayed (obviously the source image need to have that quality to start with; resizing a smaller image bigger wont do much).

Being PDF, you've got conventional units too, so you can use CSS's in or cm units to set sizes relative to the paper size, but you'll still have the same issue of needing a larger input file. (This example is 160 px:in resolution)

<img src="/path/to/my_picture.1280x800.jpg" style="width:8in;height:5in;" />


Something else to be aware of - since the images are embedded (uncompressed?) in the PDF this can significantly increase filesizes, so you may need to experiment to work out the best trade-off between filesize and image quality.

Adamis answered 21/5, 2010 at 18:25 Comment(1)
Wrong answer. JGrimm is asking about cfpdfform tag.Arctic
T
1

Direct html tag did not work. But I figured out a solution which did.

<cfset photoLink = "D:\........\example.jpg"> 
<cffile action="readbinary" file="#photoLink#" variable="binAgentPhotoFile"> 
<cfinvokeargument name="photoFile" value="#toBase64(binAgentPhotoFile)#"/>

Argument is then passed to the schema.

Tillotson answered 24/5, 2010 at 16:39 Comment(2)
JGrimm can you tell us what kind of field do you use to embeed base64. I have Acrobat XI pro and i can see (texfields, buttons, radios) as fillable elements.. but nothing seems to hold as an image container. Can you share with us?Arctic
I have the same problem as Oscar. Everything works in my form except that I cannot find an image field. I'm now trying to make a HTML form element for a base64 imageJemine

© 2022 - 2024 — McMap. All rights reserved.