Page 1 of 1

Vertical text on cover

Posted: Sat Jun 23, 2018 1:39 am
by llpick
Hi,

I've spent a few hours putting together a bare bones DITA -> PDF template using Chemistry, and I'm impressed with how intuitive things have been so far. However I'm stuck on a specific thing.

We're putting some metadata on the cover. Let's say, for example, "AA123456 revision 1".
The difficult bit (for me!) is that it has to be presented vertically (top to bottom, left-to-right).
Is there a way of doing that ?

Any help is welcome :)

(I haven't yet tried to lift the metadata from the map's topicmeta yet, but that will be the next step).
Thanks!

Re: Vertical text on cover

Posted: Mon Jun 25, 2018 4:04 pm
by Dan
You can collect the metadata and keep it into a string variable. For example, to collect the value of the "author" element :

Code: Select all


:root {
string-set: author oxy_xpath('//*[contains(@class, "bookmap/bookmeta")]/*[contains(@class, "topic/author")]/text()');
}
Please note that the string-set property accepts multiple string definitions separated by commas. Do not define the property twice on the same element, it will get overwritten by the last value.

Then, use this value from a page margin box:

Code: Select all


@page front-page{
@right-top {
content: string(author) ;
transform: rotate(90deg); /* Or -90deg */
background-color:yellow;
}
}
In this way you can display meta information to the side of the page. If your usecase is different, please let us know.

Many regards,
Dan

Re: Vertical text on cover

Posted: Mon Jun 25, 2018 7:23 pm
by llpick
Thank you Dan, this works just fine.

Here's the small adjustment I made for my own case (I'll remove the yellow background at the end):

Code: Select all


@page front-page{
@bottom-right-corner {
content: string(author);
transform: rotate(-90deg);
background-color:yellow;
}
}

Now, I've tried including metadata from a map rather than a bookmap, by slightly altering your example, and it doesn't show anything:

Code: Select all

:root {
string-set: author oxy_xpath('//*[contains(@class, "map/topicmeta")]/*[contains(@class, "topic/author")]/text()');
}
I probably made a rookie mistake.
Do you have any suggestions? And what can I read to know more about this?

Thank you so much.

Re: Vertical text on cover

Posted: Tue Jun 26, 2018 11:02 am
by Dan
This expression worked for me:

Code: Select all


:root {
string-set: author oxy_xpath('//*[contains(@class, "front-page/front-page")]/*[contains(@class, "map/topicmeta")]/*[contains(@class, "topic/author")]/text()');
}
In the map there was:

Code: Select all


<map>
<title>The Art of Bike Repair</title>
<topicmeta>
<author>John Doe</author>
</topicmeta>
....
[code]


In case you need to debug other XPath expressions:
[list]
[*] Begin by transforming your document and using your customization CSS.
[*] In the output folder, next to the PDF file you will find a [MAP_NAME].merged.xml file (if you are using the pdf-css-html5 transformation, the [MAP_NAME].merged.html file).
[*] Open the merged file in the oXygen XML Editor.
[*] Activate the XPath builder: WindowShow ViewXPath/XQuery BuilderPaste here your XPath expression and press the execute button. Check is it returns the expected results.[/list]

The XPath builder has a function that allows it to display the document path of the current element from the editor (Settings ButtonUpdate on cursor move). Alternatively you can right-click the element in the merged document and use the Copy XPath action, then paste in the XPath builder.

Re: Vertical text on cover

Posted: Wed Jun 27, 2018 3:18 pm
by llpick
Dan, thank you for this. It's exactly what I needed, and the bit about debugging is really helping.

Have a very pleasant day.