Changing the front page image according to the bookmeta

romane
Posts: 2
Joined: Tue Jun 29, 2021 4:13 pm

Changing the front page image according to the bookmeta

Post by romane » Tue Jun 29, 2021 4:25 pm

Hi all!

I'm trying to customize my PDF (based on HTML5 & CSS) in order to display a certain background image on my front page according to some metadata from my bookmap. What I'm trying to do is the exact same thing as explained here: topic22276.html and I already tried the code used in this topic but it doesn't seem to work for me.

This is what I have in my bookmap:

Code: Select all

     <bookmeta>
        <prodinfo>
            <prodname>MyProduct<data name="background" value="bgr_right.png"/></prodname>
        </prodinfo>
    </bookmeta>
 
And this is what I added to my CSS file:

Code: Select all

    @page front-page {
       background-image: url(oxy_xpath("//*[contains(@class, ' topic/data')][@name='background'][1]/@value"));
    }
I assumed it was not working because the oxy_xpath wasn't precise enough so I also tried this:

Code: Select all

@page front-page {
       background-image: urloxy_xpath('//*[contains(@class, " bookmap/bookmeta ")]/*[contains(@class, ' topic/data')][@name='background'][1]/@value"));
    }
But it wasn't working either.

Do you have any idea why it's not working? Is it because my image is a .png and not a .svg?

Thank you very much,
Romane

julien_lacour
Posts: 203
Joined: Wed Oct 16, 2019 3:47 pm

Re: Changing the front page image according to the bookmeta

Post by julien_lacour » Wed Jun 30, 2021 3:46 pm

Hello Romane,

You were really close of the solution, here is the correct CSS:

Code: Select all

@page front-page {
  background-image: url(oxy_xpath("//*[contains(@class, 'bookmap/bookmeta')]//*[contains(@class, ' topic/data')][@name='background'][1]/@value"));
}
The 'topic/data' element is a descendant of the 'bookmap/bookmeta', the "/*" XPath rule matches only a node direct children.

Regards,
Julien

romane
Posts: 2
Joined: Tue Jun 29, 2021 4:13 pm

Re: Changing the front page image according to the bookmeta

Post by romane » Wed Jun 30, 2021 3:54 pm

Hi again,

I solved the problem.
Actually it was not working on my computer (oXygen 20.1) but when tried on another computer with oXygen 23.1, it worked!

I then tried to import the CSS folder back to my computer and I was still not working. So I guess it was just a version problem.

Regards,

Romane

Post Reply