iText's support for different paint types int PdfGraphics2D
needs a little work, I may soon see to that, but until
then
you should just "Paint" your paint into a BufferedImage and
then create a TexturePaint to place it into the PDF
ie:
/********* CODE *********/
BufferedImage image = new
BufferedImage(shapeToPaint.getWidth(),shapeToPaint.getHeight(),
BufferedImage.IMAGE_TYPE);
Graphics2D g2 = image.createGraphics();
g2.setPaint(yourGradientPaint);
g2.fill(shapeToPaint);
g2.dispose.
TexturePaint newPaintForPDF = new TexturePaint(image,
shapeToPaint);
pdfGraphics.setPaint(newPaintForPDF);
pdfGraphics.fill(shapeToPaint);
/********* CODE
*********/
I may be a little off there, I didn't try to compile it,
but it gives you the general idea.
I hope this helps,
-Bill Ensley
Bear Printing
I'm running into a problem using Gradient Paint in a custom component. When the component is displayed on the screen, all is fine. When it's painted to a PdfGraphics2D instance, some of the Gradient Paint shows up, and some of it doesn't - it appears solid green. It looks like the Gradient Paint's "cycle" atribute isn't working in the PDF Graphics?
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Panurgy
Sent: Friday, July 28, 2006 2:49 PM
To: [email protected]
Subject: [iText-questions] Using GradientPaint and PdfGraphics2D
A search of the archives turned up a similar post, but no solution
http://sourceforge.net/mailarchive/message.php?msg_id=12532094
I've attached a sample program, and at line 138 if yuo change the 'true' to 'false', then the screen and the PDF will match up. How do I get my GraidentPaint to 'cycle' like it does in Swing?
Any ideas? Thanks!
--Ben
------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions
