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

Free Support Forum - aspose.com

Problem: Incorrect numbering set when merging document with numbered paragraph

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

I have a problem merging documents which are part of numbering paragraph, when the document is merged; the numbering is not set if the merged block has more that one paragraph numbered already.

The following is the result when merging the document:

Not Ok

Die Parteien vereinbaren was folgt:

1. Das Arbeitsverhältnis zwischen [%Vorname%] [%Name%] und UBS wird auf den [TT. Monat JJJJ] im gegen­seitigen Einverständnis aufgelöst. [%Vorname%] [%Name%] ist sich bewusst, dass damit die gesetzlichen Folgen über den Kündigungsschutz des Arbeitnehmers keine Anwendung finden.

1. In Absprache mit dem Linienvorgesetzten wird [%Vorname%] [%Name%] bis zum Auflösungszeitpunkt ([Datum]) verbleibende Ferientage beziehen und allfällige übrige Zeitguthaben (z.B. Überzeit, Gleitzeit- und Kompensationsstunden) kompensieren. Was aus betrieblichen Gründen nicht bezogen bzw. kompensiert werden kann, wird in Absprache mit dem Linienvorgesetzten und mit Human Resources zusammen mit dem letzten Salär finanziell abgegolten.

1. UBS bezahlt [%Vorname%] [%Name%] bis zum Auflösungszeitpunkt ([Datum]) weiterhin das vertraglich vereinbarte Salär, abzüglich der üblichen Arbeitnehmerbeiträge.

2. [%PauschalSpesen_BS49%]UBS entrichtet auf Ende [%Vorname%] [%Name%][Monat JJJJ] unpräjudiziell und ohne Anerkennung einer diesbezüglichen Rechtspflicht eine Einmalzahlung "ex gratia" von CHF [Betrag] brutto, abzüglich der üblichen Arbeitnehmerbeiträge.

3. Auf Ende [Monat JJJJ] entrichtet UBS eine [%Vorname%] [%Name%]Abgangsentschädigung von CHF [Betrag] brutto, abzüglich der üblichen Arbeitnehmerbeiträge.

Expected is to have 1,2,3,4 and 5.

The problem as I exposed before is when the document being merged has got more than numbered paragraph is only 1 paragraph, there is no problem, please notice that blue and green are merged document, and they have numbering "1. " each but just one paragraph while orange document has got 1., 2., 3. Paragraph.

I attach a small solution where the problem can be reproduced; I appreciate your help in advance.

Best regards

Josue Medrano

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. This occurs because list items that you insert into the document are members of another list. I tried to modify InsertDocumentAtBookmark method to fix this. See the attached document.

Best regards.

Hi Alexey, Thanks for your reply.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

The code you provided me solved part of the problem, but still doesn't accomplish my requirements entirely.

for example:

a. if the main Template does not have numbering but the marged document has, then it is marged with incorrect numbering set, see sample 1.

b. When the marged document has numbering, the namering is inherited for all other paragraphs, although not part of numbering, see sample 2

in here " This piece of text doesn't is not longer…" is not longer part on the numbering.

I attach the solution to reproduce the problem

I appreciate your help in advance.

kind regards

Josue

Sample 1

Das Arbeitsverhältnis zwischen [%Vorname%] [%Name%] und UBS wird auf den

1. In Absprache mit dem Linienvorgesetzten wird [%Vorname%] [%Name%] bis zum.

UBS bezahlt [%Vorname%] [%Name%] bis ..

Sample 2

1. Das Arbeitsverhältnis zwischen [%Vorname%] [%Name%] und UBS wird auf den

2. In Absprache mit dem Linienvorgesetzten wird [%Vorname%] [%Name%] bis zum.

3. UBS bezahlt [%Vorname%] [%Name%] bis ..

4. This piece of text doesn't is not longer part of the numbering Test ************************************************************************************************************************************************************************************************************************************************************

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. I fixed the first problem in your code (see attached file.). But the second one is not a bug. This occurs because you insert one more paragraph insertBeforeParagraph. If bookmark is placed in the list item then the following code will insert one more list item

builder.MoveToBookmark(bookmarkName, false, true);

//builder.MoveToBookmark(bookmarkName);

builder.Writeln();

And the last paragraph of merged document will be inserted into the list item.

You can try play around in your code or in the document to solve this problem.

Best regards.

Thanks Alexey, <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

I fixed the problem by removing the ListFormat.RemoveNumbers() if paragraph being insert and current paragraph in the document are not ListItem.

However, I found a problem in one of the problem regarding one of the previews issues.

I need to insert a bookmark on every place holder in the main doc as well in the merged template.

You told me that some times run carries more than one run, therefore we create a splitter (SplitRunsReplaceEvaluator), the splitter works most of the times, but when I run it for this spletter for some merged documents the order of words changes, I cannot figure out why it does this. See Result:

Not Ok

UBS entrichtet auf Ende [%Vorname%] [%Name%][Monat JJJJ] unpräjudiziell und ohne Anerkennung einer diesbezüglichen Rechtspflicht eine Einmalzahlung "ex gratia" von CHF [Betrag] brutto, abzüglich der üblichen Arbeitnehmerbeiträge.

Original template: (BS49_Bonus_d.doc)

UBS entrichtet [%Vorname%] [%Name%] auf Ende [Monat JJJJ] unpräjudiziell und ohne Anerkennung einer diesbezüglichen Rechtspflicht eine Einmalzahlung "ex gratia" von CHF [Betrag] brutto, abzüglich der üblichen Arbeitnehmerbeiträge.

The only think expected was to insert a bookmark for [%Vorname%] and [%Name%].

Why we do this? –Sometimes we need to merge a document into another document merged.

I provide you my Test solution again, where the problem can be reproduced.

Once again I appreciate very much your help.

Best regards,

Josue

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. Please try using the following code:

private ReplaceAction SplitRunsReplaceEvaluator(object sender, ReplaceEvaluatorArgs e)

{

//Get MatchNode

Run run1 = (Run)e.MatchNode;

//Create Run

Run run2 = (Run)run1.Clone(true);

//Run run2 = new Run(e.MatchNode.Document);

run2.Font.Style = run1.Font.Style;

//Get index of match value

int index = run1.Text.IndexOf(e.Match.Value);

//Split text in match node

run2.Text = run1.Text.Substring(index);

run1.Text = run1.Text.Replace(run2.Text, "");

run1.ParentParagraph.InsertAfter(run2, run1);

DocumentBuilder builder = new DocumentBuilder(e.MatchNode.Document);

builder.MoveTo(run2);

builder.StartBookmark(e.Match.Groups["name"].Value);

if(run2.NextSibling != null)

builder.MoveTo(run2.NextSibling);

else

builder.MoveTo(run2.ParentParagraph);

builder.EndBookmark(e.Match.Groups["name"].Value);

return ReplaceAction.Skip;

}

Also you should note that document can’t contain multiple bookmarks with same name. I see that your template document “Template_d_GWMBB.doc” and “BS49_Bonus_d.doc” contains placeholders with same text. There are no problems if you insert values into the sub document before inserting it into the main document. But if you insert sub document into the main document before then bookmarks with duplicated names will be removed.

Best regards.

The issues you have found earlier (filed as WORDSNET-5251) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(16)