Page 1 of 1

Color text in topic

Posted: Fri Sep 12, 2014 10:33 am
by Le Basque
Hi,

Exist a attribute that allows you to change colors on portions of text?

Thank you

Re: Color text in topic

Posted: Fri Sep 12, 2014 10:39 am
by Radu
Hi,

No, you would need to add a <ph> element with a certain @outputclass attribute value around that portion of text and then from the XSLs or from the CSS in case of the XHTML output match that output class and change the foreground color.

Regards,
Radu

Re: Color text in topic

Posted: Fri Sep 12, 2014 11:53 am
by Le Basque
hi,

In topic i indicate :

Code: Select all


<p>blablablas <ph outputclass="font-color-red">I am red</ph></p>
In custom file i indicate :

Code: Select all


<xsl:template name="decoration">
<xsl:choose>
<xsl:when test="@outputclass='font-color-red'">
<xsl:attribute name="color">#8E2323</xsl:attribute>
</xsl:when>
</xsl:choose>
</xsl:template>

<!-- call decoration -->
<xsl:template match="*[contains(@class,' topic/ph ')]">
<fo:inline xsl:use-attribute-sets="ph">
<xsl:call-template name="decoration"/>
<xsl:apply-templates/>
</fo:inline>
</xsl:template>
In resut PDF not color RED ?
thank you

Re: Color text in topic

Posted: Fri Sep 12, 2014 12:08 pm
by Radu
Hi,

You could try to add xsl:messages in the XSLT customization to see after the publishing is finished in the ANT console output if your template is being called.

Regards,
Radu

Re: Color text in topic

Posted: Fri Sep 12, 2014 12:27 pm
by Le Basque
hi

ok when i replace #8E2323 by red the result is OK ?

thank you

Re: Color text in topic

Posted: Fri Sep 12, 2014 1:28 pm
by Radu
Hi,

Is this a question or is this a statement?
The color attribute in XSL-FO should handle colors specified with the hexadecimal notation.
You can also edit the transformation scenario and set the parameter clean.temp to "no", then after the transformation look in the temporary files folder at a file called topic.fo which is the resulting XSL-FO file and see if the color attribute properly appeared on the fo:inline.

Regards,
Radu

Re: Color text in topic

Posted: Fri Sep 12, 2014 1:57 pm
by Le Basque
hi

there is a simpler solution for insert background color in entry of table ?

thank you

Re: Color text in topic

Posted: Mon Sep 15, 2014 4:43 pm
by Radu
Hi,

You can probably also set the @outputclass attribute on a table entry like:

Code: Select all


<entry outputclass="red">AAAAAA</entry>
then in the XSL:

OXYGEN_INSTALL_DIR\frameworks\dita\DITA-OT\plugins\org.dita.pdf2\xsl\fo\tables.xsl

make modifications to the template which matches table body entries so that it looks for that attribute:

Code: Select all

    <xsl:template match="*[contains(@class, ' topic/tbody ')]/*[contains(@class, ' topic/row ')]/*[contains(@class, ' topic/entry ')]">
<fo:table-cell xsl:use-attribute-sets="tbody.row.entry">
<xsl:if test="@outputclass">
<xsl:attribute name="background-color"><xsl:value-of select="@outputclass"/></xsl:attribute>
</xsl:if>
<xsl:call-template name="commonattributes"/>
<xsl:call-template name="applySpansAttrs"/>
<xsl:call-template name="applyAlignAttrs"/>
<xsl:call-template name="generateTableEntryBorder"/>
<fo:block xsl:use-attribute-sets="tbody.row.entry__content">
<xsl:call-template name="processEntryContent"/>
</fo:block>
</fo:table-cell>
</xsl:template>
Regards,
Radu