How do I make the PDF2 output in Author 19 look the same as in Author 16: tables don't continue

Exotic Hadron
Posts: 24

How do I make the PDF2 output in Author 19 look the same as in Author 16: tables don't continue

Mon Oct 09, 2017 8:47 pm

Howdy,

Is there any way how I could make the PDF output by PDF2 transformation in Author 19 look the same as it's been in Author 16?

I understand this has something to do with settings in XSL files within ${frameworksDir}/dita/DITA-OT/plugins/org.dita.pdf2/xsl/fo/ like that tables.xsl

But what exactly should be edited in XSL files in the DITA set shipped with Author 19? Any clues on what should I change to achieve the same output as in Author 16?


Output in Author 16


Image

Output in Author 19
Image


As you see the issues are as follows:
1) The table does not continue on the next page
If the table does not feet the page size, it protrudes through the margins.

2) Tables do not have a color fill in their headings
In Author 16's output tables have an orange fill.

3) Text in cell does overlaps
In Author 16, cells are rendered as "fit the text in cell". In Author 19, cells are rendered with a static width so that the text that does not fit this width overlaps the neighbor cell.


Thank you in advance.
Exotic Hadron
Posts: 24

Re: How do I make the PDF2 output in Author 19 look the same as in Author 16: tables don't continue

Tue Oct 10, 2017 5:18 pm

Okay, I've figured it out.

To make the table to continue on a next page when it is long enough to fit the current page, we have to clear the attribute that prevents the rows to break. The attribute that controls whether a row can break is called keep-together.within-page. It is the inverse analog of the Allow row to break across pages check box found in table properties in Microsoft Word.

The thing is, while Allow row to break across pages stops Word from keeping rows together, keep-together.within-page forces that effectively preventing two adjacent rows to break. As a result, rows stick together when output to PDF.

To allow rows to break across pages and enable tables to continue of next page,
1) In Author 19 open ${frameworksDir}/dita/DITA-OT2.x/plugins/org.dita.pdf2/cfg/fo/attrs/.

Note: ${frameworksDir} substitutes for %programfiles%\Oxygen XML Author 19\frameworks\. When using 32-bit version of Author 19 on a 64-bit platform, this maps to %programfiles(x86)%\Oxygen XML Author 19\frameworks\.

Note: Author 19 ships with two built-in versions of DITA framework: DITA-OT 1.8 and DITA-OT 2.x (used by default). You can select the framework to be used for publishing in Preferences | DITA.

2) Locate the tables-attr.xsl and open it for editing. Preferably in an editor that supports Linux-like line endings (LF without CR) such as Notepad++.
3) In the opened tables-attr.xsl locate the block that starts with the following line:

Code: Select all

<xsl:attribute-set name="tbody.row">


3.1) Create a backup of the expression by copying the block and commenting it out, like:

Code: Select all

<!--Default: Do not continue table on the next page-->
<!--  <xsl:attribute-set name="tbody.row">-->
    <!--Table body row-->
<!--    <xsl:attribute name="keep-together.within-page">always</xsl:attribute>-->
<!--  </xsl:attribute-set>-->


4) Modify the original block by removing the keep-together.within-page attribute:

Code: Select all

<!--Modified: Сontinue table on the next page-->
  <xsl:attribute-set name="tbody.row">
    <!--Table body row-->
  </xsl:attribute-set>


The change will look as:

Code: Select all

<!--Default: Do not continue table on the next page-->
<!--  <xsl:attribute-set name="tbody.row">-->
    <!--Table body row-->
<!--    <xsl:attribute name="keep-together.within-page">always</xsl:attribute>-->
<!--  </xsl:attribute-set>-->

<!--Modified: Сontinue table on the next page-->
  <xsl:attribute-set name="tbody.row">
    <!--Table body row-->
  </xsl:attribute-set>


Save changes and then close the editor. You do not have to restart the Author 19 to make the changes apply. Now if you print the document to PDF by using the PDF2 transformation, your tables will run across multiple pages if they do not fit a single page.

Adding shading for table headings

To allow rows to break across pages and enable tables to continue of next page,
1) In Author 19 open ${frameworksDir}/dita/DITA-OT2.x/plugins/org.dita.pdf2/cfg/fo/attrs/.

Note: ${frameworksDir} substitutes for %programfiles%\Oxygen XML Author 19\frameworks\. When using 32-bit version of Author 19 on a 64-bit platform, this maps to %programfiles(x86)%\Oxygen XML Author 19\frameworks\.

Note: Author 19 ships with two built-in versions of DITA framework: DITA-OT 1.8 and DITA-OT 2.x (used by default). You can select the framework to be used for publishing in Preferences | DITA.

2) Locate the tables-attr.xsl and open it for editing. Preferably in an editor that supports Linux-like line endings (LF without CR) such as Notepad++.
3) In the opened tables-attr.xsl locate the block that starts with the following line:

Code: Select all

<xsl:attribute-set name="thead.row.entry">


3.1) Create a backup of the expression by copying the block and commenting it out, like:

Code: Select all

<!--Default: Do not fill table head with color-->
<!--  <xsl:attribute-set name="thead.row.entry">-->
    <!--head cell-->
<!--  </xsl:attribute-set>-->


4) Modify the original block by adding the background-color attribute and setting its value to antiquewhite:

Code: Select all

<!--Default: Fill table head with color-->
  <xsl:attribute-set name="thead.row.entry">
    <!--head cell-->
    <xsl:attribute name="background-color">antiquewhite</xsl:attribute>
  </xsl:attribute-set>


The change will look as:

Code: Select all


<!--Default: Do not fill table head with color-->
<!--  <xsl:attribute-set name="thead.row.entry">-->
    <!--head cell-->
<!--  </xsl:attribute-set>-->

<!--Default: Fill table head with color-->
  <xsl:attribute-set name="thead.row.entry">
    <!--head cell-->
    <xsl:attribute name="background-color">antiquewhite</xsl:attribute>
  </xsl:attribute-set>



5) Repeat steps 3 through 4.1 for:
5.1) Block that starts with

Code: Select all

<xsl:attribute-set name="sthead.stentry__keycol-content" use-attribute-sets="common.table.body.entry common.table.head.entry">


The change will look as:

Code: Select all


<!--Default: Do not fill table head with color-->
<!--  <xsl:attribute-set name="sthead.stentry__keycol-content" use-attribute-sets="common.table.body.entry common.table.head.entry">-->
<!--  </xsl:attribute-set>-->

<!--Default: Fill table head with color-->
  <xsl:attribute-set name="sthead.stentry__keycol-content" use-attribute-sets="common.table.body.entry common.table.head.entry">
    <xsl:attribute name="background-color">antiquewhite</xsl:attribute>
  </xsl:attribute-set>



6) Repeat steps 3 through 4.1 for:
6.1) Block that starts with

Code: Select all

<xsl:attribute-set name="strow.stentry__keycol-content" use-attribute-sets="common.table.body.entry common.table.head.entry">


The change will look as:

Code: Select all


<!--Default: Do not fill table head with color-->
<!--  <xsl:attribute-set name="strow.stentry__keycol-content" use-attribute-sets="common.table.body.entry common.table.head.entry">-->
<!--  </xsl:attribute-set>-->

<!--Default: Fill table head with color-->
  <xsl:attribute-set name="strow.stentry__keycol-content" use-attribute-sets="common.table.body.entry common.table.head.entry">
    <xsl:attribute name="background-color">antiquewhite</xsl:attribute>
  </xsl:attribute-set>



Save changes and then close the editor. You do not have to restart the Author 19 to make the changes apply. Now if you print the document to PDF by using the PDF2 transformation, your tables will now have shading in their headings.
Radu
Posts: 5093

Re: How do I make the PDF2 output in Author 19 look the same as in Author 16: tables don't continue

Wed Oct 11, 2017 10:40 am

Hi,

Thanks for posting detailed steps about what you did. Ideally when making PDF customizations you should avoid as much as possible to edit the XSLTs located in the base DITA OT PDF plugin.
This topic in our user's guide discusses the two proper ways in which a DITA OT PDF customization should be made along with links to the DITA OT 1.8 and 2.x documentation:

https://www.oxygenxml.com/doc/versions/19.1/ug-editor/topics/dita_pdf_output_customization-x-predefined3.html

Once you have a PDF customization folder or a PDF plugin, you will be able to migrate easier to newer DITA OT releases, instead of relying on manual changes to update the base DITA OT XSLTs.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Exotic Hadron
Posts: 24

Re: How do I make the PDF2 output in Author 19 look the same as in Author 16: tables don't continue

Wed Oct 11, 2017 3:12 pm

Hi Radu,

Thanks for noting.

Could you please hint on where I could get some documentation on creating XSL templates? The referenced example does not delve into markup details, so while it is clear what one should do to do a specific task add a logo to the frontmatter of a PDF document, I am not sure I caught the idea of creating templates for a specific task.

For example, how do I create a template for the tasks outlined in this topic?

Thank you in advance.
Radu
Posts: 5093

Re: How do I make the PDF2 output in Author 19 look the same as in Author 16: tables don't continue

Thu Oct 12, 2017 10:05 am

Hi,

So to create an external PDF customization folder you first start by copying this folder to an external location:

OXYGEN_INSTALL_DIR\frameworks\dita\DITA-OT2.x\plugins\org.dita.pdf2\Customization

You change the name of the "catalog.xml.orig" to "catalog.xml" and uncomment in it the two mappings:

Code: Select all

  <uri name="cfg:fo/attrs/custom.xsl" uri="fo/attrs/custom.xsl"/>
  <uri name="cfg:fo/xsl/custom.xsl" uri="fo/xsl/custom.xsl"/>


You rename "Customization\fo\attrs\custom.xsl.orig" to "custom.xsl" and "Customization\fo\xsl\custom.xsl.orig" to "custom.xsl".
You now have these two "custom.xsl" stylesheets in your customization folder. The one in the "attrs" folder can be used to override attribute set definitions from the base XSLTs. The other one can be used to override XSLT templates from the base XSLTs.
For example if in the "attrs/custom.xsl" you add:

Code: Select all

  <xsl:attribute-set name="tbody.row">
<xsl:attribute name="keep-together.within-page">auto</xsl:attribute>
  </xsl:attribute-set>


you should override the "always" value which was set in the original XSLTs for the same named attribute-set. The way in which attribute sets are overridden in XSLT means that you must specify a value for "keep-together.within-page" in your overridden attribute set, otherwise the value from the base XSLT will be used.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Exotic Hadron
Posts: 24

Re: How do I make the PDF2 output in Author 19 look the same as in Author 16: tables don't continue

Tue Nov 14, 2017 3:02 pm

Hello Radu,

Thank you for your help.

Seems like I've missed some detail here as coloring of table headers doesn't work for me with the customization plugin.

Here's what I've done.

1. Copied %OxygenProgramFolder%\frameworks\dita\DITA-OT2.x\plugins\org.dita.pdf2\Customization\ to C:\DITA-OT\ so that customization XSL files are now located in:

Code: Select all

C:\DITA-OT\Customization

2. Renamed catalog.xml.orig to catalog.xml
3. Edited catalog.xml and removed commentary from the uri name="cfg:fo/xsl/custom.xsl line so that the file now looks as:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="system">

  <uri name="cfg:fo/xsl/custom.xsl" uri="fo/xsl/custom.xsl"/>

</catalog>

4. Pasted the following lines to C:\DITA-OT\Customization\fo\xsl\custom.xsl

Code: Select all

<!--Fill table head with color-->
  <xsl:attribute-set name="thead.row.entry">
    <!--head cell-->
    <xsl:attribute name="background-color">antiquewhite</xsl:attribute>
  </xsl:attribute-set>

<!--Fill table head with color-->
  <xsl:attribute-set name="sthead.stentry__keycol-content" use-attribute-sets="common.table.body.entry common.table.head.entry">
    <xsl:attribute name="background-color">antiquewhite</xsl:attribute>
  </xsl:attribute-set>

<!--Fill table head with color-->
  <xsl:attribute-set name="strow.stentry__keycol-content" use-attribute-sets="common.table.body.entry common.table.head.entry">
    <xsl:attribute name="background-color">antiquewhite</xsl:attribute>
  </xsl:attribute-set>


Note: these modifications are supposed to change fill color for the table head.

5. Copied DITA Map PDF transformation scenario, and then, on the Parameters tab in scenario properties, set customization.dir property to C:\DITA-OT\Customization.

Now if I build my DITAMAP using this modified transformation, the transformation fails with following error:
BUILD FAILED
\DITA-OT2.x\build.xml:45: The following error occurred while executing this line:
\DITA-OT2.x\plugins\org.dita.pdf2\build.xml:140: The following error occurred while executing this line:
\DITA-OT2.x\plugins\org.dita.pdf2\build.xml:276: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.tools.ant.types.XMLCatalog$ExternalResolver.processExternalCatalogs(Unknown Source)
at org.apache.tools.ant.types.XMLCatalog$ExternalResolver.resolve(Unknown Source)
at org.apache.tools.ant.types.XMLCatalog.resolve(Unknown Source)
at net.sf.saxon.style.UseWhenFilter.startElement(UseWhenFilter.java:316)
at net.sf.saxon.event.StartTagBuffer.startContent(StartTagBuffer.java:236)
at net.sf.saxon.event.ProxyReceiver.startContent(ProxyReceiver.java:177)
at net.sf.saxon.event.ProxyReceiver.startContent(ProxyReceiver.java:177)
at net.sf.saxon.event.ProxyReceiver.startContent(ProxyReceiver.java:177)
at net.sf.saxon.event.ProxyReceiver.startContent(ProxyReceiver.java:177)
at net.sf.saxon.event.ReceivingContentHandler.startElement(ReceivingContentHandler.java:370)
at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
at org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)
at ro.sync.xml.transformer.dita.remote.b.emptyElement(Unknown Source)
at org.ditang.relaxng.defaults.RelaxNGDefaultsComponent.emptyElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.ditang.relaxng.defaults.RelaxDefaultsParserConfiguration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at net.sf.saxon.event.Sender.sendSAXSource(Sender.java:451)
at net.sf.saxon.event.Sender.send(Sender.java:153)
at net.sf.saxon.style.StylesheetModule.loadStylesheet(StylesheetModule.java:233)
at net.sf.saxon.style.Compilation.compileSingletonPackage(Compilation.java:101)
at net.sf.saxon.s9api.XsltCompiler.compile(XsltCompiler.java:859)
at net.sf.saxon.jaxp.SaxonTransformerFactory.newTemplates(Unknown Source)
at org.apache.tools.ant.taskdefs.optional.TraXLiaison.readTemplates(TraXLiaison.java:302)
at org.apache.tools.ant.taskdefs.optional.TraXLiaison.createTransformer(TraXLiaison.java:319)
at org.apache.tools.ant.taskdefs.optional.TraXLiaison.transform(TraXLiaison.java:180)
at org.apache.tools.ant.taskdefs.XSLTProcess.process(XSLTProcess.java:878)
at org.apache.tools.ant.taskdefs.XSLTProcess.execute(XSLTProcess.java:416)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405)
at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38)
at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:441)
at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:105)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405)
at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38)
at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:441)
at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:105)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405)
at org.apache.tools.ant.Project.executeTarget(Project.java:1376)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
at org.apache.tools.ant.Main.runBuild(Main.java:854)
at org.apache.tools.ant.Main.startAnt(Main.java:236)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:287)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:113)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 3
at org.apache.xml.resolver.readers.TextCatalogReader.nextToken(TextCatalogReader.java:249)
at org.apache.xml.resolver.readers.TR9401CatalogReader.readCatalog(TR9401CatalogReader.java:81)
at org.apache.xml.resolver.Catalog.parseCatalogFile(Unknown Source)
at org.apache.xml.resolver.Catalog.parsePendingCatalogs(Unknown Source)
at org.apache.xml.resolver.Catalog.parseCatalog(Unknown Source)
at org.apache.tools.ant.types.resolver.ApacheCatalogResolver.parseCatalog(ApacheCatalogResolver.java:115)
... 80 more


When using original transformation without the configured customization.dir property, PDF file produces without issues.

What gives?

I'd appreciate your help and suggestions.
Last edited by Exotic Hadron on Tue Nov 14, 2017 4:48 pm, edited 1 time in total.
Radu
Posts: 5093

Re: How do I make the PDF2 output in Author 19 look the same as in Author 16: tables don't continue

Tue Nov 14, 2017 4:24 pm

Hi,

It seems that your catalog.xml from the customization folder is no longer well formed. You can open it in Oxygen and validate.
It's contents should look like:

Code: Select all

<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="system">

  <uri name="cfg:fo/xsl/custom.xsl" uri="fo/xsl/custom.xsl"/>

</catalog>


Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Exotic Hadron
Posts: 24

Re: How do I make the PDF2 output in Author 19 look the same as in Author 16: tables don't continue

Tue Nov 14, 2017 4:47 pm

Thank you. Indeed, I have erroneously removed the open and close angle brackets when I was removing the commentary in step. I had:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="system">

  uri name="cfg:fo/xsl/custom.xsl" uri="fo/xsl/custom.xsl"/

</catalog>


it must look as:

<?xml version="1.0" encoding="utf-8"?>
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="system">

<!-- Custom XSL code entry.-->
<uri name="cfg:fo/xsl/custom.xsl" uri="fo/xsl/custom.xsl"/>

</catalog>


For some reason, I also had to re-copy the custom.xsl.orig from the /plugins folder and paste the content of my edited custom.xsl to this new one again, because simply adding missing brackets to the URI in catalog.xml didn't work.

Anyways, thank you! Works fine now.

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

Who is online

Users browsing this forum: No registered users and 1 guest