batik

Swing & Batik: Create an ImageIcon from an SVG file?

偶尔善良 提交于 2019-12-02 18:39:48
Simply put, I'm looking for a way to make an ImageIcon from an SVG file using the batik library. I don't want to have to raster the SVG to disk first, I just want to be able to pull an svg out of the jar file and have it land as a UI element. I feel like this should be reasonably easy, but the batik javadocs aren't telling me what I need to know. (Why batik? Well, we're already using it, so we don't have to run another library past legal.) Devon_C_Miller It's really quite easy, just not very intuitive. You need to extend ImageTranscoder . In the createImage method you allocate a BufferedImage

Event clic with DOM / batik : Recovery the use tag which refers a symbol

你离开我真会死。 提交于 2019-12-02 00:25:23
问题 Good evening, I am currently working on a graphics application (handling a svg file) in Java with the use of batik to directly manipulate DOM document svg. My various elements are declared in "symbol" tags are used and / displayed by the tags' "use ". Here the document svg: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentScriptType="text/ecmascript" width="100%" zoomAndPan="magnify"

Easiest way to read in svg path data with Java? [duplicate]

大城市里の小女人 提交于 2019-12-01 19:27:20
问题 This question already has an answer here : How to load and parse SVG documents (1 answer) Closed 8 months ago . I'm looking to consume an svg image and parse/process the different paths to do a custom conversion. What is the easiest way, in Java, to simply extract the path data? I was looking at the apache xmlgraphics/batik packages, but it's not real obvious how to return the path types and parameters. Any suggestions? 回答1: To simply extract the path data you can use XPath. Suppose you have

How to add SVG image to PDF built with HTML and Flying Saucer library (and Batik)?

雨燕双飞 提交于 2019-12-01 18:34:48
问题 Im working on generation of PDFs with XHTML using the flying saucer library (old but open source). I got that working but I also want to add SVG images. Ive started working on integrating batik to try and get it to work but I'm running into issues. The SVG images are not drawn. The XHTML still renders, but it doesnt seem to show the SVG. I've gotten SVG to render on separate PDFs but never together with the flying saucer results. I've added the usual ReplacedElementFactory (which works with

How to add SVG image to PDF built with HTML and Flying Saucer library (and Batik)?

十年热恋 提交于 2019-12-01 18:08:49
Im working on generation of PDFs with XHTML using the flying saucer library (old but open source). I got that working but I also want to add SVG images. Ive started working on integrating batik to try and get it to work but I'm running into issues. The SVG images are not drawn. The XHTML still renders, but it doesnt seem to show the SVG. I've gotten SVG to render on separate PDFs but never together with the flying saucer results. I've added the usual ReplacedElementFactory (which works with regular images as well but havent included that code). The only relevant method (that does get called

How do I superimpose one SVG image onto another using Apache Batik?

做~自己de王妃 提交于 2019-12-01 03:52:00
I have 2 SVG files I need to overlay using Batik. One file serve as the background image and is 308px by 308px while the second file (260px by 260px) is the foreground image that must be centered (that is at the center of the background image). I'd like the result of the operation to be saved in a third SVG file. If you are familiar with Batik, I'd appreciate your suggestions. Thanks, Olivier. If you don't need to include the contents of the background and foreground documents in the final one, you can use simply reference them: <svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www

create an SVG image with embedded base64 string from another svg image with elements

别说谁变了你拦得住时间么 提交于 2019-11-30 21:44:08
I have an SVG file that contains several elements (like path, circles, rectangles, etc.). I'd like to convert that SVG file to an SVG with embedded base64 data instead of multiple elements. is it possible to do that with Batik? The project I'm working on requires I use Java libraries only. There's a technique which I've used to embed SVG images in Blogger posts which might work for this. Basically, it's a two-step process: You serialize the SVG you want to embed, and URL-encode it. You then use the URL-encoded string as a data URI in the xlink:href attribute of an SVG use element. Here's a

Unregister font with GraphicsEnvironment?

冷暖自知 提交于 2019-11-30 20:08:11
I recently found out how to register a TTF font with the local GraphicsEnvironment, s.t., for my use case (SVG-to-PNG transcoding), Apache Batik may recognize the font: import java.awt.Font; import java.awt.FontFormatException; import java.awt.GraphicsEnvironment; // [...] GraphicsEnvironment lge = GraphicsEnvironment.getLocalGraphicsEnvironment(); try { Font font = Font.createFont(Font.TRUETYPE_FONT, fontFile); lge.registerFont(font); } catch (FontFormatException e) { logger.warn(e.getMessage(), e); } catch (IOException e) { logger.warn(e.getMessage(), e); } However, I was wondering if I

SVG to PNG text not showing properly - Arial font

你说的曾经没有我的故事 提交于 2019-11-30 04:44:10
问题 I'm having an issue of converted PNG using Apache Batik is different when there is a text with different font-family, like Arial. The issue occurs in the environment where Cent OS 6 running Tomcat 7 and Java 6. The Java code used to convert SVG to PNG is : // Convert the SVG image to png and send back PNGTranscoder transcoder = new PNGTranscoder(); // TranscoderInput input = new TranscoderInput(new ByteArrayInputStream(svgImage)); outStream = new ByteArrayOutputStream(); TranscoderOutput

jQuery ajax seems to alter SVG data sent to coldfusion server

ⅰ亾dé卋堺 提交于 2019-11-29 17:07:07
I'm using $.ajax() to send a string to a coldfusion server where it is stored in a table. When I later query and try to use that data I get an error; "null Enclosed Exception: Invalid byte 2 of 3-byte UTF-8 sequence". First I grab the SVG from the DOM and send it to an action page. It should just be a string, right? var lclSVG = $('#myDiv')[0].innerHTML; // SVG Code (XML?) $.ajax({ url: "myAction.cfm", type: "POST", data: ({myInfo: lclSVG}), }); On the myAction.cfm page I update the data into a table. <CFQUERY NAME="postSVG"> UPDATE myTable SET svg = '#form.myInfo#' WHERE ID = 1 </CFQUERY>