Footnote problems with mailmerge


I have a word document ( doc or docx ) with footnote that need to appear on certains conditions.

I use a pre-made document loaded in Aspose.Words.Document and try to do a mail merge with a datatable and it works except the footnote number change from 3 to 5 and duplicate footnote appears on the bottom of the page.

Another problem is that the footnote appear even if the conditionnal does not want the note to appear.

I'm wondering how I could make it works with footnotes.

my code is basically :

Dim doc As Aspose.Words.Document = ... loading document Choix retraite.doc

' datatable is define before
doc.MailMerge.Execute(dataTable)

Dim outStream As MemoryStream = New MemoryStream()

' saving to pdf outstream
doc.Save(outStream, SaveFormat.Pdf)

' saving to disk
IO.File.WriteAllBytes("C:\temp\tests\Choix retraite.pdf", outStream.ToArray())

I can sen list of datatable columns use.

Public NotInheritable Class FormulaireChoixRetraiteReleveRetraiteRrfsMergeField
Public Const Certificat = "CERTIFICAT"
Public Const DateDeRetraiteMot = "DDRET_mot"
Public Const NomComplet = "Nom"
Public Const Option1 = "OP1"
Public Const Option1Reversible = "OP1R"
Public Const Option2 = "OP2"
Public Const Option3 = "OP3"
Public Const Option4 = "OP4"
Public Const Option5AP = "OP5AP"
Public Const Option5AV = "OP5AV"
Public Const Option5ReveribleAP = "OP5RAP"
Public Const Option5ReversibleAV = "OP5RAV"
Public Const Option6AP = "OP6AP"
Public Const Option6AV = "OP6AV"
Public Const Option7AP = "OP7AP"
Public Const Option7AV = "OP7AV"
Public Const Option8AP = "OP8AP"
Public Const Option8AV = "OP8AV"
Public Const RenteViagere = "RENT_VIAG"
Public Const RenteDifferee = "RTEDIFF"
Public Const TermeOptionRente = "PERIODETEMP"
End Class

' exemple of data table construction with unit test

_
Public Sub With_Document_ReleveRetraite()

Dim mms As IMailMergeService = New MailMergeService()

Dim table As DataTable = New DataTable()

table.Columns.Add(New DataColumn("SexeAbbreviation"))
table.Columns.Add(New DataColumn("NomComplet"))
table.Columns.Add(New DataColumn("Adresse_1"))
table.Columns.Add(New DataColumn("Adresse_2"))
table.Columns.Add(New DataColumn("Date de retraite"))
table.Columns.Add(New DataColumn("Remboursement"))
table.Columns.Add(New DataColumn("Frais"))
table.Columns.Add(New DataColumn("CotVol non immo"))
table.Columns.Add(New DataColumn("CotVol immo"))
table.Columns.Add(New DataColumn("Rente différée"))
table.Columns.Add(New DataColumn("AGE", GetType(Decimal)))
table.Columns.Add(New DataColumn("OP5AP", GetType(Decimal)))

Dim row As DataRow = table.NewRow()
row("SexeAbbreviation") = "Clifton"
row("NomComplet") = "Marc"
row("Adresse_1") = "Marc"
row("Adresse_2") = "123213 sadsd"
row("Date de retraite") = "1er janvier 2013"
row("Remboursement") = "Marc"
row("CotVol non immo") = "Marc"
row("Rente différée") = "Marc"

row("AGE") = 66
row("OP5AP") = 10
...
adding all data row values

table.Rows.Add(row)

Const templatePath As String = "C:\temp\tests\Choix retraite.doc"
Dim documentTemplate As Aspose.Words.Document = New Aspose.Words.Document(templatePath)
Dim data As Byte() = mms.Merge(documentTemplate, table)

IO.File.WriteAllBytes("C:\temp\tests\Choix retraite.pdf", data)

Assert.That(data, Iz.Not.Null)

End Sub


tanks

Jonatan

Hi Jonatan,

Thanks for your inquiry. To ensure a timely and accurate response, it would be great if you please create a standalone/runnable simple application (for example a Console Application Project) that helps me reproduce your problem on my end and attach it here for testing. As soon as you get this simple application ready for me, I'll start investigation into your issue and provide you more information. Thanks for your cooperation.

Best regards,

Hi,

I have add a console app MailMergeExample.zip that you could use to execute directly by command line.

Type : TestMailMerge.exe Choixretraite.doc

or

Type : TestMailMerge.exe Choixretraite.docx

The PDF output of the programs goes in Documents folder identify by the name ChoixRetraite_NumberXXXX.pdf.

I have also include a visual studio .net 2012 project solution TestMailMerge.Zip use to do this example.

Tanks

Hi Jonatan,

Thanks for the additional information. I tested the scenario and have managed to reproduce the same problem on my side. For the sake of correction, I have logged this problem in our issue tracking system as WORDSNET-8852. Our development team will further look into the details of this problem and we will keep you updated on the status of correction. We apologize for your inconvenience.

Best regards,
Hi Jonatan,

I'm very sorry to share with you that on further investigation our development team came to know that they won't be able to implement the fix to your issue. Your issue is now closed with ''Won't Fix'' resolution. This means the issue is not actually fixed but closed because Aspose.Words correctly mimics the behaviour of Microsoft Word. To illustrate the correctness of Aspose.Words, I have attached a simple document here for your reference. If you open it in Microsoft Word and then press F9 then a second footnote will be added. So, this is the expected behaviour. If we can help you with anything else, please feel free to ask.

Best regards,