Forum Discussion

stemarcoh's avatar
stemarcoh
Tin Contributor
Aug 17, 2026

OneNote Interop API: Local paragraph style attributes not retained after UpdatePageContent

Summary: When using the OneNote COM Interop API to round‑trip page XML, local paragraph style attributes are removed if they match the font properties already defined in the referenced QuickStyleDef. After this normalization, the paragraph inherits the QuickStyleDef’s color, which can cause text to become unreadable if the QuickStyleDef uses a color that is not visible against the page background.

Environment: C# / .NET Framework 4.8 OneNote for Microsoft 365 IApplication.UpdatePageContent / IApplication.GetPageContent XMLSchema.xs2013

Description: If a page contains a QuickStyleDef with a specific fontColor (for example, #FFFFFF) and a paragraph that references this QuickStyleDef also includes a local style attribute that duplicates only the font family and size (but does not specify a color), the following behavior occurs: The page XML is retrieved using GetPageContent. The same XML is sent back to OneNote using UpdatePageContent, either when creating a new page or updating an existing one. After the update, retrieving the page again shows that the local style attribute has been removed from the affected one:OE elements. Because the local style no longer provides a font color override, the paragraph inherits the QuickStyleDef’s color. If that color is not visible (e.g., white text on a white background), the paragraph appears blank even though the text is still present.Reproduction steps: Create a new page using CreateNewPage. Provide XML containing: A QuickStyleDef such as:

<one:quickstyledef index="1" name="p" fontcolor="#FFFFFF" font="Calibri" fontsize="11.0"></one:quickstyledef>

An Outline with an OE referencing this QuickStyleDef and containing a local style attribute that duplicates the font properties:

<one:OE quickStyleIndex="1" style="font-family:Calibri;font-size:11.0pt">

  <one:T>Example text</one:T>

</one:OE>

Call UpdatePageContent with the XML. Retrieve the page again using GetPageContent.

Observed behavior: The returned XML no longer contains the style attribute on the OE element. All other attributes and elements are preserved. The paragraph now renders using the QuickStyleDef’s color.

Expected behavior: Local style attributes that are present in the XML passed to UpdatePageContent should remain in the stored page XML, even if they duplicate properties from the QuickStyleDef, so that the effective formatting remains unchanged. Impact: Any tool that copies or rewrites page content through the Interop API may encounter unexpected formatting changes when OneNote normalizes style attributes. If the QuickStyleDef uses a color that is not visible, paragraphs may appear blank after round‑tripping through the API.

Additional note: This behavior can also occur when updating an Outline that contains multiple OE elements. If one OE is modified and the entire Outline is resent, sibling OEs may also have their local style attributes normalized in the same way. If you want, I can also prepare a shorter version optimized for Q&A’s character limits or a developer‑focused version aimed at Office engineering.

 

No RepliesBe the first to reply