Difference between revisions of "AODL example 15"
From Apache OpenOffice Wiki
m |
|||
| Line 1: | Line 1: | ||
<b>Create a standard Paragraph with formated text</b> | <b>Create a standard Paragraph with formated text</b> | ||
| − | < | + | <syntaxhighlight lang="c"> |
//Create a new text document | //Create a new text document | ||
TextDocument document = new TextDocument(); | TextDocument document = new TextDocument(); | ||
| Line 7: | Line 7: | ||
//Create a standard paragraph using the ParagraphBuilder | //Create a standard paragraph using the ParagraphBuilder | ||
Paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(document); | Paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(document); | ||
| − | //Add some | + | //Add some formatted text |
| − | FormatedText formText = new FormatedText(document, "T1", "Some | + | FormatedText formText = new FormatedText(document, "T1", "Some formatted text!"); |
formText.TextStyle.TextProperties.Bold = "bold"; | formText.TextStyle.TextProperties.Bold = "bold"; | ||
paragraph.TextContent.Add(formText); | paragraph.TextContent.Add(formText); | ||
| Line 14: | Line 14: | ||
document.Content.Add(paragraph); | document.Content.Add(paragraph); | ||
//Save | //Save | ||
| − | document.SaveTo(" | + | document.SaveTo("formatted.odt"); |
| − | </ | + | </syntaxhighlight> |
Back to the [[AODL_examples|AODL examples]] overview. | Back to the [[AODL_examples|AODL examples]] overview. | ||
[[category:Summer of Code 2007]][[category:AODL]] | [[category:Summer of Code 2007]][[category:AODL]] | ||
Latest revision as of 12:45, 22 May 2022
Create a standard Paragraph with formated text
//Create a new text document
TextDocument document = new TextDocument();
document.New();
//Create a standard paragraph using the ParagraphBuilder
Paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(document);
//Add some formatted text
FormatedText formText = new FormatedText(document, "T1", "Some formatted text!");
formText.TextStyle.TextProperties.Bold = "bold";
paragraph.TextContent.Add(formText);
//Add the paragraph to the document
document.Content.Add(paragraph);
//Save
document.SaveTo("formatted.odt");
Back to the AODL examples overview.