You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Robyp1 <ro...@hotmail.com> on 2011/05/17 09:57:29 UTC

problem resolve external image resource with fop

hi,

i have a problem using a fop in a web application. First of all,  this is
not only only a kind a web application but a maven web application with
others dependencies like libs or maven module (not web) linked. One kind of
this lib/maven module keep the source with embed a fop code for translate
xml into pdf using an xsl stylesheet. My problem is that the user request is
processed by a servlet. I try to use URIResolver with ServletContext and
"servlet-context:" for accessing external resource in xsl with
"<fo:external-graphic src="servlet-context:path
webapp/images/nameGifImage.gif">". This is work fine but i prefere that fop
access resource without serveletContext but with the ClassLoader without
placing images in a context web root. I try to place my images in a
application class-path where fop is embed but this not work. Anybody now how
can i solve my problem? How can find where fop external resource would be
place? 

Thank you very much

Roby
-- 
View this message in context: http://old.nabble.com/problem-resolve-external-image-resource-with-fop-tp31635640p31635640.html
Sent from the FOP - Users mailing list archive at Nabble.com.


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


RE: problem resolve external image resource with fop

Posted by Theresa Jayne Forster <th...@inbrand.co.uk>.
Hmmm 
I think you are talking about how we do it
We process contents of web pages from the web pulling in data etc from
remote sites and putting them into a template, 

A small example here (imagedataservlet returns xml containing the width and
height in pixels of an image)

<xsl:template name="crop-scale-image">
		<xsl:param name="content-width"/>
		<xsl:param name="content-height"/>
		<xsl:param name="imgurl"/>

		<xsl:variable name="imginfourl">
	
<xsl:text>http://www.example.com/ImageDataServlet-1.0/ImageDataServlet?imgsr
c=</xsl:text>
			<xsl:value-of select="$imgurl"/>
		</xsl:variable>
		<xsl:variable name="imginfo"
select="document($imginfourl)"/>
		<xsl:variable name="imgWidthmm"
select="$imginfo/imginfo/imgwidth div 3.779527559"/>
		<xsl:variable name="imgHeightmm"
select="$imginfo/imginfo/imgheight div 3.779527559"/>
		<xsl:variable name="xscale" select="$content-width div
$imgWidthmm"/>
		<xsl:variable name="yscale" select="$content-height div
$imgHeightmm"/>
		<xsl:variable name="scale">
			<xsl:choose>
				<xsl:when test="$xscale >= $yscale">
					<xsl:value-of select="$xscale"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="$yscale"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<xsl:choose>
			<xsl:when test="$yscale > $xscale">
				<fo:external-graphic
scaling-method="resample-any-method"
						height="{$content-height}mm"
						width="{$content-width}mm"
						src="{$imgurl}"
						content-x="0mm"
						content-y="0mm"
						content-width="{$imgWidthmm
* $scale}mm"
	
content-height="{$imgHeightmm * $scale}mm"
						clip="auto"
						movie="auto"
				/>
			</xsl:when>
			<xsl:otherwise >
				<fo:external-graphic
scaling-method="resample-any-method"
						height="{$content-height}mm"
						width="{$content-width}mm"
						src="{$imgurl}"
						content-x="0mm"
						content-y="0mm"
						content-width="{$imgWidthmm
* $scale}mm"
	
content-height="{$imgHeightmm * $scale}mm"
						clip="auto"
						movie="auto"
				/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>	

Kindest regards


Theresa Forster
Senior Software Developer 

-----Original Message-----
From: Robyp1 [mailto:robyp1@hotmail.com] 
Sent: 17 May 2011 08:57
To: fop-users@xmlgraphics.apache.org
Subject: problem resolve external image resource with fop


hi,

i have a problem using a fop in a web application. First of all,  this is
not only only a kind a web application but a maven web application with
others dependencies like libs or maven module (not web) linked. One kind of
this lib/maven module keep the source with embed a fop code for translate
xml into pdf using an xsl stylesheet. My problem is that the user request is
processed by a servlet. I try to use URIResolver with ServletContext and
"servlet-context:" for accessing external resource in xsl with
"<fo:external-graphic src="servlet-context:path
webapp/images/nameGifImage.gif">". This is work fine but i prefere that fop
access resource without serveletContext but with the ClassLoader without
placing images in a context web root. I try to place my images in a
application class-path where fop is embed but this not work. Anybody now how
can i solve my problem? How can find where fop external resource would be
place? 

Thank you very much

Roby
-- 
View this message in context:
http://old.nabble.com/problem-resolve-external-image-resource-with-fop-tp316
35640p31635640.html
Sent from the FOP - Users mailing list archive at Nabble.com.


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



-----
No virus found in this message.
Checked by AVG - www.avg.com
Version: 10.0.1325 / Virus Database: 1509/3644 - Release Date: 05/17/11



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


Re: problem resolve external image resource with fop

Posted by "aditi.singla" <ad...@gmail.com>.
Hi,

Can you please provide steps to create a new servlet and at what place we
should use "FopFactory.setURIResolver(URIResolver). " in
ApacheFOPWorker.java



--
View this message in context: http://apache-fop.1065347.n5.nabble.com/problem-resolve-external-image-resource-with-fop-tp4079p38063.html
Sent from the FOP - Users mailing list archive at Nabble.com.

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


Re: problem resolve external image resource with fop

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
Roby,
then don't use the ServletContextURIResolver and instead write your own
URIResolver which then can work exactly how you want it. You could
define your own "classpath:" URI scheme. You could copy FOP's
ServletContextURIResolver and adjust it to your liking. Then just set
your new URIResolver instead of the ServletContextURIResolver using
FopFactory.setURIResolver(URIResolver). That allows FOP to find your
images the way you want FOP to. HTH

On 17.05.2011 09:57:29 Robyp1 wrote:
> 
> hi,
> 
> i have a problem using a fop in a web application. First of all,  this is
> not only only a kind a web application but a maven web application with
> others dependencies like libs or maven module (not web) linked. One kind of
> this lib/maven module keep the source with embed a fop code for translate
> xml into pdf using an xsl stylesheet. My problem is that the user request is
> processed by a servlet. I try to use URIResolver with ServletContext and
> "servlet-context:" for accessing external resource in xsl with
> "<fo:external-graphic src="servlet-context:path
> webapp/images/nameGifImage.gif">". This is work fine but i prefere that fop
> access resource without serveletContext but with the ClassLoader without
> placing images in a context web root. I try to place my images in a
> application class-path where fop is embed but this not work. Anybody now how
> can i solve my problem? How can find where fop external resource would be
> place? 
> 
> Thank you very much
> 
> Roby
> -- 
> View this message in context: http://old.nabble.com/problem-resolve-external-image-resource-with-fop-tp31635640p31635640.html
> Sent from the FOP - Users mailing list archive at Nabble.com.
> 



Jeremias Maerki


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