This page’s PURL is http://purl.org/NET/2008,frankbruder/article/Apache-Batik-install,MSWindows . Please use the PURL whenever you set links to this page.
This text is also available at Google Knol.
This document describes how to install the Batik SVG Toolkit on a Microsoft Windows system. After following the instructions you will be able to use the Batik tools and applications from the Windows Explorer menu to
You will also be able to start Batik's SVG browser Squiggle from a shortcut in your Start menu or on your desktop.
I am writing this document for users who are familiar with basic usage of the Microsoft Windows graphical user interface. If you know how to use a web-browser like the Internet Explorer, open files from the Windows Explorer, drag and drop files from one folder to an other, create new folders and files, use menues, buttons, and the like then either you are able to follow the instructions I give here or my instructions need some clarification.
Specifically, it is intended that you can follow this tutorial even when you don't know how to use the command line interface, have never used batch files before, and did never manually change file type settings before. You also don't need to be a Java programmer or even know how to start a Java application.
You will have to do some guessing some times, because I didn't test this on different Windows versions. The exact names of menu entries and buttons and the structure of some dialogs might differ. The screenshots are taken on a German install of
If the Java Runtime Environment is already installed on your system then you can skip this step. If you're not sure whether you've got a JRE installed then you can also skip this step at first. When attempts to use the batch files we'll create later yield the error message “Bad command or file name” then you need to install Java. You will only need to do the other steps of the Batik installation once, no matter if they are done before or after installing Java. So you can savely skip this step for now.
To install the Java Runtime Environment, visit http://www.java.com/, follow the “download” link you find there, save the installation file to a folder where you'll find it (Desktop is fine), and then open the installation file. Installing Java should be rather easy. If you encounter any problems then refer to the Java home page for support.
If you've already got an executable of the Batik SVG toolkit on your computer then you can skip this step. But you might want to check if there's a newer version of Batik available.
Visit http://xmlgraphics.apache.org/batik/download.cgi#Download+a+distribution, and download the binary distribution for
By the time I'm writing this the current release of Apache Batik is version
The file you should download is called
This is a zip archive file. On newer versions of Microsoft Windows you can open it just like it was a folder. But that's of no use. You need to extract the files from the archive. There almost certainly is an archive program installed on your system. When you select an archive file in Windows Explorer, and then select ‘File’ from the menu there should be an entry for the archive program with several sub-entries, among them ‘Extract to…’ . I hope you've found that. Otherwise you should ask someone to help you.
Extract the archive with the Batik binary to your program files folder. For the remainder of this document wherever I write
After extracting the archive there should be a new folder
When you have installed Java, and downloaded and unpacked the Batik binary then you can use the Batik tools from the command line. But that's unsatisfactory, in my opinion. Now, let's start making the usage of Batik easier.
To do this we first create some batch files. As far as this tutorial goes, batch files are just files containing commands which we wish to use more often. Storing these commands in batch files saves us from the need to enter them to the command line each time.
To create a batch file, start a plain text editor, like the Windows Notepad; write the command or commands you wish to execute; and save the text under a file name ending with the extension ‘
I will assume that you create a new folder named ‘Batch’ in
One advantage of having a folder for batch files is that you can add that folder to the Windows search path to make using the batch files from the command line interface easier. But using the command line is not what this tutorial is about. Let me just note that adding a folder to the search path requires changing a file named
Below are some suggested file names and corresponding commands which I consider useful. You can select a text (if Javascript is enabled in your browser then clicking at any of the text areas is sufficient to select the text therein), copy it by pressing
Depending on which Batik version you use and which folder you've unpacked it to you might need to change the paths given in the batch files. Using absolute paths–not paths pointing to the
I suppose you get the basic idea of how this works. Let me just explain the parts with the percent signs.
With the ‘%1’ we use an argument which would be given to the batch file. When you enter
"C:\Program Files\Batch\svg2png.bat" example.svg
on the command line then the batch file will be executed as if
When you've created the batch files then open the folder in which you have saved them in Windows Explorer and double-click at
One obstacle here is that in these files line breaks are saved in a different way than what Windows applications usually use. Maybe you'll have to change the line breaks manually in order to have a well arranged overview of the options. Also the Batik font converter writes it's usage instructions not to the standard output stream but to a stream for error messages. The syntax I've used to redirect that error stream to the text file does not work on older Windows versions. And I have not tested it on a Windows system on which it does work, so maybe it's not really the correct syntax for newer versions either.
You can also find explanations of the command line options at the pages linked at http://xmlgraphics.apache.org/batik/tools/index.html. You'll need these options when you wish to customize the batch files.
When you're done creating the batch files you can start Batik's SVG browser Squiggle by double-clicking Squiggle.bat. When in Windows Explorer you select the batch file and choose “File”, “Create shortcut” from the menu then you create a link to that batch file. It will appear in the same folder and run by the name of ‘Shortcut to Squiggle.bat’. You can rename it to ‘Squiggle’ and move it via drag and drop to the Start menu or the desktop or wherever you'd like to have it.
You can also create multiple shortcuts to the same file. If you later change the batch file, for example to set the font-size option, then using each shortcut will start Squiggle with the same options you've added to the batch file.
The SVG file type is most probably registered with your system already. When your system does not know the file type SVG yet then SVGs will be represented by some general icon (on my system it's a white sheet with the Windows symbol on it), in the file properties the type is given as ‘File SVG’, and the most accurate indicator is that the “File” menu offers “Open with…” instead of “Open”.
If your system does not know the file type SVG then my advice is to go to http://www.adobe.com/svg/viewer/install/ to download and install the Adobe SVG Viewer. The installation program will create the filetype ‘SVG Document’ with the MIME type
You can also create the file type manually. Instructions for doing so might get added to later versions of this document. Also there is a number of other applications which would register the file file type on installation. Some people will disagree, but I think that installing the Adobe SVG Viewer is the most convinient solution currently. I suspect that it's the way the file type was introduced to most Windows systems on which it exists.
Now we will create actions for the file type ‘SVG Document’ and also one action for the file type ‘True Type Font’. Actions are the options appearing on top of the “File” menu of Windows Explorer when one file is selected and also on top of the pop-up menu appearing when you right-click one file. What happens when you double-click a file is the default action for that file type–in most cases it's ‘open’. Actions are often created automatically while you install new programs. For Batik we need to create the actions manually.
I will assume here that the file type associated with the extensions
Let's first create the action “create PNG”.
Open Windows Explorer and select “Tools”, “Folder Options…” to display the ‘Folder Options’ dialog box. (Or maybe it's “View”, “Folder Options…” on your system. Just search for “Folder Options…”.)
In the ‘Folder Options’ dialog box select the tab ‘File Types’. There you see a list of registered file types, ordered alphabetically. Select “SVG Document” from the list. To find it you can press ‘T’ on your keyboard to jump directly to the first file type starting with the letter ‘T’ and search from there upward. If the file type for SVG has a different name on your system, not starting with ‘SVG’, then remember that you'll have to find that name in the list.
When you've selected the file type you wish to edit then click the “Advanced” (or maybe it's “Edit” on your system) button to open the ‘Edit File Type’ dialog box.
In this dialog we're interested in the ‘Actions’ associated with the file type. Click “New…” to open the ‘New Action’ dialog.
In the ‘New Action’ dialog box enter
Click “OK”. Now the action “create PNG” should appear in the ‘Edit File Type’ dialog box.
In the same way you've created the action “create PNG” you can now create an action named “create PDF” referencing the batch file
After creating the actions click “OK” to close the ‘Edit File Type’ dialog. Then click “Close” (or maybe it's “OK” again) to close the ‘Folder Options’ dialog.
Before you go testing your new actions, one word of caution: Read the section about the problem of DOS
And now there's one more action to create. Open “Folder Options”, “File Types” again. This time select the file type ‘True Type font’. Open the “Edit File Type” dialogue. Click “New…” to create a new action. This action we call “create SVG Font file” and make it reference our
Let's assume we have a folder in which there is an SVG file named
"C:\Program Files\Batch\svg2png.bat" page1_figure1.svg
then the Batik rasterizer will create a file
File names in
In our example the SVG document would have the
The problem with this is that the rasterizer will derive the filename for the output file from the filename given to it. In this case it will write to
So when you use the action to create a PNG the rasterizer will overwrite the existing PNG file of a different filename in the same folder.
To avoid such problems it's wise to take care that filenames differ in their first six characters. There surely are more advanced ways to get around this problem. But I haven't found one yet.
With the font converter and the pretty printer things work a bit different. Both do by default not write to files but to the standard output stream. So I have to derive a filename for the output file myself.
In batch programming there seems to be no simple way to extract the base name from a filename. The way I helped myself here is that when, for example, you convert a True Type font with the
The pretty printer does actually write only to the standard output. You may find that overwriting the source SVG with the pretty printed version of the same SVG would be okay for your purposes. But this would need a bit more knowledge of batch programming than I can offer, because before you overwrite the source file you would want to check that the pretty printer did not throw an exception.
I've had the problem that with some True Type fonts the font converter did create SVG documents with no glyph tags. I found that this problem was solved by explicitly specifying the range of characters to be converted, by using the -l
-h
This Document is licensed under the Apache License,
The License grants you permission to distribute copies of this document. My intention, of course, is that when you distribute copies of Batik you should be allowed to include this tutorial. Especially for offline copies just including a link to the online version of this tutorial might be insufficient.
The License also permits you to make changes to this document and redistribute the changed version. But you must apply the same license to any modified version which you distribute. You are not allowed to remove copyright notices (or patent, trademark, or attribution notices.) And you must add a notice stating that you have changed the file. Modifications are not only allowed, but definitely welcomed. In fact I've compiled some ideas for improvements in the file
This document was actually created from a PHP document. So if you intend to modify it I ask that you download the archive file
The archive file
This file was downloaded from http://frabru.de:80/batikinstall_doc_win/batikinstall.php?r=%2Fc.php%2Farticle%2F&rt=Articles
Copyright 2008-2010 Frank Bruder Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.