Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automaticstyle not added into content xml #113

Open
Sefran007 opened this issue Jan 10, 2022 · 1 comment
Open

Automaticstyle not added into content xml #113

Sefran007 opened this issue Jan 10, 2022 · 1 comment

Comments

@Sefran007
Copy link

Sefran007 commented Jan 10, 2022

from odf.opendocument import OpenDocumentText
from odf.style import Style, TextProperties, ParagraphProperties

document_test = OpenDocumentText()

paragraph_style = Style(name='Test', family='paragraph')
paragraph_style.addElement(ParagraphProperties(numberlines='false', linenumber='0'))
paragraph_style.addElement(TextProperties(fontsize='24pt', fontweight='bold'))
document_test.automaticstyles.addElement(paragraph_style)

document_test.contentxml()

Return :
b'<?xml …><office:automatic-styles/><office:body><office:text/></office:body></office:document-content>'

Missing xml syntax of automatic style

I'm test them on Ubuntu 21.04 and Manjaro 21.2.1 with Python 3.9.5 and 3.10.1

@Sefran007 Sefran007 changed the title Automaticstyle not added into odt file Automaticstyle not added into content xml Jan 10, 2022
@kivdev
Copy link

kivdev commented Feb 14, 2022

Sorry for using google translate.
You have two options for using the library without changing it:

  1. Use names without separators.
  2. Do as I do:
from odf.attrconverters import make_NCName
from odf.style import Style
from odf.table import Table

display_name = "New Style"
name = make_NCName(display_name)
Style(name=display_name)
...


t = Table(stylename=name)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants