Cross Reference identification

Hi

We are using Aspose.Words.dll version 10.5.0.0 to produce highly customized documents.

The generated documents may have cross-reference in them. We are facing problem when there is reference to a heading (only number part of it) or a footnote (not complete only number part of it) or a page number. For ex PFA document in which:
There are references example for footnote, Heading and page number

We are generating output by taking ASPOSe HTML as input. Now in the input HTML, we are not getting any indication or hint that this refers to a heading or a footnote or any page number. Because these are numbers and through only number we cannot identify this number is for heading or for footnote or for page number. Please provide if any solution is possible.
Please find below code for your reference which we have used to generated the html for input word document

string htmlText = string.Empty;
Aspose.Words.Document doc = new Aspose.Words.Document(filepath);
if (doc.Sections != null && doc.Sections.Count > 1)
{
    doc.Sections.RemoveAt(0);
    string lStrImageFolder = string.Empty;
    lStrImageFolder = FolderPath + "/" + ConfigurationManager.AppSettings["HTMLFileFolderName"].ToString();
    string tempDir = Path.Combine(Server.MapPath(lStrImageFolder));
    if (!Directory.Exists(tempDir))
        Directory.CreateDirectory(tempDir);
    Aspose.Words.Saving.HtmlSaveOptions saveOptions = new Aspose.Words.Saving.HtmlSaveOptions();
    saveOptions.ImagesFolder = tempDir;
    saveOptions.CssStyleSheetType = Aspose.Words.Saving.CssStyleSheetType.Embedded;
    saveOptions.SaveFormat = SaveFormat.Html;
    saveOptions.ImagesFolderAlias = ConfigurationManager.AppSettings["HTMLFileFolderName"].ToString();
    doc.JoinRunsWithSameFormatting();
    doc.ExpandTableStylesToDirectFormatting();
    MemoryStream htmlStream = new MemoryStream();
    doc.Save(htmlStream, saveOptions);
    htmlText = Encoding.UTF8.GetString(htmlStream.GetBuffer());
    htmlStream.Close();
    this.HTMLFilePath = FolderPath + "/" + ConfigurationManager.AppSettings["HTMLFileName"].ToString();
    StreamWriter sr = new System.IO.StreamWriter(Server.MapPath(this.HTMLFilePath), false, Encoding.Default);
    StringBuilder strStylePath = new StringBuilder();
    strStylePath.Append(htmlText);
}

So please let us know if is there any way to get the clue at HTML side for identify cross reference source.
Thanks,
Samanvay

Hi
Thanks for your request. I managed to reproduce the problem you request has been linked to the appropriate issue. We will let you know once it is resolved. The problem occurs because Aspose.Words does not support REF fields upon converting document to HTML.
As a temporary workaround, you can simply replace REF fields in your document with HYPERLINK field as suggested here:
https://forum.aspose.com/t/102957
Hope this helps.
Best regards,

Hi ,

Thanks for your quick response.

The above link you have suggested gives us the reference but do not tells us or gives us a clue that it is referring to a heading/page number/footnote.

Please let us know if there is any way we can get this clue.

Thanks,
Samanvay

Hi
Thanks for your request. But it is still not clear for me what you need to achieve. Could you please edit your output HTML so that it looks as you need and attached it here? We will check your expected output and provide you more information.
Best regards,

Hi

Please find below modified HTML of attached input document.We have added one attribute in REF hyperlink which show this cross reference point to page number or footnote.
So is it possible you can provide this type of html while converting the attached input document to HTML using ASPOSE.

<body>
   
    <div>
        <h2>
            <span>1.1</span>
            <span style="font:7.0pt 'Times New Roman'">         </span>
            <a name="_Ref311537694"></a>
            <a name="_Ref311452803"></a>
            <span>asdsadsad</span>
        </h2>
        <p class="Caption">
            <span> </span>
        </p>
        <p class="Caption">
            <span>Figure </span>
            <span>1</span>
            <span>: this is monika</span>
        </p>
        <p class="Graphic">
            <img src="BBA_HTML_files/Aspose.Words.ac991b31-807d-40c1-80e1-593d61ffa89f.001.jpeg" width="543" height="424" alt="155159-__x___Free_Button_Icons.jpg" />
        </p>
        <p class="BodyText">
            <span> </span>
        </p>
        <p class="BodyText">
            <span>this is first paragraph which refer to </span>
            <a href="#_Ref311452803">
                <span>Figure 1: this is monika</span>
            </a>
        </p>
        <p class="BodyText">
            <span> </span>
        </p>
        <p class="BodyText">
            <span>this is section para show in </span>
            <a href="#_Ref311452850">
                <span>Figure 2</span>
            </a>
        </p>
        <p class="BodyText">
            <span> </span>
        </p>
        <p class="Caption">
            <a name="_Ref311452850"></a>
            <span>Figure </span>
            <span>2</span>
            <span> ) this is a demo purpose</span>
        </p>
        <p class="Graphic">
            <img src="BBA_HTML_files/Aspose.Words.ac991b31-807d-40c1-80e1-593d61ffa89f.002.jpeg" width="450" height="338" alt="image-1.jpg" />
        </p>
        <p class="BodyText" style="margin-left:36pt; text-indent:-18pt">
            <span>1.</span>
            <span style="font:7.0pt 'Times New Roman'">       </span>
            <span>Item1</span>
        </p>
        <p class="BodyText" style="margin-left:36pt; text-indent:-18pt">
            <span>2.</span>
            <span style="font:7.0pt 'Times New Roman'">       </span>
            <a name="_Ref311558785"></a>
            <span>item2</span>
        </p>
        <p class="BodyText" style="margin-left:36pt; text-indent:-18pt">
            <span>3.</span>
            <span style="font:7.0pt 'Times New Roman'">       </span>
            <span>item3</span>
        </p>
        <p class="BodyText" style="margin-left:36pt; text-indent:-18pt">
            <span>4.</span>
            <span style="font:7.0pt 'Times New Roman'">       </span>
            <span>item4I</span>
        </p>
        <p class="BodyText" style="margin-left:36pt; text-indent:-18pt">
            <span>5.</span>
            <span style="font:7.0pt 'Times New Roman'">       </span>
            <span>tem5</span>
        </p>
        <p class="BodyText">
            <span> </span>
        </p>
        <p class="BodyText">
            <span> </span>
        </p>
        <p class="BodyText">
            <span>This is a point to list number </span>
            <a href="#_Ref311558785" sourcetype="NumberedListItem">
                <span>2</span>
            </a>
        </p>
        <p class="BodyText">
            <span>This is our new footnote </span>
            <a name="_Ref311558849"></a>
            <a name="_ftnref1"></a>
            <a href="#_ftn1">[1]</a>
        </p>
        <p class="BodyText">
            <span>this is point to footnote </span>
            <a href="#_Ref311558785" sourcetype="footnote">
                <span>1</span>
            </a>            
        </p>
        <p class="BodyText">
            <span>this is point to heading number </span>
            <a href="#_Ref311537694" sourcetype="Heading">
                <span>1.1</span>
            </a>
        </p>
        <p class="BodyText">
            <span>this is point to page number </span>
            <a href="#_Ref311558785" sourcetype="PageNumber">
                <span>2</span>
            </a>
        </p>
        <p class="BodyText">
            <span> </span>
        </p>
    </div>
    <hr style="width:33%; height:1px; text-align:left" />
    <p class="FootnoteText">
        <a name="_ftn1"></a>
        <a href="#_ftnref1">[1]</a>
        <span> Demo</span>
    </p>

</body>

Hi
Thanks for your request. What you added is custom attribute “sourcetype”. In HTML there is no standard tag for this:
https://www.w3schools.com/tags/tag_a.asp
So adding such attribute will make output HTML does not conform the specification.
Also, reference is simple bookmark in source documents. So I do not think it is possible to determine from where the bookmark comes.
Best regards,

@samanvay,

The issues you have found earlier (filed as WORDSNET-1814) have been fixed in this Aspose.Words for .NET 17.7 update and this Aspose.Words for Java 17.7 update.

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan