Getting a wide table to print in landscape

Having trouble installing Oxygen? Got a bug to report? Post it all here.
BarbaraLGreen
Posts: 5
Joined: Wed Jan 26, 2011 12:06 am

Getting a wide table to print in landscape

Post by BarbaraLGreen »

I have a single topic with a wide table that needs a DITA->PDF transformation with a landscape page orientation.

I have searched everywhere in the user guide and online to find where I can set page width and page height to landscape values. I cannot seem to find the settings for landscape orientation in any of the OxyGen dialogs.

I have been using the included DITA to PDF transformation scenario. I created a map for this one topic, and tried transformation both from the topic and from the map. I also tried a set of instructions for including a custom.xsl file, but that pretty much broke the transformation.

Each time I transform the topic I get the following warnings, followed by a bunch of overflow messages for the table cells.


transform.fo2pdf.fop:
[java] 0 INFO [ main ] org.apache.fop.apps.FopFactoryConfigurator - Default page-height set to: 11in
[java] 0 INFO [ main ] org.apache.fop.apps.FopFactoryConfigurator - Default page-width set to: 8.26in

So, how do I tell the Apache FOP to set these values?

Any help appreciated.

Thanks,
Barbara
Radu
Posts: 9446
Joined: Fri Jul 09, 2004 5:18 pm

Re: Getting a wide table to print in landscape

Post by Radu »

Hi Barbara,

In the XSL file:
OXYGEN_INSTALL_DIR/frameworks/dita/DITA-OT/demo/fo/cfg/fo/layout-masters.xsl

You can edit the simple-page-masters called body-odd and body-even like:

Code: Select all

  <fo:simple-page-master
master-name="body-odd"
page-width="{$page-width}"
page-height="{$page-height}">
.....................
and add the attribute reference-orientation="90" to it.
See this tutorial for example:
http://www.learn-xsl-fo-tutorial.com/Page-Layout.cfm

The final result after adding the attributes should be like:

Code: Select all


            <fo:simple-page-master
master-name="body-even"
page-width="{$page-width}"
page-height="{$page-height}"
reference-orientation="90">
<fo:region-body
margin-top="{$page-margin-top}"
margin-bottom="{$page-margin-bottom}"
margin-left="{$page-margin-left}"
margin-right="{$page-margin-right}"/>
<fo:region-before extent="{$page-margin-top}"
display-align="before"
region-name="even-body-header"/>
<fo:region-after extent="{$page-margin-bottom}"
display-align="after"
region-name="even-body-footer"/>
</fo:simple-page-master>

<fo:simple-page-master
master-name="body-odd"
page-width="{$page-width}"
page-height="{$page-height}"
reference-orientation="90">
<fo:region-body
margin-top="{$page-margin-top}"
margin-bottom="{$page-margin-bottom}"
margin-left="{$page-margin-left}"
margin-right="{$page-margin-right}"/>
<fo:region-before extent="{$page-margin-top}"
display-align="before"
region-name="odd-body-header"/>
<fo:region-after extent="{$page-margin-bottom}"
display-align="after"
region-name="odd-body-footer"/>
</fo:simple-page-master>
But this will change the orientation to landscape to all pages in the PDF. If you want to change the layout only for a single page you would need a lot of XSLT customization but the idea is the same.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
BarbaraLGreen
Posts: 5
Joined: Wed Jan 26, 2011 12:06 am

Re: Getting a wide table to print in landscape

Post by BarbaraLGreen »

Thanks, Radu. I finally had time to test this out and it worked fine.

Thanks again for your help.
Bob.Conlin
Posts: 22
Joined: Sun Aug 14, 2011 5:21 am

Re: Getting a wide table to print in landscape

Post by Bob.Conlin »

What kind of customizing is needed? I too have a table (several) in a topic that is part of a larger ditamap. Only a few tables needs to be oriented to landscape. How can this be accomplished?
Radu
Posts: 9446
Joined: Fri Jul 09, 2004 5:18 pm

Re: Getting a wide table to print in landscape

Post by Radu »

Hi Bob,

You should probably at first set an outputclass attribute to those specific tables to differentiate them from the rest.
Then somehow in the stylesheet generate different simple-page-master's for each one with a different rotation attribute than the default one.

Maybe you should also ask around on the DITA Users List, there might be people who have done this and can give you customization suggestions.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Radu
Posts: 9446
Joined: Fri Jul 09, 2004 5:18 pm

Re: Getting a wide table to print in landscape

Post by Radu »

Updating this thread because the XSLs we discussed have been moved to a new folder in DITA OT 1.6.

The XSL the forum post discussed was moved to:

OXYGEN_INSTALL_DIR\frameworks\dita\DITA-OT\plugins\org.dita.pdf2\cfg\fo\layout-masters.xsl

Actually the entire PDF generation plugin was moved to "plugins\org.dita.pdf2" so this is why references to XSLs no longer correspond.

But simple page masters defined there use a common attribute set called "simple-page-master" which is defined in:

OXYGEN_INSTALL_DIR\frameworks\dita\DITA-OT\plugins\org.dita.pdf2\cfg\fo\attrs\layout-masters-attr.xsl

If you want landscape display for your entire PDF, you can open this XSl and can change this particular attribute set to be something like:

Code: Select all


 <xsl:attribute-set name="simple-page-master">
<xsl:attribute name="page-width">
<xsl:value-of select="$page-width"/>
</xsl:attribute>
<xsl:attribute name="page-height">
<xsl:value-of select="$page-height"/>
</xsl:attribute>
<xsl:attribute name="reference-orientation" select="90"/>
</xsl:attribute-set>
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
aaloysious
Posts: 4
Joined: Thu Jan 10, 2013 6:07 pm

Re: Getting a wide table to print in landscape

Post by aaloysious »

This works beautifully but my PDF file opens up in Adobe Reader with the text in vertical format across the page. I need to select view > rotate 90 to view it correctly. Is this something that can be added to the xsl file?
Radu
Posts: 9446
Joined: Fri Jul 09, 2004 5:18 pm

Re: Getting a wide table to print in landscape

Post by Radu »

Hi Anne,

Maybe what you actually need is not to rotate the pages in the entire PDF but to increase the page width and to decrease the page height of the original page settings.
So you could remove your customization to rotate the page and then in the XSL:

OXYGEN_INSTALL_DIR/frameworks/dita/DITA-OT/plugins/org.dita.pdf2/cfg/fo/attrs/basic-settings.xsl

you could modify the values for:

Code: Select all

    <xsl:variable name="page-width">215.9mm</xsl:variable>
<xsl:variable name="page-height">279.4mm</xsl:variable>
to be the other way around (the value for the width to be for height and vice-versa).

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
aaloysious
Posts: 4
Joined: Thu Jan 10, 2013 6:07 pm

Re: Getting a wide table to print in landscape

Post by aaloysious »

When I do that, the PDF the text is still vertically spread accross the page & unfortunately it's not in landscape but in portrait format. I want it to be in landscape format and for the text to read horizontally from left to right across the page.
aaloysious
Posts: 4
Joined: Thu Jan 10, 2013 6:07 pm

Re: Getting a wide table to print in landscape

Post by aaloysious »

Sorry, ignore the last comment. I wanted to delete it but can't. It works if I switch the page widths arund and remove the line <xsl:attribute name="reference-orientation" select="90"/>.

Thanks!
aaloysious
Posts: 4
Joined: Thu Jan 10, 2013 6:07 pm

Re: Getting a wide table to print in landscape

Post by aaloysious »

OXYGEN_INSTALL_DIR/frameworks/dita/DITA-OT/plugins/org.dita.pdf2/cfg/fo/attrs/basic-settings.xsl

Should this be moved to the customization folder if I want to switch between portrait and lanscape format?
Radu
Posts: 9446
Joined: Fri Jul 09, 2004 5:18 pm

Re: Getting a wide table to print in landscape

Post by Radu »

Hi Anne,

Not the entire XSLT stylesheet but the modified content.
In the CustomizationDIR\fo\attrs you would have a custom.xsl with the content being something like this:

Code: Select all

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
version="2.0">
<xsl:variable name="page-width">215.9mm</xsl:variable>
<xsl:variable name="page-height">279.4mm</xsl:variable>
</xsl:stylesheet>
And in the CustomizationDIR\catalog.xml you would need to uncomment the mapping to the custom.xsl like:

Code: Select all

<uri name="cfg:fo/attrs/custom.xsl" uri="fo/attrs/custom.xsl"/>
This would mean that the variables defined in your customization would be imported first, thus overwriting the ones in the basic-settings.xsl.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
kelly wang
Posts: 1
Joined: Mon Sep 30, 2013 11:17 am

Re: Getting a wide table to print in landscape

Post by kelly wang »

Hi Radu,
I have a similar situation where I only want to rotate the pages which contains very wide table.
Could you please specify some detailed instructions on how to make it happen?


Thank you very much!
Kelly
Radu wrote:Hi Bob,

You should probably at first set an outputclass attribute to those specific tables to differentiate them from the rest.
Then somehow in the stylesheet generate different simple-page-master's for each one with a different rotation attribute than the default one.

Maybe you should also ask around on the DITA Users List, there might be people who have done this and can give you customization suggestions.

Regards,
Radu
Radu
Posts: 9446
Joined: Fri Jul 09, 2004 5:18 pm

Re: Getting a wide table to print in landscape

Post by Radu »

Hi Kelly,

The suggestions I gave on this thread were for the case in which the entire PDF would need to appear with wide pages.
Sorry but although possible with XSL-FO I do not have a clear idea of how it would be done to change the page format only for certain tables.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
asurkau
Posts: 6
Joined: Mon Mar 06, 2017 5:20 pm

Re: Getting a wide table to print in landscape

Post by asurkau »

With Dita OT 2.5.4 (this is the toolkit version I'm currently using) you can create a landscape table OOTB by adding orient="land" to the table tag; you don't need to change anything in your plugin.
This will put the table on a new page and rotate it by 90 degrees; the rest of the document (including anything else that is in the topic besides the table) will appear in portrait mode.

The following code in tables-attr.xsl does this for you:

Code: Select all

<xsl:attribute-set name="table__container">
<xsl:attribute name="reference-orientation" select="if (@orient eq 'land') then 90 else 0"/>
<xsl:attribute name="start-indent">from-parent(start-indent)</xsl:attribute>
</xsl:attribute-set>
asurkau
Posts: 6
Joined: Mon Mar 06, 2017 5:20 pm

Re: Getting a wide table to print in landscape

Post by asurkau »

I'm using the method decribed in my post yesterday (add @orient="lang" to <table> tag) to render large tables in landscape in an otherwise portrait document and have run into the following issue:
A large table (i.e. a table with many rows) does not break across pages when this attribute is set, as it would if it wasn't set. My plugin has the following code set for breaking table rows across pages:

Code: Select all

<xsl:attribute-set name="tbody.row">
<xsl:attribute name="keep-together.within-page">auto</xsl:attribute>
</xsl:attribute-set>
This works fine if the table does not have the attribute set, but the table overflows the page if the attribute is set.

I also tested this with a default DITA-OT 2.5.4 plugin, and it shows the same behaviour.
Is there any other setting that I should change or could this be a bug in the plugin?
Radu
Posts: 9446
Joined: Fri Jul 09, 2004 5:18 pm

Re: Getting a wide table to print in landscape

Post by Radu »

Hi,

From what I remember the reference-orientation is a good option only for small tables which do not span pages.
I'm not sure if the problem you encounter is a limitation in the open source PDF processor bundled with Oxygen (Apache FOP), in which case you could try to publish to PDF using a commercial processor like RenderX XEP or Antenna House or maybe it could be a limitation in all processors.
I found a similar question addressed on the Antenna House commercial PDF processor list:

https://www.antennahouse.com/support/v2 ... 2002121303

and they seem to have removed the limitation in recent processor versions.

As an alternative to the classical PDF output I would suggest you try our "DITA Map PDF - WYSIWYG" transformation scenario which renders the PDF by using CSS to style the DITA content.
It also default support for the table @orient attribute and you can also choose to automatically rotate tables which have many columns:

https://www.oxygenxml.com/doc/versions/ ... ables.html

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply