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 Nathan Maves <Na...@Sun.COM> on 2005/06/10 22:18:32 UTC
Using images from servlets
I have searched and searched though that alias archives but I could
not find a simple answer to this problem.
I have a servlet (struts) that returns a generated chart.
What is the best/simplest way to get this into a pdf?
<fo:block>
<fo:external-graphic src="url(http://localhost:8080/
ScoreCard/View/MetricChart.do)"/>
</fo:block>
[ERROR] Could not load external SVG: Premature end of file.
[ERROR] Error while creating area : No ImageReader for this type of
image (http://localhost:8080/ScoreCard/View/MetricChart.do)
Nathan
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
Re: Using images from servlets
Posted by "J.Pietschmann" <j3...@yahoo.de>.
Nathan Maves wrote:
> OT but
> is there an easy way to pass a variable to the xsl without adding it to
> the xml, i.e. the url with the added request parameters?
Check XSLT parameters (xsl:param):
http://www.w3.org/TR/xslt#variables
http://xml.apache.org/fop/servlets.html#xslt
J.Pietschmann
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
Re: Using images from servlets
Posted by Nathan Maves <Na...@Sun.COM>.
I think that you hit the nail on the head. The servlet uses session
variables. I can get around this an will try it out on Monday. OT
but is there an easy way to pass a variable to the xsl without adding
it to the xml, i.e. the url with the added request parameters?
Nathan
On Jun 11, 2005, at 2:17 PM, J.Pietschmann wrote:
> Nathan Maves wrote:
>
>> I have a servlet (struts) that returns a generated chart.
>> What is the best/simplest way to get this into a pdf?
>>
> ...
>
>> <fo:external-graphic src="url(http://localhost:
>> 8080/ ScoreCard/View/MetricChart.do)"/>
>>
>
> In general, this should work.
> ...
>
>> [ERROR] Could not load external SVG: Premature end of file.
>> [ERROR] Error while creating area : No ImageReader for this type
>> of image (http://localhost:8080/ScoreCard/View/MetricChart.do)
>>
>
> The image reader was't able to determine the image type,
> or got some other problem. Check the instructions in the FAQ
> http://xml.apache.org/fop/faq.html#graphic-not-displayed
> in particular:
> - Check whether you can display the image in a browser
> - Download a generated image into a file and try to use it
> from this file (i.e. check whether the problem is with the
> content of the image itself or whether it has somethiing to
> do with being loaded via HTTP).
> - If the problem is the image itself, try to open it in another
> graphics viewer in order to get more information about what
> might be wrong
> - If the problem is with image delivery, well, fix them. A missing
> session cookie is a likely candidate for the cause.
>
> J.Pietschmann
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
Re: Using images from servlets
Posted by "J.Pietschmann" <j3...@yahoo.de>.
Nathan Maves wrote:
> [ERROR] Could not load external SVG: Root element does not match that
> requested:
> Requested: svg
> Found: script
I suspect you use some sort script controlled of redirection, presumably
for a login, or there's still a cookie or request parameter problem. You
shouldn't see this kind of message if you server a JPEG.
Try to download the image using a command line program like wget (not a
browser), turn off following redirects, and examine what you get.
J.Pietschmann
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
Re: Using images from servlets
Posted by Nathan Maves <Na...@Sun.COM>.
While I am at it here is the servlet code.
JFreeChart chart = chartService.getTimePeriodChart(metric,
frequencyType);
response.setContentType("image/jpeg");
OutputStream out = response.getOutputStream();
ChartUtilities.writeChartAsJPEG(out, chart, 500, 300);
out.flush();
On Jun 21, 2005, at 10:54 AM, Nathan Maves wrote:
> if it is any use here is the error logs....
>
> [ERROR] Logger not set
> [INFO] building formatting object tree
> [WARNING] Screen logger not set - Using ConsoleLogger.
> [INFO] setting up fonts
> [INFO] [1]
> [ERROR] Could not load external SVG: Root element does not match
> that requested:
> Requested: svg
> Found: script
> [ERROR] Error while creating area : No ImageReader for this type of
> image (http://localhost:9044/Scorecard/View/MetricChart.do?
> metricId=5489&frequencyId=4)
> [INFO] Parsing of document complete, stopping renderer
>
> Why are the references to svg when I am not using it?
>
>
> Nathan
>
> On Jun 21, 2005, at 10:35 AM, Nathan Maves wrote:
>
>
>> J,
>>
>> I was able to remove all refrencies to the session from my
>> servlet. I was also able to view the image by calling the servlet
>> directly in a browser. Last of all I was able to save this viewed
>> image to a file. I then used it directly in a pdf and it worked.
>> Why would FOP be able to determine the image type from a file and
>> not from my servlet?
>>
>> Nathan
>>
>> On Jun 11, 2005, at 2:17 PM, J.Pietschmann wrote:
>>
>>
>>
>>> Nathan Maves wrote:
>>>
>>>
>>>
>>>> I have a servlet (struts) that returns a generated chart.
>>>> What is the best/simplest way to get this into a pdf?
>>>>
>>>>
>>>>
>>> ...
>>>
>>>
>>>
>>>> <fo:external-graphic src="url(http://localhost:
>>>> 8080/ ScoreCard/View/MetricChart.do)"/>
>>>>
>>>>
>>>>
>>>
>>> In general, this should work.
>>> ...
>>>
>>>
>>>
>>>> [ERROR] Could not load external SVG: Premature end of file.
>>>> [ERROR] Error while creating area : No ImageReader for this type
>>>> of image (http://localhost:8080/ScoreCard/View/MetricChart.do)
>>>>
>>>>
>>>>
>>>
>>> The image reader was't able to determine the image type,
>>> or got some other problem. Check the instructions in the FAQ
>>> http://xml.apache.org/fop/faq.html#graphic-not-displayed
>>> in particular:
>>> - Check whether you can display the image in a browser
>>> - Download a generated image into a file and try to use it
>>> from this file (i.e. check whether the problem is with the
>>> content of the image itself or whether it has somethiing to
>>> do with being loaded via HTTP).
>>> - If the problem is the image itself, try to open it in another
>>> graphics viewer in order to get more information about what
>>> might be wrong
>>> - If the problem is with image delivery, well, fix them. A missing
>>> session cookie is a likely candidate for the cause.
>>>
>>> J.Pietschmann
>>>
>>> --------------------------------------------------------------------
>>> -
>>> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
>>> For additional commands, e-mail: fop-users-
>>> help@xmlgraphics.apache.org
>>>
>>>
>>>
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
>> For additional commands, e-mail: fop-users-
>> help@xmlgraphics.apache.org
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
Re: Using images from servlets
Posted by Nathan Maves <Na...@Sun.COM>.
if it is any use here is the error logs....
[ERROR] Logger not set
[INFO] building formatting object tree
[WARNING] Screen logger not set - Using ConsoleLogger.
[INFO] setting up fonts
[INFO] [1]
[ERROR] Could not load external SVG: Root element does not match that
requested:
Requested: svg
Found: script
[ERROR] Error while creating area : No ImageReader for this type of
image (http://localhost:9044/Scorecard/View/MetricChart.do?
metricId=5489&frequencyId=4)
[INFO] Parsing of document complete, stopping renderer
Why are the references to svg when I am not using it?
Nathan
On Jun 21, 2005, at 10:35 AM, Nathan Maves wrote:
> J,
>
> I was able to remove all refrencies to the session from my
> servlet. I was also able to view the image by calling the servlet
> directly in a browser. Last of all I was able to save this viewed
> image to a file. I then used it directly in a pdf and it worked.
> Why would FOP be able to determine the image type from a file and
> not from my servlet?
>
> Nathan
>
> On Jun 11, 2005, at 2:17 PM, J.Pietschmann wrote:
>
>
>> Nathan Maves wrote:
>>
>>
>>> I have a servlet (struts) that returns a generated chart.
>>> What is the best/simplest way to get this into a pdf?
>>>
>>>
>> ...
>>
>>
>>> <fo:external-graphic src="url(http://localhost:
>>> 8080/ ScoreCard/View/MetricChart.do)"/>
>>>
>>>
>>
>> In general, this should work.
>> ...
>>
>>
>>> [ERROR] Could not load external SVG: Premature end of file.
>>> [ERROR] Error while creating area : No ImageReader for this type
>>> of image (http://localhost:8080/ScoreCard/View/MetricChart.do)
>>>
>>>
>>
>> The image reader was't able to determine the image type,
>> or got some other problem. Check the instructions in the FAQ
>> http://xml.apache.org/fop/faq.html#graphic-not-displayed
>> in particular:
>> - Check whether you can display the image in a browser
>> - Download a generated image into a file and try to use it
>> from this file (i.e. check whether the problem is with the
>> content of the image itself or whether it has somethiing to
>> do with being loaded via HTTP).
>> - If the problem is the image itself, try to open it in another
>> graphics viewer in order to get more information about what
>> might be wrong
>> - If the problem is with image delivery, well, fix them. A missing
>> session cookie is a likely candidate for the cause.
>>
>> J.Pietschmann
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
>> For additional commands, e-mail: fop-users-
>> help@xmlgraphics.apache.org
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
Re: Using images from servlets
Posted by Nathan Maves <Na...@Sun.COM>.
J,
I was able to remove all refrencies to the session from my servlet.
I was also able to view the image by calling the servlet directly in
a browser. Last of all I was able to save this viewed image to a
file. I then used it directly in a pdf and it worked. Why would FOP
be able to determine the image type from a file and not from my servlet?
Nathan
On Jun 11, 2005, at 2:17 PM, J.Pietschmann wrote:
> Nathan Maves wrote:
>
>> I have a servlet (struts) that returns a generated chart.
>> What is the best/simplest way to get this into a pdf?
>>
> ...
>
>> <fo:external-graphic src="url(http://localhost:
>> 8080/ ScoreCard/View/MetricChart.do)"/>
>>
>
> In general, this should work.
> ...
>
>> [ERROR] Could not load external SVG: Premature end of file.
>> [ERROR] Error while creating area : No ImageReader for this type
>> of image (http://localhost:8080/ScoreCard/View/MetricChart.do)
>>
>
> The image reader was't able to determine the image type,
> or got some other problem. Check the instructions in the FAQ
> http://xml.apache.org/fop/faq.html#graphic-not-displayed
> in particular:
> - Check whether you can display the image in a browser
> - Download a generated image into a file and try to use it
> from this file (i.e. check whether the problem is with the
> content of the image itself or whether it has somethiing to
> do with being loaded via HTTP).
> - If the problem is the image itself, try to open it in another
> graphics viewer in order to get more information about what
> might be wrong
> - If the problem is with image delivery, well, fix them. A missing
> session cookie is a likely candidate for the cause.
>
> J.Pietschmann
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
Re: Using images from servlets
Posted by "J.Pietschmann" <j3...@yahoo.de>.
Nathan Maves wrote:
> I have a servlet (struts) that returns a generated chart.
> What is the best/simplest way to get this into a pdf?
...
> <fo:external-graphic src="url(http://localhost:8080/
> ScoreCard/View/MetricChart.do)"/>
In general, this should work.
...
> [ERROR] Could not load external SVG: Premature end of file.
> [ERROR] Error while creating area : No ImageReader for this type of
> image (http://localhost:8080/ScoreCard/View/MetricChart.do)
The image reader was't able to determine the image type,
or got some other problem. Check the instructions in the FAQ
http://xml.apache.org/fop/faq.html#graphic-not-displayed
in particular:
- Check whether you can display the image in a browser
- Download a generated image into a file and try to use it
from this file (i.e. check whether the problem is with the
content of the image itself or whether it has somethiing to
do with being loaded via HTTP).
- If the problem is the image itself, try to open it in another
graphics viewer in order to get more information about what
might be wrong
- If the problem is with image delivery, well, fix them. A missing
session cookie is a likely candidate for the cause.
J.Pietschmann
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org