Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Mon May 13, 2013 8:26 am

Hi,

i have a rtf-file containing lists wir paragraphstyles.
Like the following:
A) Some text
A. Some text
B. Some text
now an indent then
a. Some text
b. Some text
and so on

I attach a testfile for better explanation.

I want to read the paragraph attributes out of the paragraphobject. I use the currentlistlevel-object to read most of the values but the "start at"-value is always "0".

Can anyone say where to find the value to determine if i should use "a" or "b" or "c" ...

Thank you

mbi GmbH
 
Posts: 11
Joined: Mon Feb 25, 2013 9:52 am

Mon May 13, 2013 10:48 am

Hi,

Thanks for your inquiry.

Sorry that we couldn't find the testfile you attached, could you please attach it again.
I don't understand your issue completely. Do you mean that the value is "0 Some text" you got at present?
Please provide us more information to help us understand your issue better. And please provide us your code to help us reproduce this issue.

Thanks and Regards,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Wed May 15, 2013 7:39 am

Hi,

thanks for your fast answer.

What i am trying to do is to open the attached rtf-file with spire doc and iterate over the paragraph-collection.
If i find a list i want to transform it programmatically into another type of xml.
But i can't find the start -Value for the nummeration in the object.

If i save the rtf-file via spire doc as html i see the following as a snapshot:
<ol type="A" start="4">
<li class="BA-Geordnete-Liste-alpha-gross-Punkt" style="margin-top:6.030151pt;margin-left:18.0904522pt;text-indent:0pt;background-color:#FFFFFF;"><span style="font-family:'Arial';font-size:11pt;">Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptu</span><span style="font-family:'Arial';font-size:11pt;">a</span><span style="font-family:'Arial';font-size:11pt;">.</span><span style="font-family:'Arial';font-size:11pt;"> At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</span></li>
</ol>

As you can see in the rtf-file is this the part where the list-numbering is a "D" which is in html "start=4". What i have to know is where in the objectmodel is the value "4" coded.

Thank you

mbi GmbH
 
Posts: 11
Joined: Mon Feb 25, 2013 9:52 am

Wed May 15, 2013 10:00 am

Hi,

Thanks for your description and your document, it's clear.
You can get the start number from para.ListFormat.CurrentListLevel.StartAt, we provide you some code
Code: Select all
String inputFile = GetInputFile(@"SALESSUPPORT-1467\HV_ausgezeichnet_mit_Logo.rtf");
Document doc = new Document();
doc.LoadRtf(inputFile, Encoding.UTF8);

Dictionary<String, int> listNumber = new Dictionary<string, int>();

foreach (Section sec in doc.Sections)
{
   foreach (Paragraph p in sec.Paragraphs)
   {
      ListFormat format = p.ListFormat;
      if (format != null && format.CurrentListLevel != null
         && format.CurrentListLevel.PatternType != ListPatternType.Bullet)
      {
         int number = 1;
         if (listNumber.ContainsKey(format.CustomStyleName))
         {
            number = listNumber[format.CustomStyleName] + 1;
         }
         else
         {
            number = format.CurrentListLevel.StartAt;
         }
         listNumber[format.CustomStyleName] = number;

         Console.Write("{0}. ", number);
      }
      Console.WriteLine(p.Text);
   }
}


Some paragraphs have the list with number UpLetter or UpLetter), you could get the indicator from CurrentListLevel.PatternType and more information, for example number format of number text, from the object CurrentListLevel.

If you have any other question, please tell us.

Regards,
Harry
Technical Support / Developer,
e-iceblue Support Team
User avatar

harry.support
 
Posts: 180
Joined: Mon Nov 08, 2010 3:11 pm

Fri May 17, 2013 9:44 am

Hello,

Has the code provided by Harry worked fine for you? Has the issue been resolved? Could you please update the thread if convenience?

If there are any questions, welcome to get it back to us.

Thanks,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Fri May 17, 2013 12:53 pm

Hello,

thanks for the solution. Worked fine.

Please take attention to the other problem i posted with the table and col- and rowspan informations. I need maintenance ASAP.

Greetings

mbi GmbH
 
Posts: 11
Joined: Mon Feb 25, 2013 9:52 am

Return to Spire.Doc