Issue regarding End notes numbering

Hello,

We have purchased Aspose. Words license and implementing Words functionality in one of our project.

Word document with EndNote,in this end note contains numbers like

1 EndNote Import Test
2 Test endnote
3 Endnote Import Test 2

but while importing document displaying with Roman numbers like

i EndNote Import Test
ii Test endnote
iii Endnote Import Test 2

We have already raised the query in the below link

Please go through the forum thread once as it is urgent requirement.

Another Issue is when we read document which contains 5 endnotes,

Refer --> Screen shot with total Endnotes in the document.png

First 3 endnotes located in the first section content and other 2 endnotes in the section section content.

Refer -->Endnotes in the different Sections.png

Endnotes should display in the following order

Refer --> Expected Endnotes in the different Sections.png

The functionality implementation has stopped because of this issue. Kindly resolve this issue and update us ASAP, so that we can continue.

Below is the code using in the application

License lic = new License();
lic.SetLicense("Aspose.Words.lic");

// Document doc = new Document(@"E:\\Regeneron CCDS Template_revised draft 23Oct2015_FU4.docx");
Document doc = new Document(@"D:\\Regeneron\\Regeneron Roman.docx");
Document finalDoc = (Document)doc.Clone(false);

finalDoc.RemoveAllChildren();
ArrayList tocBookmarks = new ArrayList();
foreach (Field field in doc.Range.Fields)
{
    if (field.Type.Equals(FieldType.FieldHyperlink))
    {
        FieldHyperlink link = (FieldHyperlink)field;
        string fieldCode = link.GetFieldCode();
        if (fieldCode.Contains("_Toc"))
        {
            tocBookmarks.Add(link.SubAddress);
        }
    }
}

doc.UpdateListLabels();

for (int i = 0; i < tocBookmarks.Count; i++)
{
    Paragraph startPara = (Paragraph)doc.Range.Bookmarks[tocBookmarks[i].ToString()].BookmarkStart.ParentNode;
    // Console.WriteLine(startPara.ToString(SaveFormat.Text));
    divheading.InnerHtml += startPara.ToString(SaveFormat.Text) + "";
    Paragraph endPara;
    if (i + 1 == tocBookmarks.Count)
        endPara = doc.LastSection.Body.LastParagraph;
    else
        endPara = (Paragraph)doc.Range.Bookmarks[tocBookmarks[i + 1].ToString()].BookmarkStart.ParentNode;
    if (endPara != null)
    {
        ArrayList extractedNodes = ExtractContent(startPara, endPara, true);
        Document dstDoc = GenerateDocument(doc, extractedNodes);
        dstDoc.FirstSection.Body.Paragraphs[1].Remove();
        if (i + 1 != tocBookmarks.Count)
            dstDoc.LastSection.Body.LastParagraph.Remove();
        divheading.InnerHtml += dstDoc.ToString(SaveFormat.Html) + "";

        finalDoc.AppendDocument(dstDoc, ImportFormatMode.UseDestinationStyles);
    }
}

Please find the total code and source doucment as an attachment(s) to this mail.

Thanks

Hi Srini,

Thanks for your inquiry. I have generated and attached ‘15.12.0.html’ here for your reference. The output is correctly produced on my side using your code. I don’t know how are you using ‘divheading’ variable. To ensure a timely and accurate response, please create a standalone simple console/web application (source code without compilation errors) that helps me reproduce your problem on my end and attach it here for further testing.

Best regards,

Hi Hafeez,

Thank you for your reply. Sending sample application as an attachment to this mail.

Run the application and update the code in the application(if neeed) itself.

“divheading” used in the code is a
control.

Please check it and update ASAP.

Another requirement is to customize my code to set the endnote numbering to a specific type i mean either the document contains endnote numbering as
Characters(a,b,c,d,e…) or Capitial Characters(A,B,C,D,E…) or Numbers(1,2,3,4,5…) or Roman Numbers(i,ii,iii,iv…)

we need to set the endnote numbering to Numbers only(1,2,3,4,5…so on)

Please share the code regarding customize endnote numbering to a specific type.

Thanks

Hi Srini,

Thanks for your inquiry. We are working over your query and will get back to you soon.

Best regards,

Hi,

The problem with the code shared by Aspose is the numbering of the endnote is resetting for every section content in the document.

The root cause is in the method ( Generate Document) because for every iteration it is creating a new document object so the endnote number is resetting.

But our requirement is to get the endnotes without resetting.

Our requirement is to read each and every section of the document one by one and section name and section content and save to data table, so completely reading the document at a time didn’t work for us.

So please provide solution for reading one by one section without resetting the EndNote numbers.

Below is the code shared by Aspose

Document doc = new Document(MyDir + @"Regeneron+CCDS+Template_revised+draft+23Oct2015_FU4.docx");
Document finalDoc = (Document)doc.Clone(false);
finalDoc.RemoveAllChildren();
ArrayList tocBookmarks = new ArrayList();
foreach (Field field in doc.Range.Fields)
{
    if (field.Type.Equals(FieldType.FieldHyperlink))
    {
        FieldHyperlink link = (FieldHyperlink)field;
        string fieldCode = link.GetFieldCode();
        if (fieldCode.Contains("_Toc"))
        {
            tocBookmarks.Add(link.SubAddress);
        }
    }
}

for (int i = 0; i < tocBookmarks.Count; i++)
{
    Paragraph startPara = (Paragraph)doc.Range.Bookmarks[tocBookmarks[i].ToString()].BookmarkStart.ParentNode;
    Paragraph endPara;
    if (i + 1 == tocBookmarks.Count)
        endPara = doc.LastSection.Body.LastParagraph;
    else
        endPara = (Paragraph)doc.Range.Bookmarks[tocBookmarks[i + 1].ToString()].BookmarkStart.ParentNode;

    if (endPara != null)
    {
        ArrayList extractedNodes = ExtractContent(startPara, endPara, true);
        Document dstDoc = GenerateDocument(doc, extractedNodes);
        dstDoc.FirstSection.Body.Paragraphs[1].Remove();
        if (i + 1 != tocBookmarks.Count)
            dstDoc.LastSection.Body.LastParagraph.Remove();
        finalDoc.AppendDocument(dstDoc, ImportFormatMode.UseDestinationStyles);
    }
}
finalDoc.Save(MyDir + @"15.11.0.html");```

Hi Srini,

Thanks for the additional information. We are checking this scenario and will get back to you soon.

Best regards,

Hi Hafeez,

Thanks for your reply. As it is the very urgent requirement please resolve it as soon as possible.

Let me the status of the issue.

Thanks

Hi Srini,

Thanks for your inquiry. You can use Footnote.ReferenceMark property to get/set custom reference mark to be used for this footnote. Default value is Empty, meaning auto-numbered footnotes are used. If this property is set to Empty or null, then IsAuto property will automatically be set to true, if set to anything else then IsAuto will be set to false. RTF-format can only store 1 symbol as custom reference mark, so upon export only the first symbol will be written others will be discard. Hope, this helps.

Best regards,

Hi Hafeez,

Thanks for your reply. As our requirement is regarding EndNote not the Footnote.

As i shared my code in the thread go through it and update the code(if required) and send back.

please share code to resolve the issue.

Thanks

Hi Srini,

Thanks for your inquiry. Please note that the Footnote class is used to represent both footnotes and endnotes in a Word document. It represents a container for text of a footnote or endnote.

Best regards,

Hi,

When i try to apply Footnote.ReferenceMark property it is not working on my side.

Please update my code with Footnote.ReferenceMark property and produce the required output.

please share the code

Thanks

Hi Srini,

Thanks for your inquiry.

*Srini:
Another requirement is to customize my code to set the endnote numbering to a specific type i mean either the document contains endnote numbering as
Characters(a,b,c,d,e…) or Capitial Characters(A,B,C,D,E…) or Numbers(1,2,3,4,5…) or Roman Numbers(i,ii,iii,iv…)

we need to set the endnote numbering to Numbers only(1,2,3,4,5…so on)

Please share the code regarding customize endnote numbering to a specific type.*

We have logged this requirement in our issue tracking system as WORDSNET-13086. Our product team will further look into the details of this problem and we will keep you updated on the status of this issue. We apologize for your inconvenience.

Best regards,

Hi Srini,

Regarding WORDSNET-13086, please see attached input/output documents and try running the following code to specify the number format for automatically numbered footnotes or endnotes.

Document doc = new Document(MyDir + @"input.docx"); 
doc.FirstSection.PageSetup.EndnoteOptions.NumberStyle = NumberStyle.LowercaseLetter;
doc.Save(MyDir + @"16.1.0.docx");

Not all number styles are applicable for this property. For the list of applicable number styles see the Insert Footnote or Endnote dialog box in Microsoft Word. If you select a number style that is not applicable, Microsoft Word will revert to a default value.

Hope, this helps.

Best regards,