You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by 32...@gmail.com on 2006/07/20 22:03:52 UTC

Re: PDF: external-graphic & absolute pat

Hello,

content-width and -height are not supported for FOP 0.20.5, as seen on this
page
http://xmlgraphics.apache.org/fop/compliance.html#fo-property-content-width
and yes, width / height are the way to go...but not both at the same time
since that would destroy the aspect ratio of your images, if I recall
correctly.
Marco

2006/7/20, Andrew Stevens <at...@hotmail.com>:
>
> >From: "Omar Adobati" <om...@gmail.com>
> >Date: Thu, 20 Jul 2006 10:40:09 +0200
> >
> >Good Morning,
> >
> >  What is the reason I need to use the full path of an image I want to
> >display into a PDF generated file?
>
> I believe it's a limitation of Apache FOP.  I was recently working on a
> (non-Cocoon) servlet that used XSL/FOP to generate a PDF, and had to use
> the
> full URLs in that also.
>
> >This way to use images kills
> >portability, Not always the code one develop will runs on the same
> >machine he use to write the code...
>
> I worked around that by passing in the host/port/context (read from the
> request object) as a parameter to the XSL transformation.  You could do
> much
> the same with Cocoon using something like
> <map:transform type="xsl" src="whatever.xsl">
>    <map:parameter name="baseUrl"
>
> value="http://{request:serverName}:{request:serverPort}{request:contextPath}"/>
> in your sitemap and
> <xsl:param name="baseUrl"/>
> ...
> <fo:external-graphic src="{$baseUrl}/images/my_logo.png"/>
> in the XSLT stylesheet.  This avoids having to hard code the server in
> your
> XSL.
>
> >And, more, how to resize the image? I have tried to use content-height
> >and content-weight attributes, but they seems to not work... any
> >suggestion (I know I could resize it with an image editor software,
> >but I'd like to not do this for many reasons).
>
> I can't remember how I ended up that way, but nearly all the
> external-graphic elements in my XSL were using both width and
> content-width
> attributes (I let it scale the height automatically to preserve the aspect
> ration).  I have a feeling that when I only used content-width it didn't
> work, or maybe it was the other way round.  The other external-graphic in
> that file has only a height attribute, so perhaps it's height and width
> that
> are needed to get it to work properly rather than content-height &
> content-width?
>
>
> Andrew.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>

Re: PDF: external-graphic & absolute pat

Posted by Andrew Stevens <at...@hotmail.com>.
>From: "Omar Adobati" <om...@gmail.com>
>Date: Fri, 21 Jul 2006 12:03:05 +0200
>
>> > I worked around that by passing in the host/port/context (read from the
>> > request object) as a parameter to the XSL transformation.  You could do
>>much
>> > the same with Cocoon using something like
>> > <map:transform type="xsl" src="whatever.xsl">
>> >    <map:parameter name="baseUrl"
>> >
>>value="http://{request:serverName}:{request:serverPort}{request:contextPath}"/>
>> > in your sitemap and
>> > <xsl:param name="baseUrl"/>
>> > ...
>> > <fo:external-graphic
>>src="{$baseUrl}/images/my_logo.png"/>
>> > in the XSLT stylesheet.  This avoids having to hard code the server in
>>your
>> > XSL.
>
>I tried to do this into my sitemap.xmap
>
>    <map:match pattern="*.jpg">
>      <map:parameter name="baseUrl"
>value="http://{request:serverName}:{request:serverPort}{request:contextPath}"/>
>      <map:read mime-type="image/jpg" src="img/{1}.jpg"/>
>    </map:match>

Wrong place.  The baseUrl is to be passed into the XSL transformation, the 
reader that's returning the bitmap doesn't need to know it.  And besides, 
even if you had a reader that e.g. embedded the URL in an EXIF field in the 
JPEG, you'd have to put the parameter inside the <map:read> element rather 
than inside the <map:match>.  You'd only need it there if the wildcard URI 
matcher were written to expect a parameter of that name.

>>and I tried to put it also here:
>
><map:match pattern="*.html">
>   	  <map:generate src="xml/{1}.xml"/>
>	  <map:transform src="xsl/xml2html.xsl"/>
>	  <map:serialize type="html"/>
>	</map:match>

You need to use
	  <map:transform src="xsl/xml2html.xsl">
	      <map:parameter name="baseUrl" 
value="http://{request:serverName}:{request:serverPort}{request:contextPath}"/>
	  </map:transform>
and the transformer will then pass the parameter to the XSL transformation 
engine, which will allow you to access it within xml2html.xsl using a 
top-level (at the start, outside any xsl:template) <xsl:param 
name="baseUrl"/> element.  Then, when you output the external-graphic 
elements, use <fo:external-graphic src="{$baseUrl}/whatever.jpg"/>

>but seems that baseUrl is a blank string... so it doesn't work for me...
>could you suggest me why?
>IT could depends by the fact that I'm actually running cocoon in Tomcat?

The container shouldn't matter, I've used this technique running in Tomcat 
on my own machine, then deployed the same war to Websphere.  It worked the 
same in both.


Andrew.



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


Re: PDF: external-graphic & absolute pat

Posted by Omar Adobati <om...@gmail.com>.
> > I worked around that by passing in the host/port/context (read from the
> > request object) as a parameter to the XSL transformation.  You could do
> much
> > the same with Cocoon using something like
> > <map:transform type="xsl" src="whatever.xsl">
> >    <map:parameter name="baseUrl"
> >
> value="http://{request:serverName}:{request:serverPort}{request:contextPath}"/>
> > in your sitemap and
> > <xsl:param name="baseUrl"/>
> > ...
> > <fo:external-graphic
> src="{$baseUrl}/images/my_logo.png"/>
> > in the XSLT stylesheet.  This avoids having to hard code the server in
> your
> > XSL.

I tried to do this into my sitemap.xmap

    <map:match pattern="*.jpg">
      <map:parameter name="baseUrl"
value="http://{request:serverName}:{request:serverPort}{request:contextPath}"/>
      <map:read mime-type="image/jpg" src="img/{1}.jpg"/>
    </map:match>

and I tried to put it also here:

<map:match pattern="*.html">	  	
   	  <map:generate src="xml/{1}.xml"/>
	  <map:transform src="xsl/xml2html.xsl"/>
	  <map:serialize type="html"/>		
	</map:match>

but seems that baseUrl is a blank string... so it doesn't work for me...
could you suggest me why?
IT could depends by the fact that I'm actually running cocoon in Tomcat?

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