Issue with string-set and variable declaration in css (PDF creation)

Having trouble installing Oxygen PDF Chemistry? Got a bug to report? Post it all here.
mariom
Posts: 5
Joined: Tue Jun 25, 2024 3:55 pm

Issue with string-set and variable declaration in css (PDF creation)

Post by mariom »

I'm using a demo version of Publishing Engine and have run into the following issue while creating PDFs

I'm testing the use of css variables and string-set and when referencing them in the css no value is returned.

Code: Select all

:root {
	string-set: effectiveDate "EFFECTIVE DATE";
	--effectiveDate: "EFFECTIVE DATE";
}

/* this one returns : TEST - Some more stuff - null */
.front-page > div.front-page-title > div {
	color: blue;
	font-size: 4rem;
	content: oxy_concat('TEST - ', 'Some more stuff - ', string(effectiveDate));
}

/* this one returns nothing */
.front-page > div.front-page-title2 > div {
	color: blue;
	font-size: 4rem;
	content: oxy_concat('TEST - ', 'Some more stuff - ', var(--effectiveDate));
}
I've tried the above without the oxy_concat
content: var(--effectiveDate); or content: string(effectiveDate)
both these return nothing.

Is this a limitation with the demo version?

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

Re: Issue with string-set and variable declaration in css (PDF creation)

Post by julien_lacour »

Hello Mario,

This is not a limitation of the trial version, the string() function can only be used within a static context like page-margin boxes (defined within CSS @page at-rule). You can't use it at element level. If you use it in the correct context, you don't need to use oxy_concat() function, you can directly write each value:

Code: Select all

@page front-page {
  @top-left {
    content: 'TEST - ' 'Some more stuff - ' string(effectiveDate));
  }
}
You cannot use a variable neither as indicated in the CSS Validator warning: "Due to their dynamic nature, CSS variables are currently not statically checked".

If you want to add dynamic content in some elements you should take a look at the oxy_xpath() function, you can for example add the current date:

Code: Select all

*[class~="front-page/front-page-title"]::after{
  display: block;
  content: oxy_xpath('current-date()');
}
Regards,
Julien
mariom
Posts: 5
Joined: Tue Jun 25, 2024 3:55 pm

Re: Issue with string-set and variable declaration in css (PDF creation)

Post by mariom »

Thanks for the quick reply.
If I use oxy_xpath() can I use document()?

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

Re: Issue with string-set and variable declaration in css (PDF creation)

Post by julien_lacour »

Hello Mario,

Yes you can, there is an example in the user guide.

Regards,
Julien
mariom
Posts: 5
Joined: Tue Jun 25, 2024 3:55 pm

Re: Issue with string-set and variable declaration in css (PDF creation)

Post by mariom »

Julien,
thanks and things are working as expected now.
Post Reply