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 ?
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.
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.
© 2022 - 2024 — McMap. All rights reserved.