Re: FO + External bitmap graphics -> FOP -> SVG

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: FO + External bitmap graphics -> FOP -> SVG

Daniel Noll-4
Jeremias Maerki wrote:

>Don't be shy! This is actually quite easy. It just took the following
>lines to hack that missing feature in. Just place the code snippet below
>in SVGRenderer in the method renderImageArea() right after the commented
>call to graphics.drawImage().
>  
>

You're right, that seems to work fairly well for our simple case.  I
just had no idea how the renderer / SVG stuff stuck together.

But actually, I found another way which seems to require less effort on
the part of FOP.  Since we're including Batik for other features in our
app, we already have access to Batik's SVGGraphics2D class which
implements an AWT graphics context that "paints" to SVG.

I can use the AWTRenderer, and "print" each page directly into an SVG
file, which people at work seemed to prefer anyway.  And AWTRenderer
seems much more mature, as it worked flawlessly (a nearby observer
couldn't tell the quality difference between the SVG file opened in
Illustrator and the equivalent PDF file opened in Adobe Reader.)

Bonus advantage: our code is now more or less identical (it differs in
how the graphics context is created) whether we're rendering to SVG or TIFF.

I was getting to thinking how the SVGRenderer could even be implemented
while reducing duplication of code, by delegating to the AWTRenderer.  
I'm sure there must be a little quality degradation by doing so, but I
can't tell from our simple use cases. :-)

Daniel

--
Daniel Noll

NUIX Pty Ltd
Level 8, 143 York Street, Sydney 2000
Phone: (02) 9283 9010
Fax:   (02) 9283 9020

This message is intended only for the named recipient. If you are not
the intended recipient you are notified that disclosing, copying,
distributing or taking any action in reliance on the contents of this
message or attachment is strictly prohibited.


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: FO + External bitmap graphics -> FOP -> SVG

Jeremias Maerki
I'm glad you found a good solution. You're idea might prove useful to
the redesign since we already have someone who is working to bring the
AWT/Java2D-Renderer up to date. We can handle the SVG part like that.

For SVG I don't think there would be a quality degradation. The
SVGRenderer is not very sophisticated so it won't hurt there. It's
something else for the PDF and PS renderer where we would surely have a
quality (or rather feature) degradation were we to use a Java2D/AWT
approach.

On 09.05.2005 03:03:12 Daniel Noll wrote:

> Jeremias Maerki wrote:
>
> >Don't be shy! This is actually quite easy. It just took the following
> >lines to hack that missing feature in. Just place the code snippet below
> >in SVGRenderer in the method renderImageArea() right after the commented
> >call to graphics.drawImage().
> >  
> >
>
> You're right, that seems to work fairly well for our simple case.  I
> just had no idea how the renderer / SVG stuff stuck together.
>
> But actually, I found another way which seems to require less effort on
> the part of FOP.  Since we're including Batik for other features in our
> app, we already have access to Batik's SVGGraphics2D class which
> implements an AWT graphics context that "paints" to SVG.
>
> I can use the AWTRenderer, and "print" each page directly into an SVG
> file, which people at work seemed to prefer anyway.  And AWTRenderer
> seems much more mature, as it worked flawlessly (a nearby observer
> couldn't tell the quality difference between the SVG file opened in
> Illustrator and the equivalent PDF file opened in Adobe Reader.)
>
> Bonus advantage: our code is now more or less identical (it differs in
> how the graphics context is created) whether we're rendering to SVG or TIFF.
>
> I was getting to thinking how the SVGRenderer could even be implemented
> while reducing duplication of code, by delegating to the AWTRenderer.  
> I'm sure there must be a little quality degradation by doing so, but I
> can't tell from our simple use cases. :-)



Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

How to prevent SVG Image from caching

Amita Rathore

I am using data scheme to insert an image. like this :

<fo:instream-foreign-object>
   <svg:svg xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="542px" height="506px">
   <svg:image width="64" height="48" xlink:href="SRC="data:image/gif;base64,1QMMA..." />
   </svg:svg>
</fo:instream-foreign-object>

The image gets cached and the same image is displayed even after I  change the value for xlink:href.

I am resetting the cache also using :org.apache.fop.image.FopImageFactory.resetCache();
       
What should be done to avoid cachig of images. Thanks.        
Reply | Threaded
Open this post in threaded view
|

SV: How to prevent SVG Image from caching

lars.bjerges

If you´re using (at least) 0.20.5 you can call:

org.apache.fop.image.FopImageFactory.resetCache()

 

Hälsningar

 

Lars Bjerges

Team Verktyg

* FöreningsSparbanken IT

105 34 Stockholm

( +46 (0)8 58 59 43 45

( +46 (0)70 95 27 774

-----Ursprungligt meddelande-----
Från: Amita Rathore [mailto:[hidden email]]
Skickat: den 10 maj 2005 06:16
Till: [hidden email]
Ämne: How to prevent SVG Image from caching

 


I am using data scheme to insert an image. like this :

<fo:instream-foreign-object>
   <svg:svg xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="542px" height="506px">
   <svg:image width="64" height="48" xlink:href="SRC="data:image/gif;base64,1QMMA..." />
   </svg:svg>
</fo:instream-foreign-object>

The image gets cached and the same image is displayed even after I  change the value for xlink:href.

I am resetting the cache also using :org.apache.fop.image.FopImageFactory.resetCache();
       
What should be done to avoid cachig of images. Thanks.        

Reply | Threaded
Open this post in threaded view
|

Re: SV: How to prevent SVG Image from caching

Amita Rathore

I am calling resetCache(), snippet here :

                        org.apache.fop.image.FopImageFactory.resetCache();
                        org.apache.fop.apps.Driver driver2 = null;
                        driver2 = new org.apache.fop.apps.Driver();
                        driver2.reset();




<[hidden email]>

05/10/2005 10:44 AM

Please respond to
fop-users

To
<[hidden email]>
cc
Subject
SV: How to prevent SVG Image from caching





If you´re using (at least) 0.20.5 you can call:
org.apache.fop.image.FopImageFactory.resetCache()
 
Hälsningar
 
Lars Bjerges
Team Verktyg
* FöreningsSparbanken IT
105 34 Stockholm
( +46 (0)8 58 59 43 45
( +46 (0)70 95 27 774
-----Ursprungligt meddelande-----
Från:
Amita Rathore [mailto:[hidden email]]
Skickat:
den 10 maj 2005 06:16
Till:
[hidden email]
Ämne:
How to prevent SVG Image from caching

 

I am using data scheme to insert an image. like this :


<fo:instream-foreign-object>

  <svg:svg xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="542px" height="506px">

  <svg:image width="64" height="48" xlink:href="SRC="data:image/gif;base64,1QMMA..." />

  </svg:svg>

</fo:instream-foreign-object>


The image gets cached and the same image is displayed even after I  change the value for xlink:href.


I am resetting the cache also using :org.apache.fop.image.FopImageFactory.resetCache();

       
What should be done to avoid cachig of images. Thanks.        

Reply | Threaded
Open this post in threaded view
|

Re: How to prevent SVG Image from caching

Chris Bowditch
In reply to this post by Amita Rathore
Amita Rathore wrote:

>
> I am using data scheme to insert an image. like this :
>
> <fo:instream-foreign-object>
>    <svg:svg xmlns:svg="http://www.w3.org/2000/svg"
> xmlns:xlink="http://www.w3.org/1999/xlink" width="542px" height="506px">
>    <svg:image width="64" height="48"
> xlink:href="SRC="data:image/gif;base64,1QMMA..." />
>    </svg:svg>
> </fo:instream-foreign-object>

Well I believe the problem is that the image is inside the SVG and therefore
handled by Batik rather than FOP. Not sure how you can tell Batik not to cache
the images. Perhaps some of the other committers can help.

Chris


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: How to prevent SVG Image from caching

Amita Rathore

Thanks Chris,

Is there any way I can include the image without using svg ?
Or I should put it as - How to use the data scheme with FOP ?



Chris Bowditch <[hidden email]>

05/10/2005 01:52 PM

Please respond to
fop-users

To
[hidden email]
cc
Subject
Re: How to prevent SVG Image from caching





Amita Rathore wrote:

>
> I am using data scheme to insert an image. like this :
>
> <fo:instream-foreign-object>
>    <svg:svg xmlns:svg="http://www.w3.org/2000/svg"
> xmlns:xlink="http://www.w3.org/1999/xlink" width="542px" height="506px">
>    <svg:image width="64" height="48"
> xlink:href="SRC="data:image/gif;base64,1QMMA..." />
>    </svg:svg>
> </fo:instream-foreign-object>

Well I believe the problem is that the image is inside the SVG and therefore
handled by Batik rather than FOP. Not sure how you can tell Batik not to cache
the images. Perhaps some of the other committers can help.

Chris


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: How to prevent SVG Image from caching

Jeremias Maerki
You need an RFC2397 protocol handler for that. You can find at least one
in the mailing list archives:
http://marc.theaimsgroup.com/?l=fop-user&w=2&r=1&s=RFC2397&q=b

On 10.05.2005 10:32:52 Amita Rathore wrote:
> Thanks Chris,
>
> Is there any way I can include the image without using svg ?
> Or I should put it as - How to use the data scheme with FOP ?



Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: How to prevent SVG Image from caching

Amita Rathore

I followed your steps and its not working
I get exception  "No ImageReader for this type of image (data:image/jpeg;base64,lQA"

In my xsl I am writing :
<fo:block>
        <fo:external-graphic src="url(data:image/jpeg;base64,lQAm..)" height="8cm" width="7cm" />
</fo:block>

Am I missing something ?



Jeremias Maerki <[hidden email]>

05/10/2005 03:08 PM

Please respond to
fop-users

To
[hidden email]
cc
Subject
Re: How to prevent SVG Image from caching





You need an RFC2397 protocol handler for that. You can find at least one
in the mailing list archives:
http://marc.theaimsgroup.com/?l=fop-user&w=2&r=1&s=RFC2397&q=b

On 10.05.2005 10:32:52 Amita Rathore wrote:
> Thanks Chris,
>
> Is there any way I can include the image without using svg ?
> Or I should put it as - How to use the data scheme with FOP ?



Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: How to prevent SVG Image from caching

Jeremias Maerki
No idea. The error message would indicate that the image contained in
the URL is not a valid JPEG file. But maybe there's something else
that's not right.

Can you send me your FO file to test?

On 12.05.2005 08:27:58 Amita Rathore wrote:

> I followed your steps and its not working
> I get exception  "No ImageReader for this type of image
> (data:image/jpeg;base64,lQA"
>
> In my xsl I am writing :
> <fo:block>
>         <fo:external-graphic src="url(data:image/jpeg;base64,lQAm..)"
> height="8cm" width="7cm" />
> </fo:block>
>
> Am I missing something ?


Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: How to prevent SVG Image from caching

Amita Rathore

You are right. I tried again and the sample image displays.
Seems some problem with my image only.
I am getting it as a notesbitmap from remote system in a xml.
Do you know any way with which I can verify if I am getting proper data.

Thanks a ton for your help  :-)



Jeremias Maerki <[hidden email]>

05/12/2005 12:40 PM

Please respond to
fop-users

To
[hidden email]
cc
Subject
Re: How to prevent SVG Image from caching





No idea. The error message would indicate that the image contained in
the URL is not a valid JPEG file. But maybe there's something else
that's not right.

Can you send me your FO file to test?

Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: How to prevent SVG Image from caching

Jeremias Maerki
You're welcome. The only way to verify is to decode the URL and save the
extracted data to a file which will then be a normal JPEG file (or
whatever).

To do this, just create a small program which builds a java.net.URL
instance from the data URL, then get the InputStream by calling
URL.openStream() and read and copy all the data to a FileOutputStream.

On 12.05.2005 09:58:35 Amita Rathore wrote:

> You are right. I tried again and the sample image displays.
> Seems some problem with my image only.
> I am getting it as a notesbitmap from remote system in a xml.
> Do you know any way with which I can verify if I am getting proper data.
>
> Thanks a ton for your help  :-)
>
>
>
>
> Jeremias Maerki <[hidden email]>
> 05/12/2005 12:40 PM
> Please respond to
> fop-users
>
>
> To
> [hidden email]
> cc
>
> Subject
> Re: How to prevent SVG Image from caching
>
>
>
>
>
>
> No idea. The error message would indicate that the image contained in
> the URL is not a valid JPEG file. But maybe there's something else
> that's not right.
>
> Can you send me your FO file to test?
>
> Jeremias Maerki
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>



Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: How to prevent SVG Image from caching

Daniel Noll-4
Jeremias Maerki wrote:

>You're welcome. The only way to verify is to decode the URL and save the
>extracted data to a file which will then be a normal JPEG file (or
>whatever).
>
>To do this, just create a small program which builds a java.net.URL
>instance from the data URL, then get the InputStream by calling
>URL.openStream() and read and copy all the data to a FileOutputStream.
>  
>
Another way would be to pass the result of URL.openStream() to
ImageIO.read(InputStream).  If it throws an error, you can assume the
image isn't valid, and that it probably won't work in FOP either.

You could use this to discover whether an image will break before
starting FOP, and without needing user intervention.

Daniel

--
Daniel Noll

NUIX Pty Ltd
Level 8, 143 York Street, Sydney 2000
Phone: (02) 9283 9010
Fax:   (02) 9283 9020

This message is intended only for the named recipient. If you are not
the intended recipient you are notified that disclosing, copying,
distributing or taking any action in reliance on the contents of this
message or attachment is strictly prohibited.


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]