There are several reasons why EchoSVG is not a drop-in replacement for Apache Batik:
-
Avoid using Apache Software Foundation package names and trademarks.
-
Improved conformance to the SVG and CSS specifications.
-
Better user experience (e.g. the
codecclasses that got merged intotranscoder, or the cleaner module interdependencies). -
A circularity with Apache FOP. To render PDF images, Batik uses FOP which in turn uses Batik, so depending on FOP would imply mixing EchoSVG and Batik. See issue #10.
-
Changes in the Java™ Platform.
To migrate from Apache Batik, you generally have to deal with the following:
-
Package names are now prefixed by
io.sf.carte.echosvginstead oforg.apache.batik. -
Class names that included the name "Batik" now have "EchoSVG".
-
The
codec-transcodercircular dependency was removed in the following way: a few classes from thecodecmodule were moved totranscoder. Nowtranscoderexplicitly depends oncodec(but not the other way around). -
Tcl and Python 2.x scripting was removed (see issues #12 and #13). That scripting wasn't functional in Batik anyway.
-
The generic
rasterizermodule (and related files) was removed (svgrasterizeris still available but no longer supports PDF graphics). See issue #10 for more details. -
SAXDocumentFactoryandSAXSVGDocumentFactoryno longer have constructors withStringarguments. Either remove the string argument or replace it by anulland you should be fine. Alternatively, you can now use your ownXMLReaderin place of the parser class name. (The API change was made for security reasons) -
EchoSVG does not depend on
xml-apis-ext-1.3.04.jarto provide the SVGOM and SMIL APIs (see #15). Ifxml-apis-exthappens to be in your modulepath, you could configure an exclusion for it (in Maven or Gradle), and letsvgom-apiandsmil-api(transitive dependencies of EchoSVG from the Web APIs project) do the job, as they are compatible with Batik. If your project requires the old SAC api which is provided byxml-apis-extas well, you can usesac.jaras a replacement. -
EchoSVGSecurityManageris deprecated for removal due to Security Manager API being deprecated for removal since Java 17. Similarly,RhinoClassLoader.getAccessControlContext()and other security-related methods in other classes are deprecated for removal as well. The constructorApplicationSecurityEnforcer(Class, String)is no longer public, please useApplicationSecurityEnforcer.createSecurityEnforcer(Class, String)instead. -
BridgeContext(in thebridgemodule) gained aclosemethod. -
SVGAnimationElementBridge.initializeAnimation()gained aBridgeContextargument and now returns aboolean.
-
The old and deprecated
CSSValueAPI was replaced by an API close to W3C's Typed OM. One of the consequences is that if your scripts callgetPresentationAttributeonSVGStylableobjects,getPresentationAttributeValueshould be called instead, obtaining aCSSStyleValue. Note that modern SVGOM has neither of those methods. -
The
line-heightproperty now has a global default of 1.1, instead of the mixture of 1.1 and 1 that Batik uses. -
The
css.engine.value.css2package was renamed tocss.engine.value.css, given that CSS as a whole isn't versioned anymore. -
You can keep using the old
transcodermodule, but that one was split in four sub-modules. For example, for converting SVG to any image format (like PNG) you only need theechosvg-transcoder-svgmodule. Note that if you have a user agent that inherits from theSVGAbstractTranscoderUserAgent, that class is now located inside a newSVGAbstractTranscoderclass that was created in theio.sf.carte.echosvg.transcoder.svgpackage, which shadows the old class of the same name located atio.sf.carte.echosvg.transcoder. -
Field
SVGDOMImplementation.svg11Factorieswas renamed tosvgFactories. -
Package
io.sf.carte.echosvg.ext.swingwas moved fromechosvg-awt-utilto a newio.sf.carte.echosvg.ext.swingmodule (echosvg-ext-swingGradle name). -
Methods that took an
ICCColorSpaceWithIntent(from xmlgraphics-commons), likeImageTagRegistry.readStream(stream, space), now take aColorSpace. The legacy ICC color stuff was removed, as it did not produce actual colors outside of the sRGB gamut, is not supported by browsers and was just adding bloat. -
Protected method
SVGAbstractTranscoder.createBridgeContext(String)was deprecated, due to theversionattribute being dropped from SVG. If you wanted to override it, please do that withcreateBridgeContext()andcreateSVG12BridgeContext()instead. The former creates aBridgeContextwhich is intended for the current SVG specification, not just 1.1 as in Batik, while the latter produces one for the deprecated 1.2 version.