AntennaHouse / pdf5-ml

Antenna House PDF5-ML DITA-OT Plug-in
23 stars 9 forks source link

Customize the cover #226

Closed bing-10 closed 2 years ago

bing-10 commented 2 years ago

I want to position the logo and booktitle freely on the cover, but there are always margins on the cover. I checked the xsl:

<fo:page-sequence master-reference="pmsPageSeqCover" id="{$cCoverId}">
            <xsl:copy-of select="ahf:getAttributeSet('atsPageSeqBase')"/>
            <fo:flow flow-name="xsl-region-body">
                <fo:block-container>
                    <xsl:copy-of select="ahf:getAttributeSet('atsCoverBookTitleBC')"/>
                    <xsl:if test="exists($bookLibrary)">
                        <fo:block>
                            <xsl:copy-of select="ahf:getAttributeSet('atsCoverBookLibrary')"/>
                            <xsl:copy-of select="$bookLibrary"/>
                        </fo:block>
                    </xsl:if>
                    <fo:block>
                        <xsl:copy-of select="ahf:getAttributeSet('atsCoverBookTitle')"/>
                        <xsl:copy-of select="$bookTitle"/>
                    </fo:block>
                    <xsl:if test="exists($bookAltTitle)">
                        <fo:block>
                            <xsl:copy-of select="ahf:getAttributeSet('atsCoverAltBookTitle')"/>
                            <xsl:copy-of select="$bookAltTitle"/>
                        </fo:block>
                    </xsl:if>
                </fo:block-container>
                <fo:block-container>
                    <xsl:copy-of select="ahf:getAttributeSet('atsCoverBookMetaBC')"/>
                    <fo:block>
                        <xsl:copy-of select="ahf:getAttributeSet('atsCoverBookMeta')"/>
                        <xsl:apply-templates select="$map//*[contains(@class,' bookmap/bookmeta ')]" mode="cover"/>
                    </fo:block>
                </fo:block-container>
            </fo:flow>
        </fo:page-sequence>

and found it applied atsPageSeqBase as attribute-set to style the cover page. However, I found there are no attributes about margin in the attibute-set atsPageSeqBase:

            <attribute-set name="atsPageSeq">
                <attribute name="reference-orientation">from-page-master-region()</attribute>
                <attribute name="writing-mode">from-page-master-region()</attribute>
            </attribute-set>

            <attribute-set name="atsPageSeqBase" use-attribute-sets="atsPageSeq">
                <attribute name="initial-page-number">auto</attribute>
                <attribute name="force-page-count">no-force</attribute>
            </attribute-set>

So, what should I do to customize the cover independently?

ToshihikoMakita commented 2 years ago

The margins of page and fo:region-body is defined in dita2fo_layoutmasterset.xsl. If you want use margin-less page-master, use "pmsCover" or "pmsCoverForPrint" fo:simple-page-master or "pmsPageSeqCover" fo:page-sequence-master.

bing-10 commented 2 years ago

Ok, thank you. I can do some customizations now. But another question appeared: I want to put the book title in the center of the whole page(both vertically and horizontally), so I added such attributes in the definition file:

<attribute-set name="atsCoverBookTitleBlock">
    <attribute name="position">absolute</attribute>
    <attribute name="top">0</attribute>
    <attribute name="right">0</attribute>
    <attribute name="bottom">0</attribute>
    <attribute name="left">0</attribute>
    <attribute name="margin">auto</attribute>    
</attribute-set>

The horizontal position is placed initially, but the vertical position cannot be changed through such attributes. How should I do? I would be very grateful if you could give the cause and solution.

ToshihikoMakita commented 2 years ago

fo:block-container is a square whos left-side coordinate is specified by @left, right-side is specified by @right, the top position is specified as @top and bottom is specified by @bottom. So specifying all 0 to these value has no meaning.

ToshihikoMakita commented 2 years ago

If you want locate fo:block-container to (x,y)=(10mm, 20mm) with width=30mm & height=40mm, set the following property.

<attribute-set name="atsCoverBookTitleBlock">
    <attribute name="absolute-position">absolute</attribute>
    <attribute name="left">10mm</attribute>
    <attribute name="top">20mm</attribute>
    <attribute name="width">30mm</attribute>
    <attribute name="height">40mm</attribute>
</attribute-set>
bing-10 commented 2 years ago

I tried this approach, but it did not work properly: the title block remained unchanged(including "left", "top", "width" and "height"). Besides, what I want to realize is that the book title can be placed in the center of the cover page automatically, instead of by assigning absolute length values, because it will fit for different page sizes.

ToshihikoMakita commented 2 years ago

the book title can be placed in the center of the cover page automatically

What do you mean to place book title in the center of cover page? Vertically or horizontally? Or both?

Could you attach the current plug-in ZIP archive?

bing-10 commented 2 years ago

I mean both vertically and horizontally. This is the ZIP archive: com.test.pdf5.zip

bing-10 commented 2 years ago

I mean both vertically and horizontally. This is the ZIP archive: com.test.pdf5.zip

All changes I have made are mainly in config/default_style.xml and xsl/dita2fo_custom.xsl.

ToshihikoMakita commented 2 years ago

Here is the modified plug-in and sample DITA file output. Please read the output XSL-FO file and find the differences between fo:block-container anbd fo:block.

com.test.pdf5-2021-05-31.zip

PDF5-ML-Custmization-Test-2022-05-31.zip

ToshihikoMakita commented 2 years ago

Also never use margin, margin-xxx for fo:block. Instead you can use start-indent and end-indent. The margin-xxx property is only left for CSS compatibility.

bing-10 commented 2 years ago

Ok, I see. Thank you very much! And, I have learned from what you have modified, but one thing I still feel confused about text-align-last. I am wondering the differences among text-align, text-align-last, and display-align. (even though I have referred to the instructions from https://www.w3.org/TR/2006/REC-xsl11-20061205/#text-align-last, I still did not make sense of the application in my modified plugin...)

ToshihikoMakita commented 2 years ago

@text-align-last is applied to the last line of a paragraph (fo:block). The default value is @text-align="relative". So it is not needed to explicitly specify @text-align-last="center". It was my habit. It will automatically set as "center" if @text-align="center".

7.16.10 "text-align-last" 7.16.9 "text-align"

@display-align is vertical alignment specifier. It is effective such as fo:block-container, not fo:block.

7.14.4 "display-align"

bing-10 commented 2 years ago

Ok, I see. Thank you!