incubator-odf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rob Weir (JIRA)" <>
Subject [jira] [Commented] (ODFTOOLKIT-341) newImage() generates java.lang.NullPointerException when using an svg image
Date Thu, 11 Oct 2012 19:57:03 GMT


Rob Weir commented on ODFTOOLKIT-341:

The problem looks like it is in org.odftoolkit.odfdom.incubator.doc.draw.OdfDrawImage.configureInsertedImage(),
line 119 and following.  It tries to load the image file using into a BufferedImage in order
to get the image size, so it can properly declare the frame width and height.  

Does javax.imageio.ImageIO support SVG?    If not, that's a problem.  If it does support SVG,
I wonder if there is an issue with this specific SVG file?

Backup plan might be to have a newImage() overload that passes in the width and height so
the image file does not need to be parsed.
> newImage() generates java.lang.NullPointerException when using an svg image
> ---------------------------------------------------------------------------
>                 Key: ODFTOOLKIT-341
>                 URL:
>             Project: ODF Toolkit
>          Issue Type: Bug
>          Components: simple api
>    Affects Versions: 0.8
>         Environment: Windows 7 Home 32 bit
> JRE 7 32 bit
> Eclipse Indigo SR2
> odf-toolkit 0.5 
> and also tried odf-toolkit SVN revision 1395734 (built with Maven on Ubuntu): simple-odf-0.8-incubating-SNAPSHOT,
>            Reporter: Anders Sjöström
>         Attachments: simple.svg
> I'm trying to create an odt file, and insert text and svg images, with limited success.
> Inserting a png image is no problem, but when I change the line to insert an svg image
I get an exception.
> This is the minimum program to demonstrate my problem:
> import;
> import org.odftoolkit.simple.TextDocument;
> public class odfgenerator {
> 	public static void main(String[] args) throws Exception {
> 		TextDocument outputOdt;
> 		outputOdt = TextDocument.newTextDocument();
> 		outputOdt.addParagraph("Hello World.");
> 		//URI uri = new URI("file:///C:/Users/myuser/Desktop/simple.png");
> 		URI uri = new URI("file:///C:/Users/myuser/Desktop/simple.svg");
> 		outputOdt.newImage(uri);
> 	}
> }
> If I run my program (in Eclipse) I get:
> okt 08, 2012 11:30:57 EM org.odftoolkit.simple.Document newImage
> SEVERE: null
> java.lang.NullPointerException
> 	at org.odftoolkit.odfdom.incubator.doc.draw.OdfDrawImage.configureInsertedImage(
> 	at org.odftoolkit.odfdom.incubator.doc.draw.OdfDrawImage.newImage(
> 	at org.odftoolkit.simple.Document.newImage(
> 	at odfgenerator.main(
> I delete HelloWorld.odt before every run, just to make sure. The odd thing is that despite
the exception, HelloWorld.odt is still created, with the svg file inside the Pictures directory,
and the content.xml has an draw:image tag with xlink:href="Pictures/simple.svg". The odt file
can be opened with Apache Open Office without problem, and will display the picture.
> Changing the URI to point to an png file instead results in the program terminating normally
without any errors. The resulting file can also be opened with Apache Open Office without
> simple.svg is a very simple svg file created with Inkskape containing two boxes, and
saved as "plain svg".
> Am I doing anything wrong or is this a bug?

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:

View raw message