Re: Showing images in PDF embeded in a web app.

Sunrita Bagchi Basu <[email protected]>
Newsgroups gmane.text.xml.fop.user
Message-ID <CAOFXZSKKnz_Q+2ZCQAadeNGjdx66hzK3TT4yS+bfjW=Zxb1Obw@mail.gmail.com>
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 <[email protected]>
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: [email protected]
> For additional commands, e-mail: [email protected]
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.