Python-docx: Getting list numbering

Created on 29 Apr 2015  路  7Comments  路  Source: python-openxml/python-docx

Hi all,

I`m wondering how can I get list numbering of paragraphs with style "Paragraph List"
So far I got such thoughts:

numId_val = paragraph._element.pPr.numPr.numId.val # getting value for <w:num> in numbering.xml

Next step should be finding which corresponds to numId, that I got above

num_obj = filter(lambda x: x.numId == numId_val, document.part.numbering_part.element.num_lst)[0]

Then look into to get ordering info (such as start value ...)

absNum_obj = num_obj.abstractNumId

And that is fail, because it does not represent what I see in xml,
I get smth like this

print absNum_obj.xml
<w:abstractNumId xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml" xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" xmlns:wpi="http://schemas.microsoft.com/office/word/2010/wordprocessingInk" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" w:val="0"/>

Instead of

<w:abstractNum w:abstractNumId="0">
  <w:nsid w:val="00000012" /> 
  <w:multiLevelType w:val="hybridMultilevel" /> 
  <w:tmpl w:val="31AE522E" /> 
- <w:lvl w:ilvl="0" w:tplc="0419000F">
  <w:start w:val="1" /> 
  <w:numFmt w:val="decimal" /> 
  <w:lvlText w:val="%1." /> 
  <w:lvlJc w:val="left" /> 
- <w:pPr>
- <w:tabs>
  <w:tab w:val="left" w:pos="720" /> 
  </w:tabs>
  <w:ind w:left="720" w:hanging="360" /> 
  </w:pPr>
  </w:lvl>
....
</w:abstractNum>

And more, if I manage to get start value, I will have to manually count paragraphs with same level id, then increase start value and only after that I will get numbering of paragraph.

Maybe there is more straightforward and easy way?

Thanks

Most helpful comment

Is this going to implemented? Seems like an old issue, but it is still getting traction, which means it is important for people. I'd love to see a nice API call for retrieving list numbers. 馃槏

All 7 comments

I'd also like to get paragraph numbering. Has there been any development of this?

Also looking for numbering, especcially for sections...

Any hints on this?

up

up

sames

Is this going to implemented? Seems like an old issue, but it is still getting traction, which means it is important for people. I'd love to see a nice API call for retrieving list numbers. 馃槏

sames

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kociak picture kociak  路  5Comments

ronbarak picture ronbarak  路  3Comments

StephenCzarnecki picture StephenCzarnecki  路  4Comments

evbo picture evbo  路  3Comments

ssuzen picture ssuzen  路  6Comments