Vertical text on cover

llpick
Posts: 5
Joined: Sat Jun 23, 2018 12:52 am

Vertical text on cover

Post by llpick » Sat Jun 23, 2018 1:39 am

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!

Dan
Posts: 428
Joined: Mon Feb 03, 2003 10:56 am

Re: Vertical text on cover

Post by Dan » Mon Jun 25, 2018 4:04 pm

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

llpick
Posts: 5
Joined: Sat Jun 23, 2018 12:52 am

Re: Vertical text on cover

Post by llpick » Mon Jun 25, 2018 7:23 pm

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.

Dan
Posts: 428
Joined: Mon Feb 03, 2003 10:56 am

Re: Vertical text on cover

Post by Dan » Tue Jun 26, 2018 11:02 am

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.

llpick
Posts: 5
Joined: Sat Jun 23, 2018 12:52 am

Re: Vertical text on cover

Post by llpick » Wed Jun 27, 2018 3:18 pm

Dan, thank you for this. It's exactly what I needed, and the bit about debugging is really helping.

Have a very pleasant day.

Post Reply