[prev in list] [next in list] [prev in thread] [next in thread] 

List:       fop-user
Subject:    Re: Showing images in PDF embeded in a web app.
From:       Sunrita Bagchi Basu <sunrita.wrk () gmail ! com>
Date:       2016-03-29 11:57:25
Message-ID: CAOFXZSLwn83XZbeLk=VfuMtfJTy+Me42uootTUDQinsbyZXxcg () mail ! gmail ! com
[Download RAW message or body]

Hi Chris,

Thanks for reverting back. I have resolved this issue on my own.

Regards,
Sunrita


On Tue, Mar 29, 2016 at 4:32 PM, Chris Bowditch <bowditch_chris@hotmail.com>
wrote:

> Hi Sunrita,
>
> I note you've not yet received a reply to your questions. Please can you
> supply the FO File together with the errors observed as I'm not sure I
> follow the question about the image URL. Also can you paste the actual
> warning messages you get so we can advise you precisely as to cause and
> possible solution together with your fop.xconf file. Otherwise we'll just
> be guessing.
>
> Thanks,
>
> Chris
>
>
> On 12/03/2016 17:11, Sunrita Bagchi Basu wrote:
>
>> Hi,
>>
>> I am struggling to show images and data in PDF within a web application.
>> I could make the stand alone work easily. But in web it fails to get the
>> images.
>>
>> I have tried the following:
>>
>> Approach 1: [Here i tried using the ServletContextURIResolver to resolve
>> the images]
>>
>> URIResolver uriResolver = new ServletContextURIResolver(servletContext);
>> DefaultConfigurationBuilder cfgBuilder = new
>> DefaultConfigurationBuilder();
>> Configuration cfg =
>> cfgBuilder.build(GeneratePDFWithFOP.class.getResourceAsStream("/fop.xconf"));
>> ResourceResolver resolver = new ResourceResolver() {
>>             public OutputStream getOutputStream (
>>                                                  URI uri)
>>  throws IOException {
>>                 URL url = servletContext.getResource(uri.toASCIIString());
>>                 return url.openConnection().getOutputStream();
>>             }
>>
>>             public Resource getResource (
>>                                          URI uri)
>>                                                  throws IOException {
>>                 return new
>> Resource(servletContext.getResourceAsStream(uri.toASCIIString()));
>>             }
>>         };
>> FopFactoryBuilder builder = new FopFactoryBuilder(new File(".").toURI(),
>> resolver).setConfiguration(cfg);
>> final FopFactory fopFactory = builder.build();
>>
>> In the xsl for images I have put:
>>
>> <fo:external-graphic content-height="0.32in" scaling="non-uniform"
>> content-width="0.30in" src="url(servletcontext: /arrow-pdf-header.png)" />
>>
>> But this doesn't load the images.
>> SAX error show invalid URI for image. Though the same is accessible via
>> browser
>>
>> Approach 2: [Here i used the Local path, so the images are coming through
>> but the data is not getting printed]
>>
>> String appPath = servletContext.getRealPath("");
>> Configuration cfg = cfgBuilder.buildFromFile(new
>> File(appPath+"/WEB-INF/classes/fop.xconf"));
>> FopFactoryBuilder builder = new FopFactoryBuilder(new
>> File(appPath).toURI()).setConfiguration(cfg);
>> final FopFactory fopFactory = builder.build();
>>
>> In the xsl for images i have put:
>> <fo:external-graphic scaling="non-uniform" content-height="0.40625in"
>> content-width="0.40625in" src="url(/arrow-pdf-header.png)" />
>>
>> Though this one loads the images, the data fails to show up!. I also get
>> a few warning in the console such as table width was adjusted, and few
>> fonts were not found.
>>
>> Thanks,
>> Sunrita
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
>
>

[Attachment #3 (text/html)]

<div dir="ltr">Hi Chris,<div><br></div><div>Thanks for reverting back. I have \
resolved this issue on my \
own.</div><div><br></div><div>Regards,</div><div>Sunrita</div><div><br></div></div><div \
class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 29, 2016 at 4:32 PM, \
Chris Bowditch <span dir="ltr">&lt;<a href="mailto:bowditch_chris@hotmail.com" \
target="_blank">bowditch_chris@hotmail.com</a>&gt;</span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex">Hi Sunrita,<br> <br>
I note you&#39;ve not yet received a reply to your questions. Please can you supply \
the FO File together with the errors observed as I&#39;m not sure I follow the \
question about the image URL. Also can you paste the actual warning messages you get \
so we can advise you precisely as to cause and possible solution together with your \
fop.xconf file. Otherwise we&#39;ll just be guessing.<br> <br>
Thanks,<br>
<br>
Chris<div><div class="h5"><br>
<br>
On 12/03/2016 17:11, Sunrita Bagchi Basu wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"> Hi,<br>
<br>
I am struggling to show images and data in PDF within a web application.<br>
I could make the stand alone work easily. But in web it fails to get the images.<br>
<br>
I have tried the following:<br>
<br>
Approach 1: [Here i tried using the ServletContextURIResolver to resolve the \
images]<br> <br>
URIResolver uriResolver = new ServletContextURIResolver(servletContext);<br>
DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder();<br>
Configuration cfg = cfgBuilder.build(GeneratePDFWithFOP.class.getResourceAsStream(&quot;/fop.xconf&quot;));<br>
 ResourceResolver resolver = new ResourceResolver() {<br>
                  public OutputStream getOutputStream (<br>
                                                                          URI \
uri)<br>  throws IOException {<br>
                        URL url = \
servletContext.getResource(uri.toASCIIString());<br>  return \
url.openConnection().getOutputStream();<br>  }<br>
<br>
                  public Resource getResource (<br>
                                                              URI uri)<br>
                                                                          throws \
                IOException {<br>
                        return new \
Resource(servletContext.getResourceAsStream(uri.toASCIIString()));<br>  }<br>
            };<br>
FopFactoryBuilder builder = new FopFactoryBuilder(new File(&quot;.&quot;).toURI(), \
resolver).setConfiguration(cfg);<br> final FopFactory fopFactory = \
builder.build();<br> <br>
In the xsl for images I have put:<br>
<br>
&lt;fo:external-graphic content-height=&quot;0.32in&quot; \
scaling=&quot;non-uniform&quot; content-width=&quot;0.30in&quot; \
src=&quot;url(servletcontext: /arrow-pdf-header.png)&quot; /&gt;<br> <br>
But this doesn&#39;t load the images.<br>
SAX error show invalid URI for image. Though the same is accessible via browser<br>
<br>
Approach 2: [Here i used the Local path, so the images are coming through but the \
data is not getting printed]<br> <br>
String appPath = servletContext.getRealPath(&quot;&quot;);<br>
Configuration cfg = cfgBuilder.buildFromFile(new \
File(appPath+&quot;/WEB-INF/classes/fop.xconf&quot;));<br> FopFactoryBuilder builder \
= new FopFactoryBuilder(new File(appPath).toURI()).setConfiguration(cfg);<br> final \
FopFactory fopFactory = builder.build();<br> <br>
In the xsl for images i have put:<br>
&lt;fo:external-graphic scaling=&quot;non-uniform&quot; \
content-height=&quot;0.40625in&quot; content-width=&quot;0.40625in&quot; \
src=&quot;url(/arrow-pdf-header.png)&quot; /&gt;<br> <br>
Though this one loads the images, the data fails to show up!. I also get a few \
warning in the console such as table width was adjusted, and few fonts were not \
found.<br> <br>
Thanks,<br>
Sunrita<br>
</blockquote>
<br>
<br></div></div>
---------------------------------------------------------------------<br>
To unsubscribe, e-mail: <a href="mailto:fop-users-unsubscribe@xmlgraphics.apache.org" \
target="_blank">fop-users-unsubscribe@xmlgraphics.apache.org</a><br> For additional \
commands, e-mail: <a href="mailto:fop-users-help@xmlgraphics.apache.org" \
target="_blank">fop-users-help@xmlgraphics.apache.org</a><br> <br>
</blockquote></div><br></div>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic