Thread

Posted on Sat May 10 20:36:34 2008 by trotz
appending a heading does not work for me
Hello, I use this module for the first time, inserting paragraphs is fine, but inserting headers I get only normal paragraphs, no headers.

$doc->appendParagraph(text => "Dup dubi dubi dup, dup.", style => "Standard");
$doc->appendHeading(text => "bla bla bla", style=>"Heading_20_1");

Using OpenOffice.org 2.3.1 and the latest OpenOffice::OODoc (today downloaded from CPAN) on Linux.

Regards, Francesc
Direct Responses: 7850 | Write a response
Posted on Sat May 10 23:34:21 2008 by jmgdoc in response to 7849
Re: appending a heading does not work for me

The "Heading_20_1" style is probably not defined in the target document. While a "Heading_20_1" style is silently generated (with default properties) as soon as its selected and used through OpenOffice.org, it's not predefined in the OpenOffice::OODoc library. So, this style can be either replicated from an existing document which owns it, or explicitly created by program.

The following example (which works with "content" and "styles" in the same session) creates a new document from scratch, then creates a "Heading_20_1" style (with arbitrary text properties) in the "styles" part and a level 1 heading (using the new style) in the "content" part.
my $container = odfContainer("test.odt", create => 'text'); my $content = odfDocument ( container => $container, create => "text" ); my $styles = odfDocument ( container => $container, part => "styles" ); $content->appendHeading ( text => "A level one title", level => 1, style => 'Heading_20_1' ); $styles->createStyle ( 'Heading_20_1', display-name' => "Heading 1", family => "paragraph", properties => { area => 'text', 'fo:font-size' => "115%", 'fo:font-weight' => "bold" } ); $container->save;
Direct Responses: 7853 | Write a response
Posted on Sun May 11 08:14:42 2008 by trotz in response to 7850
Re: appending a heading does not work for me
Yes, it works -- Thank you very much! The module OpenOffice::OODoc is a great tool. Regards, Francesc
Write a response