We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Cross Reference / Track Changes Issue

Hi Guys,

we developed a Sharepoint Event Handler to process doc/docx documents for a customer of us.
After some testing they told us that every cross reference is lost after the processing with aspose.words version 9.5.
Another problem occurs if “Track Changes” is activated. e.g.: a text passage, which was deleted before the processing, appears two times in the final document. First as a normal text passage and second red and crossed out (as it should be).

I was able to reproduce the behaviour on our local development machine.

Would you please help us fixing this issue, it’s unfortunately an exclusion criterium for our customer.

Thanks in advance,
Daniel

Hello

Thanks for your inquiry. Could you please attach the input/output documents which will allow me to reproduce the problems on my side? I will check them and provide you more information.

Best regards,

Hello

Thanks for your quick response.
I tried to create a minmal working example, but couldn’t reproduce the problem with this newly created document.
Is it possible that this behaviour depends on the word version which is used to create the documents? We use Word 2010, our customer uses older versions. I will try to get a working example from our customer and provide it to you later this day.

Best Wishes
Daniel

Hello

Thank you for additional information. Yes, there can be difference between documents created using MS Words 2010 and older versions of MS Word.

I will wait for the document.

Best regards,

Hello

please find attached two example documents.

Best Wishes
Daniel

Hi Guys,

we did some further investigation of the problem and I think we have isolated the problem now.
It seems that the aspose.words processing replaces the number of the cross reference by the text of the referenced passage. I could reproduce this behaviour with word 2003, 2007 and 2010 documents.
Please find a minimal working example (Word 2010) in the attachments.

Are you able to fix this bug quickly?

Best regards
Daniel

Hello

Thank you for additional information. I managed to reproduce the problem on my side. Your request has been linked to the appropriate issue. You will be notified as soon as it is fixed.

Currently it is difficult to provide you a reliable estimate regarding this issue. Please expect a reply before the next hotfix within 4-5 weeks. We might just fix the problem by then or provide you more information.

Best regards,

Hello

Thanks for your response.

Unfortunately our customer really need the fix faster. It’s a law office and they can’t deliver corrupt documents to their clients. So we might be forced to use another solution if we don’t know if it’s even fixed after these four to five weeks.
We would be really pleased if you might find a quicker solution.

Thanks in advance and best wishes

Daniel

Hello

Thanks for your inquiry. I added your request to my monthly report, so priority of this issue will be increased. I will notify you as soon as the problem is resolved.

Best regards,

Hello Andrey,

thank you very much.

Are you able to give us a fix date on which the problem will be resolved? We would be grateful if you do so, because we need to tell our customer when they can use their document management system again.

If it’s possible we also would pay for a quick(er) hotfix (within the next two weeks would be great).

Thanks again for your effort
Best wishes
Daniel

Edit: Some additional information:
The error doesn’t appear with our old version of aspose (v5.0.0.0).

Edit 2:
We’ve downloaded version 9.6 and it seems that the error doesn’t exists in this version. It would be great if you can check this behaviour.

Best Wishes

Hi Daniel,

Thanks for your request. I asked our developers to analyze the issue shortly. Once the analysis is finished we will be able to provide you more information. Please expect a reply in few days.

Best regards,

Hi Guys,

unfortunately we discoreved some new problems about the cross references.
Actually the number isn’t replaced by text but when we reference a passage below the first level the number gets some additional digits.
For example:
2.1 -> 2.2.1
3.2 -> 3.3.2
3.2.1 -> 3.3.2.3.2.1

We can revert the changes by refreshing the references.
I have attached a sample document before and after processing.

Could you please try to reproduce the problem at your site and tell us how you plan to fix it.

Best wishes
Daniel

Hello

Thank you for additional information. You will be notified as soon as it is fixed. Once the analysis of this issue is finished we will be able to provide you more information.

Best regards,

Hi,

I have found the same issue. Is this issue prioritised for the next release?

Thanks Bruce

Hello

Thanks for your request.

Unfortunately, the analysis of the issue has not been fully completed. We will inform you about any developments immediately.

Hi Guys,

I’ve tested with version 9.7 now, but the problem still exists. Do you know when this bug is finally fixed? Our customer can’t use his document library for about three months now and they are really unhappy with this situation of course.

best regards
Daniel

Hello

Thanks for your request. Unfortunately, this issue is still unresolved, and I cannot provide you any reliable estimate regarding this at the moment. We will be sure to inform you of any developments regarding this issue.

Best regards,

Hi Daniel,

Your issues are still unresolved however I can provide some further information and a work around which I hope will help for now.

Your first issue (part of the paragraph being included inside the REF field after update) I cannot reproduce using the latest version of Aspose.Words. Could you please double check this on your side as well?

The second issue with the extra numbers in REF fields after update, you can work around by using the code below. The UpdateRefFields method is to be called after any call to UpdateFields.

You can find the helper methods (GetFieldCode, GetFieldResult) required by the method below in this thread here.

Document doc = new Document("Testing.docx");
doc.UpdateFields();
// Update REF fields with the proper values.
UpdateRefFields(doc);
doc.Save("Testing Out.docx");
public static void UpdateRefFields(CompositeNode node)
{
    // The document that this node belongs to.
    Document doc = (Document)node.Document;
    // Update list labels so we can get the list numbers of the paragraphs.
    doc.UpdateListLabels();
    // Each list level is represented by special symbols in the NumberFormat property. By referencing the index of the
    // list level the corresponding symbol can be retrieved.
    string[] listCodes = { "\x0000", "\x0001", "\x0002", "\x0003", "\x0004", "\x0005", "\x0006", "\x0007", "\x0008" };
    // Iterate through all FieldRefs in the Document or CompositeNode. CompositeNode means that this code
    // can run on only certain parts of the document e.g a specific section.
    foreach (FieldStart start in node.GetChildNodes(NodeType.FieldStart, true))
    {
        if (start.FieldType == FieldType.FieldRef)
        {
            // Parse the FieldCode.
            Regex regex = new Regex(@"\s*(?\S+)\s+(?\S+)\s+(?.+)");
            Match match = regex.Match(GetFieldCode(start));
            // Get the paragraph referenced by this field.
            Bookmark bookmark = doc.Range.Bookmarks[match.Groups["bookmark"].Value];
            if (bookmark != null)
            {
                // Get the paragraph that the reference bookmark is contained in.
                Paragraph bookmarkPara = (Paragraph)bookmark.BookmarkStart.ParentNode;
                // Get the current field result.
                string fieldResult = GetFieldResult(start);
                // Get the list number of the paragraph which is the proper result for this switch.
                StringBuilder labels = new StringBuilder();
                // Add the current list levels which are included by this list label.
                int currentLevel = bookmarkPara.ListFormat.ListLevelNumber;
                string baseLevelFormat = bookmarkPara.ListFormat.ListLevel.NumberFormat;
                labels.Append(bookmarkPara.ListLabel.LabelString);
                Node currentNode = bookmarkPara;
                // Iterate through previous paragraphs to find the paragraph of each previous list level
                // Stop if all levels have been processed.
                while (currentNode != null && currentLevel >= 0)
                {
                    if (currentNode.NodeType == NodeType.Paragraph)
                    {
                        Paragraph para = (Paragraph)currentNode;
                        // This paragraph belongs to the same list as the ref field as the bookmark para and is the current level we are looking for.
                        if (para.ListFormat.ListLevelNumber == currentLevel && para.ListFormat.List == bookmarkPara.ListFormat.List)
                        {
                            // We now have the current levels list format. Since we are working backward to find the list strings we
                            // need to insert this at the front of the result.
                            // If the current listlabel we have calculated already includes this level then we don't need to include it again.
                            if (!baseLevelFormat.Contains(listCodes[currentLevel]))
                            {
                                // These list labels are now included by this label. Add them to the base level so they are not included again.
                                baseLevelFormat += para.ListFormat.ListLevel.NumberFormat;
                                labels.Insert(0, para.ListLabel.LabelString);
                            }
                            // Search for the next list level down.
                            currentLevel = para.ListFormat.ListLevelNumber - 1;
                        }
                    }
                    // Search for paragraphs backward.
                    currentNode = currentNode.PreviousSibling;
                }
                // Replace the current field result with the new result. This should retain formatting.
                start.ParentParagraph.Range.Replace(fieldResult, labels.ToString().TrimEnd('.'), false, false);
            }
        }
    }
}

If you have any troubles, please let me know.

Thanks,

Hi,

thank your very much, the work around works like a charm.
I think the first issue was fixed in release 9.6, after upgrading the error was gone.

best wishes
Daniel

Hello,

Thank you for additional information.
In your post, two requests.
#25487 - closed with the reason “Cannot Reproduce”. This means that some code had already fixed the problem.
#23248 - still not solved. We will notify you as soon as this issue will be closed.