Questions tagged [batik]

Batik is a Java-based toolkit for applications or applets that want to use images in the Scalable Vector Graphics (SVG) format for various purposes, such as display, generation or manipulation.

Apache Batik is a Java-based toolkit for applications or applets that want to use images in the Scalable Vector Graphics (SVG) format for various purposes, such as display, generation or manipulation.

The project’s ambition is to give developers a set of core modules that can be used together or individually to support specific SVG solutions. Examples of modules are the SVG Parser, the SVG Generator and the SVG DOM. Another ambition for the Batik project is to make it highly extensible —for example, Batik allows the developer to handle custom SVG elements. Even though the goal of the project is to provide a set of core modules, one of the deliverables is a full fledged SVG browser implementation which validates the various modules and their inter-operability.

The Batik toolkit includes the following:

Modules:

  • An SVG DOM implementation
  • A set of SVG microsyntax parsers
  • A scripting module
  • A generator that creates an SVG document from Java2D calls
  • A Swing SVG component
  • A transcoder module

Tools and applications:

  • Squiggle, an SVG browser
  • An SVG rasterizer
  • A to SVG converter
  • A pretty printer for SVG source files

Official Website: http://xmlgraphics.apache.org/batik/

Useful Links:

391 questions
5
votes
2 answers

Multi-page PDF generation from SVG with Java and Apache Batik

I have two simple SVG documents that I want to convert to a PDF such that each document is on one page in the PDF. My first SVG document has two rectangles that look as follow: and the second one is a black circle. The code looks as…
artofdoe
  • 167
  • 2
  • 14
5
votes
2 answers

How can I set a font-family instead of font when using Batik's SVGGraphics2D?

I currently have the following code using Batik's SVGGraphics2D: ... final SVGGraphics2D svgGraphics2D = new SVGGraphics2D(svgGeneratorContext, false); svgGraphics2D.setSVGCanvasSize(new Dimension(width,…
Kraal
  • 2,779
  • 1
  • 19
  • 36
5
votes
0 answers

Setting the size of a SVG file (via Batik)

If I render to a bitmap then the bitmap has a specific number of pixels and a DPI. That combination makes it easy to draw a square that is 1" x 1" - I render lines for each side that are DPI pixels long. When I create a SVG, I think it should still…
David Thielen
  • 28,723
  • 34
  • 119
  • 193
5
votes
1 answer

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

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…
Olivier
  • 305
  • 1
  • 4
  • 17
5
votes
2 answers

How to resize an svg (with batik) and display it?

I have a svg file of 100x100 pixels (for example). I am using Batik. If I do a : JSVGCanvas svg = new JSVGCanvas(); [...] svg.setSize(10,10); It will only show this part of the picture and not the resized image. Do you know how I can display a…
g123k
  • 3,748
  • 6
  • 42
  • 45
5
votes
1 answer

Get empty image when transcoding SVG to PNG

I'm trying to generate an SVG image and then transcode it to PNG using Apache Batik. However, I end up with an empty image and I can't see why. I use the Document from SVGDomImplementation as the base for my transcoding (to avoid writing the SVG to…
fiskeben
  • 3,395
  • 4
  • 31
  • 35
5
votes
1 answer

Easiest way to read in svg path data with Java?

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…
end-user
  • 2,845
  • 6
  • 30
  • 56
5
votes
5 answers

how to find package org.w3c.dom.svg?

I cannot seem to find it and Netbeans says that the package does not exist? Which jar do I have to get to have package org.w3c.dom.svg? I'm using batik SVG
Bashir Beikzadeh
  • 761
  • 8
  • 15
5
votes
2 answers

Wrong values of bounding box for text element using Batik

I'm trying to draw a rectangle around a text element using getBBox(), the code is pretty straightforward, create document, add text element, boot document and add rectangle. The problem is that getBBox is returning some weird values, am I missing…
Hugo Giusti
  • 197
  • 2
  • 8
4
votes
2 answers

Can I use only the Transcoder of the Batik library without all other Batik code and dependencies?

I am trying to use the Batik library source, I only want to use the transcoder to convert SVG files to PNG or JPEG only. The distribution version of the Batik Rasterizer is about 55k but when I export the jar file its 7 megs. Can I just use the…
Jesse
  • 785
  • 2
  • 9
  • 29
4
votes
1 answer

How do I add ID attribute to g element in Batik?

I am creating an SVG file using Batik, which I would like to later open in a browser and manipulate using JavaScript. I am unable to figure out how to add ID attributes to the g elements created. svgGenerator = new…
Diego
  • 85
  • 7
4
votes
5 answers

Apache Batik Transcoder inside Docker Container Blocking

We're running a Spring application within a docker container. Our application can take SVG files and transform them into PDF format to be embedded within a PDF. The application works correctly on osx and transcodes as expected. However when run from…
Liam
  • 135
  • 11
4
votes
2 answers

Batik not rendering the correct font color?

I'm using the Apache Batik Java library to convert .svg vector image file to a .png file. The problem is that the font colors of the generated .png image are all going black. Here is the code that I'm using to do the conversion: import…
MyNameIsUser
  • 119
  • 9
4
votes
1 answer

Batik SVG to PDF conversion

I am trying to use Batik to convert am SVG to JPG. In the SVG I am using an external google font, and for this reason this unfortunately this fails with following error: org.w3c.dom.DOMException:…
nutrina
  • 1,002
  • 1
  • 12
  • 26
4
votes
2 answers

Java Batik: ClassNotFoundException: org.apache.batik.dom.svg.SVGDOMImplementation

I have a servlet where i´m trying to create a pdf out of a string containing svg code. Therefore i have this code: public class Conversion extends HttpServlet { protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws…
flixe
  • 626
  • 1
  • 11
  • 36
1 2
3
26 27