Dynamic SVG Image: Item is not supported [message #720979] |
Wed, 31 August 2011 15:54 |
Eclipse User |
|
|
|
Originally posted by: Mirko Swillus
Hej,
I'm trying to render a SVG image that is provided as a byte array within
a DataSource, target format is PDF. All the PDF says, is
"Current report item is not supported in this report format."
When I put a JPG as a byte array into the DataSources property
'row["Image"]' (see rptdesign below) everything works fine. Furthermore,
adding an embedded SVG image works, too.
I guess I have to specify the images mime type ("image/svg+xml"), image
type or file extension, but I have no glue how to do it. All I tried
concerning this failed.
Please find the interesting part of my .rptdesign below. Thanks in advance,
Mirko Swillus
===========================================
<body>
<image name="name_blue" id="15">
<property name="height">3.15625in</property>
<property name="width">7.583333333333333in</property>
<property name="dataSet">Data Set</property>
<list-property name="boundDataColumns">
<structure>
<property name="name">Image</property>
<expression name="expression"
type="javascript">dataSetRow["Image"]</expression>
<property name="dataType">javaObject</property>
</structure>
</list-property>
<structure name="toc"/>
<property name="source">expr</property>
<expression name="valueExpr">row["Image"]</expression>
</image>
</body>
============================================
|
|
|
Re: Dynamic SVG Image: Item is not supported [message #721115 is a reply to message #720979] |
Wed, 31 August 2011 22:28 |
|
Have you set the data type to blob and tried it?
I was able to read one from a file in the image onCreate script like:
importPackage(Packages.java.io);
importPackage(Packages.java.lang);
var file = new File("C:/work/workspaces/2.6.1workspaces/BIRT -
Reports/BIRT Reports/resources/spain.svg");
var ist = new FileInputStream(file);
var lengthi = file.length();
bytesa = new ByteArrayOutputStream( lengthi);
var c;
while((c=ist.read()) != -1){
bytesa.write(c);
} ist.close();
this.data = bytesa.toByteArray();
Jason
On 8/31/2011 11:54 AM, Mirko Swillus wrote:
> Hej,
>
> I'm trying to render a SVG image that is provided as a byte array within
> a DataSource, target format is PDF. All the PDF says, is
>
> "Current report item is not supported in this report format."
>
> When I put a JPG as a byte array into the DataSources property
> 'row["Image"]' (see rptdesign below) everything works fine. Furthermore,
> adding an embedded SVG image works, too.
>
> I guess I have to specify the images mime type ("image/svg+xml"), image
> type or file extension, but I have no glue how to do it. All I tried
> concerning this failed.
>
> Please find the interesting part of my .rptdesign below. Thanks in advance,
>
> Mirko Swillus
>
> ===========================================
> <body>
> <image name="name_blue" id="15">
> <property name="height">3.15625in</property>
> <property name="width">7.583333333333333in</property>
> <property name="dataSet">Data Set</property>
>
> <list-property name="boundDataColumns">
> <structure>
> <property name="name">Image</property>
> <expression name="expression"
> type="javascript">dataSetRow["Image"]</expression>
> <property name="dataType">javaObject</property>
> </structure>
> </list-property>
> <structure name="toc"/>
> <property name="source">expr</property>
> <expression name="valueExpr">row["Image"]</expression>
> </image>
> </body>
> ============================================
>
>
>
>
|
|
|
Re: Dynamic SVG Image: Item is not supported [message #721269 is a reply to message #721115] |
Thu, 01 September 2011 09:50 |
Eclipse User |
|
|
|
Originally posted by: Mirko Swillus
Jason,
Am 01.09.2011 00:28, schrieb Jason Weathersby:
> Have you set the data type to blob and tried it?
thanks for your answer, but changing 'javaObject' to 'blob' makes no
difference.
But I managed to solve the problem, with the help of [0]. As I guessed
yesterday, I had to set the MIME type explicitly, since BIRT obviously
has problems to resolve the image type itself when overhanding a SVG as
a byte array (at least within my BIRT 3.7 runtime here, providing a JPG
the same way works fine).
The resulting part of my .rptdesign looks like this now:
==========================================
<body>
<image name="some" id="15">
<property name="height">3.15625in</property>
<property name="width">7.583333333333333in</property>
<property name="dataSet">Data Set</property>
<list-property name="boundDataColumns">
<structure>
<property name="name">Image</property>
<expression name="expression"
type="javascript">dataSetRow["Image"]</expression>
<property name="dataType">javaObject</property>
</structure>
</list-property>
<structure name="toc"/>
<property name="source">expr</property>
<expression name="valueExpr">row["Image"]</expression>
<expression name="typeExpr">"image/svg+xml"</expression>
</image>
</body>
===========================================
Mind the <expression name="typeExpr">"image/svg+xml"</expression>.
Quotes are required because it has to be a valid JavaScript Expression.
Regards,
Mirko Swillus
[0]
http://www.eclipse.org/birt/ref/rom/elements/Image.html#Property-typeExpr
Am 01.09.2011 00:28, schrieb Jason Weathersby:
> Have you set the data type to blob and tried it?
>
> I was able to read one from a file in the image onCreate script like:
> importPackage(Packages.java.io);
> importPackage(Packages.java.lang);
>
>
>
> var file = new File("C:/work/workspaces/2.6.1workspaces/BIRT -
> Reports/BIRT Reports/resources/spain.svg");
> var ist = new FileInputStream(file);
> var lengthi = file.length();
>
> bytesa = new ByteArrayOutputStream( lengthi);
> var c;
> while((c=ist.read()) != -1){
> bytesa.write(c);
> } ist.close();
>
> this.data = bytesa.toByteArray();
>
>
> Jason
>
> On 8/31/2011 11:54 AM, Mirko Swillus wrote:
>> Hej,
>>
>> I'm trying to render a SVG image that is provided as a byte array within
>> a DataSource, target format is PDF. All the PDF says, is
>>
>> "Current report item is not supported in this report format."
>>
>> When I put a JPG as a byte array into the DataSources property
>> 'row["Image"]' (see rptdesign below) everything works fine. Furthermore,
>> adding an embedded SVG image works, too.
>>
>> I guess I have to specify the images mime type ("image/svg+xml"), image
>> type or file extension, but I have no glue how to do it. All I tried
>> concerning this failed.
>>
>> Please find the interesting part of my .rptdesign below. Thanks in
>> advance,
>>
>> Mirko Swillus
>>
>> ===========================================
>> <body>
>> <image name="name_blue" id="15">
>> <property name="height">3.15625in</property>
>> <property name="width">7.583333333333333in</property>
>> <property name="dataSet">Data Set</property>
>>
>> <list-property name="boundDataColumns">
>> <structure>
>> <property name="name">Image</property>
>> <expression name="expression"
>> type="javascript">dataSetRow["Image"]</expression>
>> <property name="dataType">javaObject</property>
>> </structure>
>> </list-property>
>> <structure name="toc"/>
>> <property name="source">expr</property>
>> <expression name="valueExpr">row["Image"]</expression>
>> </image>
>> </body>
>> ============================================
>>
>>
>>
>>
>
|
|
|
Re: Dynamic SVG Image: Item is not supported [message #721387 is a reply to message #721269] |
Thu, 01 September 2011 16:01 |
|
Thanks for posting.
Jason
On 9/1/2011 5:50 AM, Mirko Swillus wrote:
> Jason,
> Am 01.09.2011 00:28, schrieb Jason Weathersby:
> > Have you set the data type to blob and tried it?
>
> thanks for your answer, but changing 'javaObject' to 'blob' makes no
> difference.
>
> But I managed to solve the problem, with the help of [0]. As I guessed
> yesterday, I had to set the MIME type explicitly, since BIRT obviously
> has problems to resolve the image type itself when overhanding a SVG as
> a byte array (at least within my BIRT 3.7 runtime here, providing a JPG
> the same way works fine).
>
> The resulting part of my .rptdesign looks like this now:
>
> ==========================================
> <body>
> <image name="some" id="15">
> <property name="height">3.15625in</property>
> <property name="width">7.583333333333333in</property>
> <property name="dataSet">Data Set</property>
> <list-property name="boundDataColumns">
> <structure>
> <property name="name">Image</property>
> <expression name="expression"
> type="javascript">dataSetRow["Image"]</expression>
> <property name="dataType">javaObject</property>
> </structure>
> </list-property>
> <structure name="toc"/>
> <property name="source">expr</property>
> <expression name="valueExpr">row["Image"]</expression>
> <expression name="typeExpr">"image/svg+xml"</expression>
> </image>
> </body>
> ===========================================
>
> Mind the <expression name="typeExpr">"image/svg+xml"</expression>.
> Quotes are required because it has to be a valid JavaScript Expression.
>
> Regards,
> Mirko Swillus
>
>
> [0]
> http://www.eclipse.org/birt/ref/rom/elements/Image.html#Property-typeExpr
>
> Am 01.09.2011 00:28, schrieb Jason Weathersby:
> > Have you set the data type to blob and tried it?
> >
> > I was able to read one from a file in the image onCreate script like:
> > importPackage(Packages.java.io);
> > importPackage(Packages.java.lang);
> >
> >
> >
> > var file = new File("C:/work/workspaces/2.6.1workspaces/BIRT -
> > Reports/BIRT Reports/resources/spain.svg");
> > var ist = new FileInputStream(file);
> > var lengthi = file.length();
> >
> > bytesa = new ByteArrayOutputStream( lengthi);
> > var c;
> > while((c=ist.read()) != -1){
> > bytesa.write(c);
> > } ist.close();
> >
> > this.data = bytesa.toByteArray();
> >
> >
> > Jason
> >
> > On 8/31/2011 11:54 AM, Mirko Swillus wrote:
> >> Hej,
> >>
> >> I'm trying to render a SVG image that is provided as a byte array
> within
> >> a DataSource, target format is PDF. All the PDF says, is
> >>
> >> "Current report item is not supported in this report format."
> >>
> >> When I put a JPG as a byte array into the DataSources property
> >> 'row["Image"]' (see rptdesign below) everything works fine.
> Furthermore,
> >> adding an embedded SVG image works, too.
> >>
> >> I guess I have to specify the images mime type ("image/svg+xml"), image
> >> type or file extension, but I have no glue how to do it. All I tried
> >> concerning this failed.
> >>
> >> Please find the interesting part of my .rptdesign below. Thanks in
> >> advance,
> >>
> >> Mirko Swillus
> >>
> >> ===========================================
> >> <body>
> >> <image name="name_blue" id="15">
> >> <property name="height">3.15625in</property>
> >> <property name="width">7.583333333333333in</property>
> >> <property name="dataSet">Data Set</property>
> >>
> >> <list-property name="boundDataColumns">
> >> <structure>
> >> <property name="name">Image</property>
> >> <expression name="expression"
> >> type="javascript">dataSetRow["Image"]</expression>
> >> <property name="dataType">javaObject</property>
> >> </structure>
> >> </list-property>
> >> <structure name="toc"/>
> >> <property name="source">expr</property>
> >> <expression name="valueExpr">row["Image"]</expression>
> >> </image>
> >> </body>
> >> ============================================
> >>
> >>
> >>
> >>
> >
>
|
|
|
|
|
|
|
Re: Dynamic SVG Image: Item is not supported [message #778775 is a reply to message #778715] |
Fri, 13 January 2012 19:57 |
|
Can you try the attached example?
Jason
On 1/13/2012 12:28 PM, Chris Harrington wrote:
> I also tried doing it in onCreate()
>
> First, I tried using it directly:
>
> -- begin code --
>
> importPackage(Packages.java.io);
> importPackage(Packages.java.lang);
>
> var file = new File("C:/Users/chris/Downloads/helloworld.svg");
> var ist = new FileInputStream(file);
> var lengthi = file.length();
>
> bytesa = new ByteArrayOutputStream( lengthi);
> var c;
> while((c=ist.read()) != -1){
> bytesa.write(c);
> }
> ist.close();
>
> this.data = bytesa.toByteArray();
>
> -- end code --
>
> The SVG wasn't displayed and there was no error
>
>
> Then since I wasn't sure if it needed to be transcoded, I tried:
>
> -- begin code --
>
> try {
>
> importPackage(Packages.java.io);
> importPackage(Packages.java.lang);
>
> var t = new Packages.org.apache.batik.transcoder.image.PNGTranscoder();
> var file = new File("C:/Users/chris/Downloads/helloworld.svg");
> var ist = new FileInputStream(file);
> var s = new Packages.java.lang.String(ist.toString());
> var bais = new Packages.java.io.ByteArrayInputStream(s.getBytes());
> var input = new Packages.org.apache.batik.transcoder.TranscoderInput(bais);
> var baos = new Packages.java.io.ByteArrayOutputStream();
> var output = new
> Packages.org.apache.batik.transcoder.TranscoderOutput(baos);
> t.transcode(input, output);
> this.data = baos.toByteArray();
> } catch (e) {
> Packages.javax.swing.JOptionPane.showMessageDialog(null, e);
> }
>
> -- end code --
>
> This resulted in the error
>
> JavaException org.apache.batik.transcoder.TranscoderException: null
> Enclosed Exception
> Content is not allowed in prolog.
>
|
|
|
|
|
Re: Dynamic SVG Image: Item is not supported [message #780355 is a reply to message #778838] |
Tue, 17 January 2012 16:48 |
|
Chris,
This worked for me in 3.7.1 as well. Can you look at your preferences:
Window->preferences->Report Design->Preview and check the box to Always
use external browsers. Then click on the Web Browser link below the
checkbox to verify that it is using firefox?
Jason
On 1/13/2012 6:20 PM, Chris Harrington wrote:
> Hi Jason,
> I noticed that your report file has BIRT Designer Version 2.6.1, and I
> am using Version 3.7.1. Is that relevant?
>
> What I am ultimately needing to do is modify an SVG template based upon
> data fields. I think the options are
> a) request an SVG via a url with a querystring, and have a the servlet
> load, modify, and return the SVG
> b) load an SVG in the onRender event and using script modify the SVG DOM
> before transcoding
> c) some other approach I haven't considered.
>
> But first I need to get working a simple example of a dynamic SWF.
|
|
|
|
|
Re: Dynamic SVG Image: Item is not supported [message #783012 is a reply to message #782891] |
Tue, 24 January 2012 22:32 |
|
Why not use a URI image and just set the uri in the editor or in script
like:
var myurl = new Packages.java.net.URL("yoururltosvg");
this.URI = myurl;
Jason
On 1/24/2012 11:48 AM, Chris Harrington wrote:
> How to load SVG from a URL?
>
> I can do this to load an image from a URL:
>
> try {
>
> importPackage(Packages.java.io);
> importPackage(Packages.java.lang);
> importPackage(Packages.java.net);
> importPackage(Packages.javax.imageio);
>
> var myurl = new Packages.java.net.URL("http://localhost/welcome.png");
>
> var img = ImageIO.read(myurl);
> bas = new ByteArrayOutputStream();
> ImageIO.write(img, "png", bas);
> this.data = bas.toByteArray();
>
> } catch (e) {
> Packages.javax.swing.JOptionPane.showMessageDialog(null, e);
> }
>
>
> But I can't figure out how to do the same for an SVG image. Thanks for
> any guidance.
>
> - Chris
|
|
|
|
|
Re: Dynamic SVG Image: Item is not supported [message #784503 is a reply to message #783933] |
Fri, 27 January 2012 16:17 |
|
In method 1 are you running to html in the viewer and then exporting to pdf?
Jason
On 1/26/2012 2:26 PM, Chris Harrington wrote:
> Here's more details on my results so far. Some things work properly with
> some methods, but there are certainly lots of issues.
>
> Method 1:
> -----------
>
> code:
>
> importPackage(Packages.java.io);
> importPackage(Packages.java.lang);
>
> var file = new File("C:/inetpub/wwwroot/spaceship3.svg");
> var ist = new FileInputStream(file);
> var lengthi = file.length();
>
> bytesa = new ByteArrayOutputStream( lengthi);
> var c;
> while((c=ist.read()) != -1){
> bytesa.write(c);
> }
> ist.close();
>
> this.data = bytesa.toByteArray();
>
> results:
>
> In report viewer, the SVG image is displayed. The render quality is
> high. Onload()
> script in SVG is executted and rendered results reflect DOM operations
> done in script.
>
> In PDF, the SVG image is displayed but the transparency is lost
> (transparency was
> present in web viewer). Onload() script operations are not reflected in
> rendered
> results.
>
>
> Method 2:
> ----------------
>
> code:
>
> var url = new
> Packages.java.net.URL("http://localhost/sendsvg.aspx?score=5&m=3&sd=2");
> this.URI = url;
>
> results:
>
> The SVG image is not rendered.
>
> Method 3:
> -----------------
>
> code:
>
> importPackage(Packages.java.io);
> importPackage(Packages.java.lang);
> importPackage(Packages.java.net);
>
> var t = new Packages.org.apache.batik.transcoder.image.PNGTranscoder();
> var url = new
> Packages.java.net.URL("http://localhost/sendsvg.aspx?score=5&m=3&sd=2");
> var conn = url.openConnection();
> var inp = conn.getInputStream();
>
> var input = new Packages.org.apache.batik.transcoder.TranscoderInput(inp);
> var baos = new Packages.java.io.ByteArrayOutputStream();
> var output = new
> Packages.org.apache.batik.transcoder.TranscoderOutput(baos);
> t.transcode(input, output);
> this.data = baos.toByteArray();
> results:
>
> The SVG is rendered in the report viewer. Rendering quality is not as good
> as in Method 2. Transparency is rendered properly. Onload() script in SVG
> in not reflected in rendering.
> In the PDF, rendering quality is not so good, transparency works,
> onload() is
> not reflected in results.
>
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04473 seconds