Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within JSP
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
paul wheaton
Ron McLeod
Jeanne Boyarsky
Sheriffs:
Paul Clapham
Saloon Keepers:
Tim Holloway
Roland Mueller
Bartenders:
Forum:
JSP
Showing JSP output in XSL
Joseph Bashir
Ranch Hand
Posts: 41
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi
The below
JSP
code produces an image from text. I want to take this output to an XSL file. Please guide me how to do it?
<% String text = "Test string"; String font_file = "/MTCORSVA.TTF"; float size = 20.0f; Color color = Color.black; Font font = Font.createFont(Font.TRUETYPE_FONT, new FileInputStream(font_file)); font = font.deriveFont(size); BufferedImage buffer = new BufferedImage(1,1,BufferedImage.TYPE_INT_RGB); Graphics2D g2 = buffer.createGraphics(); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); FontRenderContext fc = g2.getFontRenderContext(); Rectangle2D bounds = font.getStringBounds(text,fc); // calculate the size of the text int width = (int) bounds.getWidth(); int height = (int) bounds.getHeight(); // prepare some output buffer = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); g2 = buffer.createGraphics(); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setFont(font); g2.fillRect(0,0,width,height); g2.setColor(color); g2.drawString(text,0,(int)-bounds.getY()); // set the content type and get the output stream response.setContentType("image/png"); OutputStream os = response.getOutputStream(); // output the image as png ImageIO.write(buffer, "png", os); os.close(); %>
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I want to take this output to an XSL file.
XSL files are always XML formatted text thus cannot contain a binary image. Where is that image supposed to wind up finally?
Bill
[ October 01, 2007: Message edited by: William Brogden ]
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
way to rotate without using Graphics2D.rotate()
font getting fuzzy on Graphics 2D
Text File to JPG file conversion using Java
error while using BufferedImage class in servlet
how to save text as gif ?
More...