How can I produce A4 sized PDF output?

Having trouble installing Oxygen? Got a bug to report? Post it all here.
rfolwell
Posts: 8
Joined: Wed Aug 27, 2003 3:50 pm

How can I produce A4 sized PDF output?

Post by rfolwell »

I need to produce A4 PDF output, but cannot see how to do this. I did read through the user guide, and other postings on the forum, but saw nothing obvious.
seanwhe
Posts: 27
Joined: Sat Jul 19, 2003 10:42 am
Location: South Africa
Contact:

Post by seanwhe »

I am assuming that you are using DocBook, but if you are using TEI a similar principle will apply.

In general you need to specify the page size by passing the paper.type parameter. In Oxy you can do this on the Transform Dialog > XSLT tab > Parameters. Add the parameter paper.type and set the value to A4.

The problem with this is that the parameter setting is only persistent for the XML Instance being transformed. In addition, since you most likely want to set many parameters, this method of definition is tedious.

Alternately you can modify the parameter in the DocBook XSL file, but this would mean that each time the XSL's increment a version, that you would have to redo all the changes.

The best option is to write yourself a customization layer and point to this for all your transformations.

For a more detailed discussion on the subject visit this Web Site.
http://www.sagehill.net/docbookxsl/index.html

See the part about print output options and about customization methods.

I recommend that you buy a copy of the PDF. Bob Stanton has done a really superb job with this book.

Enjoy,
Sean Wheller
Technical Writer
sean@inwords.co.za
http://www.inwords.co.za
PeterRobertson
Posts: 47
Joined: Mon Apr 18, 2005 2:22 pm

Post by PeterRobertson »

I am just starting with DocBook and am finding it very difficult: all the information I can find assumes you fully understand almost everything!

My particular problem at the moment is doing exactly what you suggest in this topic: adding some (trivial) customisation. I have taken the example from http://www.sagehill.net/docbookxsl/index.html but whatever I do, it always results in me getting the message:

"E The process ended with code : 2 The error was : [ERROR] file:/C:/Temp/test.xml_fo:32:7 Root element must be root, not book"

Could you give a complete example that shows, say, how to change the paper size to A4?
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Post by sorin_ristache »

Hello,

It shouldn't be difficult especially with the predefined transformation scenarios in <oXygen/> that allow you to perform usual XSL transformations with just one mouse click. To transform a DocBook XML document to PDF just set the cursor in that XML document, press the toolbar button "Configure transformation scenario", in the displayed dialog select the scenario "DocBook PDF", press the Edit button, in the new displayed dialog press the "Parameters" button, then add a parameter with the name paper.type and the value A4 to the list of parameters, press OK in all three dialogs to close them. To apply the scenario you just configured now you just need one mouse click on the toolbar button "Apply transformation scenario".

I hope that helps,
Sorin
PeterRobertson
Posts: 47
Joined: Mon Apr 18, 2005 2:22 pm

Post by PeterRobertson »

Thanks for the suggestion. While it addresses the specific example I gave, it does not answer the actual question. Why do I get the error when I try to follow the advice given earlier: "The best option is to write yourself a customization layer and point to this for all your transformations."?

As I said, when I do this, I always get the error "Root element must be root, not book". What is causing the error?

I would really appreciate an example showing a trivial customisation layer,
as the example taken from the web site you referenced does not seem to work.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Post by sorin_ristache »

PeterRobertson wrote:Could you give a complete example that shows, say, how to change the paper size to A4?
The demo at

http://www.oxygenxml.com/demo/DocbookCu ... ation.html

demonstrates how to create in <oXygen/> a simple DocBook customization layer that sets the output paper type and page orientation and use this layer to transform a DocBook XML document to PDF.

Best regards,
Sorin
PeterRobertson
Posts: 47
Joined: Mon Apr 18, 2005 2:22 pm

Post by PeterRobertson »

Thanks - this is exactly what I wanted. Sadly, it is doing precisely what I had tried and it STILL gives an error when transforming.
E The process ended with code : 2 The error was : [ERROR] file:/C:/Temp/Test.xml_fo:35:7 Root element must be root, not book
Here is my xml file:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.0//EN" "C:\Program Files\Oxygen 5.1\frameworks\docbook\dtd/docbookx.dtd" >

<book>
<bookinfo>
<title>My Book</title>
</bookinfo>
<part>
<title>Part1</title>
<chapter>
<title>Chapter 1</title>
<sect1><title>Section</title>
<para> This is my text </para>
</sect1>
</chapter>
</part>
</book>
Here is the xsl file:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:import href="frameworks/docbooks/fo/docbook.xsl"/>
<xsl:param name="paper.type" select="A4landscape"/>
<xsl:param name="page.orientation" select="landscape"/>
</xsl:stylesheet>
What is going wrong?
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Post by george »

Hi Peter,

Configure a transformation that applies only your stylesheet to the input document and shows the output of the transformation. That output should be a FO document, that is it should start with fo:root element. From the error message it seems you are getting something else.

Best Regards,
George
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Post by george »

Hm...
<xsl:import href="frameworks/docbooks/fo/docbook.xsl"/>
It seems you added an s to the end of docbook, you have docbooks.

Best Regards,
George
PeterRobertson
Posts: 47
Joined: Mon Apr 18, 2005 2:22 pm

Post by PeterRobertson »

I corrected the path by removing the 's'; I still get the same error.
PeterRobertson
Posts: 47
Joined: Mon Apr 18, 2005 2:22 pm

Post by PeterRobertson »

I do not understand what you are suggesting I do about
configuring "a transformation that applies only..."
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Post by george »

I mean a transformation that does not perform FO Processing, on the FO Processor page disable the Perform FO Processing option and on the Output page select the Show As XML option to view the result of the transformation in oXygen.

Converting DocBook to PDF is a two steps process. First the DocBook XSL converts the XML to FO and then the FO is converted with a FOP to PDF. The error message says that in the first step you do not get a FO document.

Best Regards,
George
PeterRobertson
Posts: 47
Joined: Mon Apr 18, 2005 2:22 pm

Post by PeterRobertson »

This is the start of the output I get:

Code: Select all

<?xml version="1.0" encoding="utf-8"?><fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" font-family="serif,Symbol,ZapfDingbats" font-size="10pt" text-align="justify" line-height="normal" font-selection-strategy="character-by-character" line-height-shift-adjustment="disregard-shifts" language="en">
<fo:layout-
Enabling FO processing gives the error.
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Post by george »

Hi Peter,

Then it means that you apply the FOP on the input XML instead of the XSLT result. Please make sure you have XSLT result as input selected for the Input option on the FO Processor page in the transformation scenario dialog.

Best Regards,
George
PeterRobertson
Posts: 47
Joined: Mon Apr 18, 2005 2:22 pm

Post by PeterRobertson »

That seems to have been the main problem: somehow "Edited document as input" had been selected.

One thing remains. If I use the following file:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:import href="frameworks\docbook\xsl\fo/docbook.xsl"/>
<xsl:param name="paper.type" select="A4"/>
</xsl:stylesheet>
When I transform, I get the message:
W Making portrait pages on paper (8.5inx11in)
and the output is NOT a4. Yet if I put the A4 setting as a parameter in the XSLT tab, I get the correct answer.

I have tried my example with several paper types (A3, A5, B4) and they all give the same message. I can actually put any string; it seems to be completely ignored. If I malform the xsl file I get an error, so I know it's being read.

If I remove the paper.type statement, I get the default of USletter,
and your example gives A4 landscape.

Any clues as to what's happening?
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Post by george »

Hi Peter,

Yes, you need to enter the constant A4, that is you need to surround it with apostrophes, otherwise it will be interpreated as the content of the element with the name A4. So you need:

<xsl:param name="paper.type" select="'A4'"/>

Best Regards,
George
PeterRobertson
Posts: 47
Joined: Mon Apr 18, 2005 2:22 pm

Post by PeterRobertson »

The complete file I have been using is:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:import href="frameworks\docbook\xsl\fo/docbook.xsl"/>
<xsl:param name="paper.type" select="A4"/>
</xsl:stylesheet>
Are you suggesting I need to enclose it doubly in quotes: " ' A 4 ' " ?
I have tried both variants "A4" and "'A4'"; it makes no difference. I can
put anything in place of A4 and the behaviour of the system never changes.

I have also verified that the xsl file is actually changing when I edit it.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Post by sorin_ristache »

Hello,

Use this as customization layer for A4 portrait pages without setting a param in the XSLT tab of the scenario edit dialog. The value of the param paper.type must be enclosed by double quotes: " ' A4 ' ". I tried it and it works. If you put USletter or A5 it will work also.

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:import href="frameworks/docbook/xsl/fo/docbook.xsl"/>
<xsl:param name="paper.type" select="'A4'"></xsl:param>
</xsl:stylesheet>
Best Regards,
Sorin
PeterRobertson
Posts: 47
Joined: Mon Apr 18, 2005 2:22 pm

Post by PeterRobertson »

I'm sorry, but it does not work on my system.

I have the following test file:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.0//EN" "C:/Program Files/Oxygen 5.1/frameworks/docbook/dtd/docbookx.dtd" >

<book>
<bookinfo>
<title>My Book</title>
</bookinfo>
<part>
<title>Part1</title>
<chapter>
<title>Chapter 1</title>
<sect1><title>Section</title>
<para> This is my text </para>
</sect1>
</chapter>
</part>
</book>
I also have the file:

Code: Select all

C:\Program Files\Oxygen 5.1\PaperSize.xsl
which contains your text (but with A4 changed to A3):

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:import href="frameworks/docbook/xsl/fo/docbook.xsl"/>
<xsl:param name="paper.type" select="'A3'"></xsl:param>
</xsl:stylesheet>
(I still find the two sets of nested quotes (" and ') contrary to my limited understanding of XML - but that's a different matter).

I select my test xml file and go to "configure transformation scenario"

I make a copy of Docbook PFD and go to XSL URL, and use "Browse for a local input XSL file" to select PaperSize.xsl. The XSL URL box now contains:

Code: Select all

file:/C:/Program%20Files/Oxygen%205.1/PaperSize.xsl
OK and Transform Now result in the message:

Code: Select all

W Making portrait pages on A4 paper (210mmx297mm)

What has happened to my A3 selection?

As this works on your system, there must be something wrong in mine.
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Post by george »

Hi Peter,

Strangely I got the same behavior as you, while this worked ok on Sorin's machine... Then I remembered I set up the paper.type parameter in the scenario when I run a few tests a couple of days ago, I edited the scenario, removed the paper.type parameter and now everything is ok. Please make sure you do not have the same situation.

The need for apostrophes are not something related with XML but with XSLT. The select attribute value is treated similar with the value-of/@select so if you want to specify the element test you write
select="test"
but if you want to specify the constant value test you write
select=" 'test' "

Best Regards,
George
PeterRobertson
Posts: 47
Joined: Mon Apr 18, 2005 2:22 pm

Post by PeterRobertson »

That solved the problem. Because of other problems, I had followed advice to put the A4 specification in the parameters, but when the first problem was resolved I forgot the parameter was still set.

Thanks for all your help.
Post Reply