Page 1 of 1
Add a copyright page to PDF output from Chemistry CSS-PDF transformation
Posted: Wed Apr 04, 2018 8:32 pm
by jbisso
I need to add a copyright page between the front cover and the TOC in the PDF that Chemistry creates from DITA files. (The document being processed is using a ditamap, not bookmap.)
Is this possible? Any extant example of such?
Re: Add a copyright page to PDF output from Chemistry CSS-PDF transformation
Posted: Thu Apr 05, 2018 10:06 am
by Dan
Indeed, a bookmap would be more appropriate for your use case. However, you can add a synthetic page using the following technique. In your customization CSS add the following:
Code: Select all
@namespace oxy "http://www.oxygenxml.com/extensions/author";
/* Declare a new page. */
@page copyright-notice-page {
@top-left {
content:none; /* Clear the headers for the copyright page */
}
@top-right {
content:none;
}
}
/* The front page contains the title of the publication. We are creating a synthetic element and place it on a different page. */
oxy|front-page:after{
display:block;
page: copyright-notice-page; /* Moves the synthetic element on a new page. */
margin-top:90%; /* use margins to position the text in the page */
margin-left: 5em;
margin-right: 5em;
content: "Copyright 2018-2019 MyCorp Inc. \A All rights reserved";
text-align:center; /* More styling */
color:blue;
}
/* If you need to add more content as blocks, use the :after(2), :after(3) pseudo elements. */
oxy|front-page:after(2){
display:block;
page: copyright-notice-page; /* Continue on the same page as the first after. */
content: "Some more styled text";
color:red;
}
/* If you want to extract information from the document, use the oxy_xpath function.
For example if the copyright info is stored in the map, like:
<map>
<topicmeta>
<copyright>
<copyryear year="2018"/>
<copyrholder>MyCorp Inc.</copyrholder>
</copyright>
</topicmeta>
...
It can be extracted like this from the intermediate merged DITA map document:
*/
oxy|front-page:after(3){
display:block;
page: copyright-notice-page;
content: "Year: " oxy_xpath('//*:front-page/topicmeta/copyright/copyryear/@year')
"\A Holder: " oxy_xpath('//*:front-page/topicmeta/copyright/copyrholder/text()') ;
color:green;
}
Many regards,
Dan