Perl OpenOffice :: OODoc-访问页眉/页脚元素 [英] Perl OpenOffice::OODoc - accessing header/footer elements

查看:140
本文介绍了Perl OpenOffice :: OODoc-访问页眉/页脚元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在odt文档的页眉/页脚中获取元素?

How do you get elements in a header/footer of a odt doc?

例如我有:

use OpenOffice::OODoc;    
my $doc = odfDocument(file => 'whatever.odt');
    my $t=0;
    while (my $table = $doc->getTable($t))
    {
       print "Table $t exists\n";
       $t++;
    }

当我检查桌子时,它们全都来自身体.我似乎无法在页眉或页脚中找到任何元素?

When I check the tables they are all from the body. I can't seem to find elements for anything in the header or footer?

推荐答案

我找到了示例代码在这里使我得到了答案:

I found sample code here which led me to the answer:

#! /usr/local/bin/perl

use OpenOffice::OODoc;

my $file='asdf.odt';

# odfContainer is a representation of the zipped odf file 
# and all of its parts.
my $container = odfContainer("$file");

# We're going to look at the 'style' part of the container,
# because that's where the header is located.
my $style = odfDocument
    (
    container => $container,
    part      => 'styles'
    );

# masterPageHeader takes the style name as its argument.
# This is not at all clear from the documentation.
my $masterPageHeader = $style->masterPageHeader('Standard');
my $headerText = $style->getText( $masterPageHeader );

print "$headerText\n"

母版页样式定义了文档的外观和风格-例如CSS.显然,标准"是OpenOffice创建的文档的母版页面样式的默认名称...这是最难破解的螺母...一旦找到示例代码,该代码就落在了我的腿上.

The master page style defines the look and feel of the document -- think CSS. Apparently 'Standard' is the default name for the master page style of a document created by OpenOffice... that was the toughest nut to crack... once I found the example code, that fell out in my lap.

这篇关于Perl OpenOffice :: OODoc-访问页眉/页脚元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆