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 Malcolm Murphy <gm...@malcolm.murphy.name> on 2011/02/03 18:14:27 UTC

Data URI handling by fox:external-document

Hi,

I've successfully used the Data URI format with the 
Fop's external-graphic element. It works perfectly in the form:-

<fo:external-graphic src="url('data:image/gif;base64,encodedblahbl')"/>

However if I try the following (after declaring the fox extensions
xmlns):

<fox:external-document
content-type="pdf"
src="url('data:application/pdf;base64,encodedblahbl')"/>

this raises a fop exception - missing parameter src.

I then tried the form:

<fox:external-document 
content-type="pdf"
src="data:application/pdf;base64,encodedblahbl"/>

and this gives java.io exceptions in pdfbox. 

I also tried all the above without the content-type parameter with no
effect. I've also tried the all the above with the latest stable and
trunk versions of Fop and PDF Image.

Additionally the valid file uri construction between the two elements is
also different. The external-graphic accepts src="url('file://C:/path')"
where as the external-document seems to only accept
src="file://C:/path".

Questions:
Is this the correct behaviour? Or do I have an environmental problem?

If its not correct....

1) Can the external-document element take a Data URI as the src
parameter by some simple change?

2) More generally it possible to have the two elements handle the uri
resolution in the same way?

Many Thanks,

Malcolm





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


Re: Data URI handling by fox:external-document

Posted by Andreas Delmelle <an...@telenet.be>.
On 03 Feb 2011, at 18:14, Malcolm Murphy wrote:

Hi Malcolm

> Questions:
> Is this the correct behaviour? Or do I have an environmental problem?

No and no. It does not seem like correct behavior, and at this point, I do not suspect an issue in your environment.

> If its not correct....
> 
> 1) Can the external-document element take a Data URI as the src
> parameter by some simple change?

That I cannot immediately judge. However, it definitely does not seem like this possibility was taken into account when developing the extension.

> 2) More generally it possible to have the two elements handle the uri
> resolution in the same way?

Ideally, that should be the case. This I could already trace down. The code that constructs the image from the URI in the case of fo:external-graphic strips off the url() function call before handing the URI over to the ImageManager, while fox:external-document passes the specified value, untreated.

The fix for part 2) is a simple modification that affects one line of code. org.apache.fop.layoutmgr.ExternalDocumentLayoutManager, line 95, should become:

        String uri = URISpecification.getURL(getExternalDocument().getSrc());

That should fix the cases:
<fox:external-document content-type="pdf" src="url('...')"/>

Part 1) I am not 100% sure of. Judging from the code in ExternalDocumentLayoutManager, I would say some modifications may be necessary there to cater for the possibility of a Data URI as well.


Regards,

Andreas
---


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