Page 1 of 1

DITA CSS to PDF Front Page (Chemistry)

Posted: Thu Jun 01, 2017 2:42 pm
by mrpaultracey
I am trying to use Chemistry to get away from my XSL FO plugin.
I am having trouble with the cover page. Is it possible to have a front page with an image set to the background and then text over the image to display title/subtitle?

How can i align the image to the top of my frontpage?

<!DOCTYPE bookmap PUBLIC "-//OASIS//DTD DITA BookMap//EN" "bookmap.dtd">

<bookmap>

<booktitle>
<mainbooktitle><image id="front-cover" href="standard/FrontCover.png" placement="break"
align="center"/> Doc Title </mainbooktitle>
</booktitle>

Re: DITA CSS to PDF Front Page (Chemistry)

Posted: Fri Jun 02, 2017 1:21 pm
by mrpaultracey
Ive tried:

background-image: url("C:\FrontCover.png");

and selecting the Front-Cover image, but it always comes out in the center of the page, I assume ist something to do with it being in a booktitle?

Re: DITA CSS to PDF Front Page (Chemistry)

Posted: Mon Jun 05, 2017 3:42 pm
by radu_pisoi
Hi,

You can use the background-size and background-position CSS properties to control the size and position of the background image.
https://developer.mozilla.org/en-US/doc ... round-size
https://developer.mozilla.org/en-US/doc ... d-position

To demonstrate this, I've created a GITHUB project containing a sample CSS customization for the DITA Map PDF - WYSIWYG transformation . In my case, I've tried to customize the front cover for the PDF manual of the oXygen Author product. This customization includes a custom background image and product logo like in the picture below.

You can try this sample customization by:
1. Download the sample customization from GITHUB: https://github.com/radu-pisoi/com.oxyge ... ion.sample;
2. Edit the DITA Map PDF - WYSIWYG transformation scenatio and set the css.processor.type parameter to chemistry;
3. Sets the args.css parameter to the path of the p-dita-customization.css CSS file;
4. Run the transformation.

Image

Re: DITA CSS to PDF Front Page (Chemistry)

Posted: Tue Jun 06, 2017 2:45 pm
by mrpaultracey
looks great. thanks!

Re: DITA CSS to PDF Front Page (Chemistry)

Posted: Thu Jun 29, 2017 7:53 pm
by shudson310
Is there a styling tool or a reference that documents how to style certain elements?

For example, on the cover, I want to extract the metadata from the prodinfo and render it in a specific place on the cover.

Thanks,

--Scott

Re: DITA CSS to PDF Front Page (Chemistry)

Posted: Thu Jun 29, 2017 11:03 pm
by shudson310
How would you go about creating a title page after the cover page?

Something like:
Product Name
Software Version 1.x for iOS

Company name
Address
City, ST 123456
© 2017 Company, All Rights Reserved

Document ID:
Document Revision:
Document Date:

Would you implement as a separate titlepage CSS?

Re: DITA CSS to PDF Front Page (Chemistry)

Posted: Fri Jun 30, 2017 4:10 pm
by radu_pisoi
Hi,

My favorite way to develop a CSS for the DITA CSS to PDF transformation type implies opening and analyzing the XML that represents the input for the CSS based PDF processor. This XML file is generated in the output folder near the PDF file and has the following name pattern: dita_map_name.in.xml.

If you open this file, you will see that the XML element associated with the front cover page (oxy:front-page) has not enough information for your use case. For the next bookmap snapshot:

Code: Select all

<bookmap>
<booktitle>
<mainbooktitle>Sample Product</mainbooktitle>
</booktitle>
<bookmeta>
<authorinformation></authorinformation>
<prodinfo>
<prodname>Product name</prodname>
<platform>Linux</platform>
</prodinfo>
</bookmeta>
...
</bookmap>
the generated bookmap.in.xml file will have the structure:

Code: Select all

<bookmap>
...
<oxy:front-page xmlns:oxy="http://www.oxygenxml.com/extensions/author">
<oxy:front-page-title>
<booktitle>
<mainbooktitle>Sample Product</mainbooktitle>
</booktitle>
</oxy:front-page-title>
</oxy:front-page>
<opentopic:map xmlns:opentopic="http://www.idiominc.com/opentopic"
xmlns:ot-placeholder="http://suite-sol.com/namespaces/ot-placeholder">
<oxy:toc-title xmlns:oxy="http://www.oxygenxml.com/extensions/author" empty="true"/>
...
<bookmeta xmlns:dita-ot="http://dita-ot.sourceforge.net/ns/201007/dita-ot"
class="- map/topicmeta bookmap/bookmeta ">
<prodinfo class="- topic/prodinfo ">
<prodname class="- topic/prodname ">Product name</prodname>
<platform class="- topic/platform ">Linux</platform>
</prodinfo>
</bookmeta>
</opentopic:map>
..
</bookmap>
As you can see, the oxy:front-page element which is associated with the cover/front page, does not contains information from bookmeta. I will register an issue on our side to add this information in a future version.

Another solution that is not available yet, is to add an XSLT extension point for this transformation that will allow you to change the structure of the bookmap.in.xml file.

Meanwhile, a workaround would be to use :after(n) pseudo-elements together with the oxy_xpath()[1] extension function. Please note that this workaround is available only when you run with the Chemistry processor.

A sample CSS that adds the product name and platform in the front cover page would be:

Code: Select all


/* If you need to display some meta information on the front (cover) page  */
front-page-title:after(1) {
display:block;
margin-top: 100mm;
content: "Product name: " oxy_xpath('//bookmeta//prodinfo/prodname/text()');
text-align:right;
}

front-page-title:after(2) {
display:block;
content: "Platform: " oxy_xpath('//bookmeta//prodinfo/platform/text()');
text-align:right;
}
----
[1] - oxy_xpath() Function
https://www.oxygenxml.com/doc/versions/ ... ction.html