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:

367 questions
7
votes
1 answer

Unregister font with GraphicsEnvironment?

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…
RobertG
  • 1,118
  • 1
  • 17
  • 38
7
votes
1 answer

How can I programatically convert SVG files containing text to PDF files (specifically on CentOS 5.3 x86_64)?

I would like to programatically convert SVG files to PDF files. However, the SVG files contain text that must be searchable in the generated PDF files. Also, it has to work on Red Hat Enterprise Linux 5.3 or CentOS 5.3 for the x86_64 architecture.…
Christopher Bottoms
  • 10,220
  • 7
  • 44
  • 87
7
votes
1 answer

Batik SVGGraphics2D nullpointerexception when drawing image

I'm trying to use the Batik library to draw a BufferedImage to a SVG file. I have very similar code working fine for EPS/PS files, but for some reason the following code: // Get a DOMImplementation and create an XML document DOMImplementation…
Alex Z
  • 1,299
  • 3
  • 16
  • 27
6
votes
1 answer

How to get the image size (width/height) of an SVG image with batik

How can I get the size (width/height) of an SVG image using batik (1.7)? String s = "https://openclipart.org/download/228858"; InputStream is = new URL(s).openStream(); DocumentBuilderFactory f =…
Thor
  • 6,375
  • 13
  • 60
  • 93
6
votes
1 answer

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

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.…
Daxterwous
  • 219
  • 1
  • 3
  • 12
6
votes
1 answer

SVG to PNG text not showing properly - Arial font

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…
Shantha Kumara
  • 2,679
  • 3
  • 32
  • 48
6
votes
3 answers

Poor Image Quality when using SVGConverter in Batik to convert svg to png

My converted image's quality is very low. I have tried using the setQuality method but it does not seem to change anything. This is the part of the code that converts svg to png: SVGConverter svgConverter = new SVGConverter(); String[] sources = {…
KrispyDonuts
  • 1,230
  • 1
  • 17
  • 36
5
votes
1 answer

How to paint SVG images efficiently in Java?

Reference: How can you produce sharp paint results when rotating a BufferedImage? In the referenced question I asked about quality regarding transformations of rasterized images. Someone suggested that I should use SVG images, as the quality of…
rtheunissen
  • 6,831
  • 5
  • 30
  • 60
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
  • 135
  • 1
  • 10
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,387
  • 1
  • 14
  • 29
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
  • 22,779
  • 27
  • 83
  • 163
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
  • 195
  • 1
  • 3
  • 17
5
votes
1 answer

Display svg on canvas

I want to display some images on a canvas accordingly to screen dimension without losing the image resolution. If I use a simple png or jpeg, I will see the image pixelized on a big screen. What I am thinking is to use svg files and display them on…
5
votes
1 answer

Getting specific elements with XPath from an SVG with Batik

I am trying to find some elements from an SVG document with Batik. This is the example SVG document I am using:
radlan
  • 1,985
  • 4
  • 24
  • 46
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,146
  • 3
  • 26
  • 32
1
2
3
24 25