Page 1 of 1

Setting PDF Bookmarks and Properties (DITA and CSS)

Posted: Sat Dec 15, 2018 2:38 am
by shannonxtreme
I'm trying to make the following happen in the PDF output:
  • Set the PDF bookmarks so that the mainbooktitle and booktitlealt are displayed as the top-level bookmark label in the format "mainbooktitle booktitlealt"
  • Set the Title property in the PDF output to the same format "mainbooktitle - booktitlealt"
For the first point, I managed to get them to display as a single string by setting the booktitle class as the level 1 bookmark, with the bookmark-label property set to content(text). I am unclear how to get an n-dash in the middle of the two.

Any help would be appreciated.

Re: Setting PDF Bookmarks and Properties (DITA and CSS)

Posted: Mon Dec 17, 2018 4:56 pm
by Costin
Hi shannonxtreme,
Set the PDF bookmarks so that the mainbooktitle and booktitlealt are displayed as the top-level bookmark label in the format "mainbooktitle – booktitlealt"
Your approach - setting the bookmark-level to 1 on the booktitle is correct.
However, to concatenate the text content from the "mainbooktitle" and the "booktitlealt" elements and use the result in bookmarks, you should use the oxy_xpath CSS extension.
More specific, you should add the following rule in your customization CSS:

Code: Select all

*[class ~= "booktitle"]{
bookmark-level:1 !important;
bookmark-label:
oxy_xpath("*[contains(@class, 'bookmap/mainbooktitle')]//text()")
" - "
oxy_xpath("*[contains(@class, 'bookmap/booktitlealt')]//text()");
}
Set the Title property in the PDF output to the same format "mainbooktitle - booktitlealt"
Regarding your 2nd question, there is an "-oxy-pdf-meta-title" property that matches the publication title (the title that appears as the "Title" property for the PDF document).
You could use the same oxy_xpath you used also as value for the "-oxy-pdf-meta-title" property, so that the concatenated string resulted from the mainbooktitle text + " - " + booktitlealt text, will be used.
Note that the selector that should be used is even the root of the document, as only the first occurrence of the meta title from the entire document is considered.
Specifically, in the customization CSS, you should use a structure like:

Code: Select all

:root {
-oxy-pdf-meta-title:
oxy_xpath("//*[contains(@class, 'front-page/front-page-title')]//*[contains(@class, 'bookmap/mainbooktitle')]//text()")
" - "
oxy_xpath("//*[contains(@class, 'front-page/front-page-title')]//*[contains(@class, 'bookmap/booktitlealt')]//text()");
}
Regards,
Costin