Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add image to pdf through xsl-fo using XML attribute value

Tags:

xml

xpath

xsl-fo

I'm making a PDF from an XMl doc using XSL-FO. I need to import images using their names that are inside the XML doc.

Example XML:

<newAlbums>
   <album cover="blaimage.jpg"/>
</newAlbums>

I need to do this through a similar statement:

<fo:external-graphic src="({})/>

What XPath do I need to put inside the src attribute to import the image? Thanks for the help this has been killing me.

like image 693
Hendrik Human Avatar asked Dec 02 '25 05:12

Hendrik Human


1 Answers

It will basically be <fo:external-graphic src="{concat('url(', /newAlbums/album/@cover, ')')}">. The exact XPath expression will depend on your XML. For example, you will most likely have more than one album element, so /newAlbums/album[1]/@cover or similar will be required.

like image 87
Dabbler Avatar answered Dec 04 '25 00:12

Dabbler



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!