1

I am trying to create an Open Office document using PERL and OpenOffice::OODoc, and I wish for the resulting document to be in the landscape orientation.

I tried going through the OpenOffice::OODoc::Styles, and the best I got is: switchPageOrientation(page); but I don't know what page is.

So I put together the following code:

#!/usr/bin/perl -w
use strict;
use Data::Dumper;
use OpenOffice::OODoc;
my $docFile = "../resources/landscape.odt";

my $doc = odfDocument( file   => $docFile,
                       create => 'text' );
my $pageLayout = $doc->updatePageLayout(
                        "LandscapeStyle",
                        properties => {
                                        'fo:margin-bottom'          => '0.7874in',
                                        'fo:page-width'             => '11in',
                                        'style:footnote-max-height' => '0in',
                                        'style:shadow'              => 'none',
                                        'fo:margin-left'            => '0.7874in',
                                        'fo:margin-right'           => '0.7874in',
                                        'fo:page-height'            => '8.5in',
                                        'style:num-format'          => '1',
                                        'style:print-orientation'   => 'landscape',
                                        'style:writing-mode'        => 'lr-tb',
                                        'fo:margin-top'             => '0.7874in'
                        }
);
$doc->switchPageOrientation($pageLayout);
$doc->appendParagraph( text  => "Testing",
                       style => $pageLayout );

$doc->save;
print "\"$docFile\" is saved.\n";
print "Done.";
exit 0;

The Output is:

Odd number of elements in hash assignment at C:/Strawberry/perl/site/lib/OpenOffice/OODoc/Styles.pm line 1301.
Use of uninitialized value in list assignment at C:/Strawberry/perl/site/lib/OpenOffice/OODoc/Styles.pm line 1301.
"../resources/landscape.odt" is saved.
Done.`

The document is created but not in landscape, rather within the regular portrait orientation.
Does anyone know what page is, and how I can get it to change my document?

Any ideas?
Zaxxon
  • 182
  • 1
  • 4
  • 18

0 Answers0