如何在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++;
}
当我检查表格时,它们全部来自身体。我似乎无法在页眉或页脚中找到任何元素?
答案 0 :(得分:1)
我找到了示例代码here,这让我得到了答案:
#! /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创建的文档的母版页样式的默认名称...这是最难解决的问题......一旦我找到示例代码,就会在我的膝盖上掉落。