You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Ulf Sahlin <ul...@s2communications.se> on 2005/07/24 19:40:03 UTC

Losing session with fo2pdf and fo:instream-foreign-object SVGs

Hello!

I have a web-based data warehouse application, rendering nice PNG charts
using Cocoon Fins in a JBoss4 container. This is working great.

Now my problem: I want to be able to render my data warehouse content to
redistributable PDF (e.g. one would do 'Save As' and then e-mail the PDF
document to colleagues). I have no problems creating PDFs with dynamic text
content.

However, naturally I want to include my nice charts into the PDF as SVG's.
>From what I've read there's a <fo:instream-foreign-object> tag in FO-XSL for
this exact task. I do not want to use the related <fo:external-graphic>,
since my data warehouse is protected by Cocoon's auth and I recon
<fo:external-graphic> calls the resource at opening-time of the PDF and not
at creation-time. Cocoon-served dynamic SVGs is working great when calling
the SVG URL from Internet Explorer with a logged-in user (auth protected).

Including an already-rendered SVG, e.g. static and Apache-proxy-served, in
the FO this way works great - I'm seeing the resulting SVG chart in my PDF.
However, when I try to include the SVG chart with a dynamic reference (e.g.
Cocoon-served), the session is somehow lost when rendering/calling the
dynamic SVG. This is bad, since my data warehouse is protected by Cocoon's
auth and I'm reading certain IDs from session when getting the data in my
data warehouse.

I've tried to remove the Apache proxy and calling the chart generator
directly (port 8080), but I'm getting the same results. A quick solution
would be to send the IDs along in the dynamic SVG URL as a request
parameter, but this is not very nice programming from a security standpoint.

Any ideas why the session is lost? Is there some other way to call the
dynamic resource from FO, other than the way I do it, maintaining the
session? I read somewhere one could append the session ID to the SVG URL
(http://cocoonserver/project/dwh/image.svg;jsessionid=1234?...), is this a
solution? Haven't tried it yet, but it seems a pretty far-fetched solution.
Could be my entity referencing is a/the problem (see below).

----

Here's how I do the including (file "resources/test.fo"):

<?xml version="1.0"?> 
<!DOCTYPE root [
<!ENTITY svgimage SYSTEM
"http://cocoonserver/project/dwh/image.svg?param1=3&amp;param2=4">
]>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> 
   <fo:layout-master-set> 
      <fo:simple-page-master master-name="main"> 
      <fo:region-body/> 
   </fo:simple-page-master> 
   </fo:layout-master-set> 
   <fo:page-sequence master-reference="main"> 
      <fo:flow flow-name="xsl-region-body"> 
         <fo:block> 
 
<fo:instream-foreign-object>&svgimage;</fo:instream-foreign-object>
         </fo:block> 
      </fo:flow> 
   </fo:page-sequence> 
</fo:root> 

----

Here's a somewhat edited snippet of the project sitemap:

<map:match pattern="dwh/**">
  <map:act type="auth-protect">
    <map:parameter name="handler" value="dwhhandler"/>

    <map:match pattern="dwh/image.svg">
      <map:call resource="pipeline-chart-bar-svg"/>
    </map:match>

    <map:match pattern="dwh/test.pdf">
      <map:generate type="file" src="resources/test.fo"/>
      <map:call resource="serialize-pdf"/>
    </map:match>
...

----

Best regards,
   Ulf Sahlin



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


RE: Losing session with fo2pdf and fo:instream-foreign-object SVGs

Posted by Ulf Sahlin <ul...@s2communications.se>.
Hello and thank you for your fast reply!

Thanks for clarifying about the fo:external-graphic being embedded. I'll
look into the XInclude transformer, thanks for pointing it out!

Best regards,
    Ulf Sahlin
 

-----Original Message-----
From: J.Pietschmann [mailto:j3322ptm@yahoo.de] 
Sent: den 24 juli 2005 21:04
To: users@cocoon.apache.org
Subject: Re: Losing session with fo2pdf and fo:instream-foreign-object SVGs

Ulf Sahlin wrote:
> I do not want to use the related <fo:external-graphic>, since my data 
> warehouse is protected by Cocoon's auth and I recon 
> <fo:external-graphic> calls the resource at opening-time of the PDF 
> and not at creation-time.

That's incorrect, the graphic is complete embedded into the PDF.

> However, when I try to include the SVG chart with a dynamic reference
(e.g.
> Cocoon-served), the session is somehow lost when rendering/calling the 
> dynamic SVG.
...
> Any ideas why the session is lost? Is there some other way to call the 
> dynamic resource from FO, other than the way I do it, maintaining the 
> session?

It depends what you exactly do. If you really use
  fo:instream-foreign-object to embed the SVG content, you do so at the XSLT
level before it gets into the FO renderer. You can check for problems by
serializing to XML rather than PDF and inspect the result.

> <?xml version="1.0"?>
> <!DOCTYPE root [
> <!ENTITY svgimage SYSTEM
> "http://cocoonserver/project/dwh/image.svg?param1=3&amp;param2=4">
> ]>
...
> <fo:instream-foreign-object>&svgimage;</fo:instream-foreign-object>

Using entities to get content into an XML file is *not* a good idea for
several reasons, one reason being that the entity handler doesn't know
anything about your session.
You should use an xinclude transformer or aggregation combined with an
approriate XSLT to reshuffle the content.

J.Pietschmann


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org





---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Losing session with fo2pdf and fo:instream-foreign-object SVGs

Posted by "J.Pietschmann" <j3...@yahoo.de>.
Ulf Sahlin wrote:
> I do not want to use the related <fo:external-graphic>,
> since my data warehouse is protected by Cocoon's auth and I recon
> <fo:external-graphic> calls the resource at opening-time of the PDF and not
> at creation-time.

That's incorrect, the graphic is complete embedded into the PDF.

> However, when I try to include the SVG chart with a dynamic reference (e.g.
> Cocoon-served), the session is somehow lost when rendering/calling the
> dynamic SVG.
...
> Any ideas why the session is lost? Is there some other way to call the
> dynamic resource from FO, other than the way I do it, maintaining the
> session?

It depends what you exactly do. If you really use
  fo:instream-foreign-object to embed the SVG content, you do so at
the XSLT level before it gets into the FO renderer. You can check
for problems by serializing to XML rather than PDF and inspect the
result.

> <?xml version="1.0"?> 
> <!DOCTYPE root [
> <!ENTITY svgimage SYSTEM
> "http://cocoonserver/project/dwh/image.svg?param1=3&amp;param2=4">
> ]>
...
> <fo:instream-foreign-object>&svgimage;</fo:instream-foreign-object>

Using entities to get content into an XML file is *not* a good idea
for several reasons, one reason being that the entity handler doesn't
know anything about your session.
You should use an xinclude transformer or aggregation combined with
an approriate XSLT to reshuffle the content.

J.Pietschmann


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org