Mathias Nilsson wrote:
> Hi,
> 
> I'm using the sample code from the iText in action to round my image.
> 
> Image img1 = Image.getInstance("d:\\7311310034092.jpg");
> float w = MeasurementUtil.millimetersToPostscriptPoints(70.8f);
> float h = MeasurementUtil.millimetersToPostscriptPoints(90f);
> img1.scaleToFit( w, h);
> PdfTemplate tp1 = cb.createTemplate(w, h);
> img1.setAbsolutePosition(0, 0);
> tp1.roundRectangle(0, 0, w, h, 10f);
> tp1.clip();
> tp1.newPath();
> tp1.addImage(img1);
> cb.addTemplate(tp1, 300, 300);

roundRectangle is used as a clipping path; it's not a line to "stroke".
Everything outside the clipping path will be... clipped.
That's the general idea.

Add:

cb.roundRectangle(300, 300, w, h, 10f);
cb.stroke();

> I have tried to set the color stroke and linewidth on the PdfTemplate but I
> can't get the border to show.
> can someone please point me in the right direction.

Don't draw the border on the template (it will be clipped);
draw it to the direct content.
-- 
This answer is provided by 1T3XT BVBA
http://www.1t3xt.com/ - http://www.1t3xt.info

------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com 
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to