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 ?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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:
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
inorcmunits 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)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.