text-with-masterpage.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. # Copyright (C) 2007 Søren Roug, European Environment Agency
  4. #
  5. # This is free software. You may redistribute it under the terms
  6. # of the Apache license and the GNU General Public License Version
  7. # 2 or at your option any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public
  15. # License along with this program; if not, write to the Free Software
  16. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. #
  18. # Contributor(s):
  19. #
  20. from odf.opendocument import OpenDocumentText
  21. from odf.style import PageLayout, MasterPage, Header, Footer
  22. from odf.text import P
  23. textdoc = OpenDocumentText()
  24. pl = PageLayout(name="pagelayout")
  25. textdoc.automaticstyles.addElement(pl)
  26. mp = MasterPage(name="Standard", pagelayoutname=pl)
  27. textdoc.masterstyles.addElement(mp)
  28. h = Header()
  29. hp = P(text="header try")
  30. h.addElement(hp)
  31. mp.addElement(h)
  32. textdoc.save("headers.odt")