String dataDir = Utils.getSharedDataDir(CreateOneNoteDocumentWithSimpleRichText.class) + "introduction/"; // For complete examples and data files, please go to // https://github.com/aspose-note/Aspose.Note-for-Java // create an object of the Document class Document doc = new Document(); // initialize Page class object Page page = new Page(doc); // initialize Outline class object Outline outline = new Outline(doc); // initialize OutlineElement class object OutlineElement outlineElem = new OutlineElement(doc); // initialize ParagraphStyle class object and set formatting properties ParagraphStyle textStyle = new ParagraphStyle(); textStyle.setFontColor(Color.black); textStyle.setFontName("Arial"); textStyle.setFontSize(10); // initialize RichText class object and apply text style RichText text = new RichText(doc); text.setText("Hello OneNote text!"); text.setParagraphStyle(textStyle); // add RichText node outlineElem.appendChildLast(text); // add OutlineElement node outline.appendChildLast(outlineElem); // add Outline node page.appendChildLast(outline); // add Page node doc.appendChildLast(page); // save OneNote document doc.save(dataDir + "CreateOneNoteDocumentWithSimpleRichText_out.pdf", SaveFormat.Pdf);