The meta data doesn't show the title which is a paragraph with the style of 'Title' or Psomething.

I installed ODF::lpOD once I figured out that lpOD starts with lower case L. It's documentation is voluminous and not much better than OpenOffice::OODoc's.

However I did get it to work!

#!/usr/bin/perl -w use strict; use ODF::lpOD; my $file = $ARGV[0]; die "You must supply an odf file name\n" unless $file; my $doc = odf_document->get($file) or die "Can't load $file\n$!\n"; my $context = $doc->body; my $meta = $doc->meta; # Doesn't do what I wanted my $title = $meta->get_title; print "Title: $title\n" if $title; # shows Title: c if at all my $p = $context->get_paragraph(style=>'Title', content=>'ODF',positio +n=>0); if ($p) {print $p->get_text()."\n";} else {print "Not found\n";} # prints Not found #this works my ($i,$ps,$style,$pStyle); for ($i = 0; $i < 6; $i++) { $p = $context->get_paragraph(position=>$i); if ($p) { print "Paragraph $i"; $ps = $p->get_style(); if ($ps) { if ($ps =~ m/^P\d+$/) { # Check for internal styles $style = $doc->get_style('paragraph',$ps) || ''; $pStyle = $style->get_parent_style if $style; $ps = $pStyle if $pStyle; # This gets the real name } print " Style: $ps\n"; } else {print "No Style\n";} my $data = $p->get_text(recursive=>1); if ($data) {print "$data\n";} else {print "--No data\n";} } else { print "Paragraph $i not found\n"; } }

Thanks Ken

—Bob


In reply to Re^2: Search OpenOffice document for title and author by jinnicky
in thread Search OpenOffice document for title and author [Solved] by jinnicky

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.