DITA CSS to PDF Front Page (Chemistry)

mrpaultracey
Posts: 9

DITA CSS to PDF Front Page (Chemistry)

Thu Jun 01, 2017 2:42 pm

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>
mrpaultracey
Posts: 9

Re: DITA CSS to PDF Front Page (Chemistry)

Fri Jun 02, 2017 1:21 pm

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?
radu_pisoi
Posts: 334
Location: Craiova

Re: DITA CSS to PDF Front Page (Chemistry)

Mon Jun 05, 2017 3:42 pm

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.oxygenxml.pdf.css.customization.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
Radu Pisoi
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
mrpaultracey
Posts: 9

Re: DITA CSS to PDF Front Page (Chemistry)

Tue Jun 06, 2017 2:45 pm

looks great. thanks!
shudson310
Posts: 130
Location: USA

Re: DITA CSS to PDF Front Page (Chemistry)

Thu Jun 29, 2017 7:53 pm

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
Scott Hudson
Content Strategist
Jeppesen
Site: jeppesen.com
shudson310
Posts: 130
Location: USA

Re: DITA CSS to PDF Front Page (Chemistry)

Thu Jun 29, 2017 11:03 pm

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?
Scott Hudson
Content Strategist
Jeppesen
Site: jeppesen.com
radu_pisoi
Posts: 334
Location: Craiova

Re: DITA CSS to PDF Front Page (Chemistry)

Fri Jun 30, 2017 4:10 pm

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
Radu Pisoi
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

Return to “DITA (Editing and Publishing DITA Content)”

Who is online

Users browsing this forum: No registered users and 1 guest