2

I am using the pdflib library to generate the pdf for my online booking system. I'm new with pdflib library. I have tried a lot but not getting how I can set image into the ellipse with pdflib.

I'm using

$pdflib->ellipse ( 10 , 30, x_radius, y_radius);

It just draws the ellipse. How can I set image inside it ?

2
  • You can't embed an image inside the ellipse directly, but you can use basic trig/geometry to calculate a bounding box whose corners lie on top of the elipse, and use those as the coordinates to embed your image. Or, you could embed an image and define an elliptical mask on it so only an ellipse-shaped part is visible.
    – Marc B
    Mar 15, 2012 at 17:15
  • Thanks for quick reply... I have almost 5-8 images per page. And doing in that manner would not be advisable
    – Smit
    Mar 15, 2012 at 17:18

1 Answer 1

3

You can use clip method provided by PDFLib, like:

$pdflib->ellipse ( 10 , 30, x_radius, y_radius);
$pdflib->clip ();
$pdflib->fit_image($image, $x, $y, $options);

This will cut the image in the ellipse shape and also that image will fit into that.

Thanks!

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.