Formatting issue observered with new version of Aspose dll version V23

@alexey.noskov please find the sample working solution which has exact scenario which we are trying to explain. please note that the issue occurring on V23 and not on V14 the snapshot which shared in prior discussion

AsposeFormIssuePOC.zip (112.4 KB)

@osakpal Thank you for additional information, but the MC_CovComprehensive_NotWorking.docx file specified in the XML file is not attached. Could you please attach it here too.

@alexey.noskov can you refer previous threads where file is already shared.

image.png (5.7 KB)

@osakpal The code you have provided can be simplified to the following:

string rootPath = @"C:\Temp";

Document mainDoc = new Document($"{rootPath}\\MC_CovComprehensive_NotWorking.docx");
// Load the additional documents to be appended
Document Subdoc1 = new Document($"{rootPath}\\MC_Header_Cov_Line.docx");
Document Subdoc2 = new Document($"{rootPath}\\MC_CovLineBodilyInjury_notWorking.docx");
Document Subdoc3 = new Document($"{rootPath}\\MC_CovLinePropertyDamage.docx");
Document Subdoc4 = new Document($"{rootPath}\\MC_CovSafetyRidingApparel.docx");
Document Subdoc5 = new Document($"{rootPath}\\MC_CSCredit.doc");
// Append the documents to the main document
mainDoc.AppendDocument(Subdoc1, ImportFormatMode.KeepSourceFormatting);
mainDoc.AppendDocument(Subdoc2, ImportFormatMode.KeepSourceFormatting);
mainDoc.AppendDocument(Subdoc3, ImportFormatMode.KeepSourceFormatting);
mainDoc.AppendDocument(Subdoc4, ImportFormatMode.KeepSourceFormatting);
mainDoc.AppendDocument(Subdoc5, ImportFormatMode.KeepSourceFormatting);

foreach (Section s in mainDoc.Sections)
{
    s.PageSetup.SectionStart = SectionStart.Continuous;
}
//Save the Form into PDF
string filename = $"{rootPath}\\MergerSampleDocument_14.8.pdf";
mainDoc.Save(filename, SaveFormat.Pdf);

I have tested the code with 24.8 and 14.8 versions and here are the results:
MergerSampleDocument_14.8.pdf (59.4 KB)
MergerSampleDocument_24.8.pdf (59.3 KB)

The result produced by 24.8 version is closer to DOCX document:
out_14.8.docx (17.8 KB)
out_24.8.docx (19.7 KB)

So the output produced by the latest version is correct and corresponds the document layout displayed by MS Word.

@alexey.noskov we have implemented the same into our solution however still some formatting issues

can you please let us know why these forms are working correctly in V14 and not in V23

@osakpal Could you please attach the the problematic DOCX and PDF documents produced on your side? It looks like some font substitution issue. Have you tried implementing IWaringCallback?

@alexey.noskov Please find the V14 and v23 word document which has formatting and font issues. also we have attached the output PDF files for your reference.

Input form 1 for doc
Worksheet_Header_1.docx (21.3 KB)

Worksheet_Line_Fee_2.docx (14.8 KB)

Worksheet_Header_1.docx (21.3 KB)

Output of this using V14 and V23 are as follows

V14_form1.pdf (61.2 KB)

V23_form1.pdf (62.0 KB)

Form 2 which has issues as well as follows
input document
MC_Header_Cov_Line.docx (17.3 KB)

MC_CovLineBodilyInjury_notWorking.docx (17.0 KB)

MC_CovLinePropertyDamage.docx (16.9 KB)

MC_Header_Cov_Risk.docx (16.7 KB)

App_Street_PaymentOption.docx (33.2 KB)

output form 2
V14_Form2_output.pdf (368.3 KB)

V23_form2_output.pdf (381.6 KB)

In addition, there is an observation from our side is that while merging the main document with subdocument V14 is applying the format setting of main document. While in V23 we observed that the settings are getting applied which is of subdocument and not of main document. Is this something that has been changed inside the aspose DLL ? it can be observed in form 1 for the font issue.

@osakpal Thank you for additional information. But unfortunately, I cannot reproduce the problem on my side. In your template you have merge fields, which are filled before merging documents. I tried with dummy data and the above provided code to merge the documents, but the problem is not reproducible. Is the problem reproducible on your side if save the output as DOCX? If not, is the problem reproducible if convert the output DOCX to PDF?

@alexey.noskov the issue is reproducible if convert the output DOCX to PDF. Also,

can you also confirm below observation
In addition to this there is an observation from our side is that while merging the main document with subdocument V14 is applying the format setting of main document. While in V23 we observed that the settings are getting applied which is of subdocument and not of main document. Is this something that has been changed inside the aspose DLL ? it can be observed in form 1 for the font issue.

@osakpal

Could you please attach your output DOCX documents?

As far as I know there were no changes in this behavior. As you can see you are using ImportFormatMode.KeepSourceFormatting in this mode Aspose.Words should preserve the original documents formatting.

@alexey.noskov Please find the sample docx file and output generated using Aspose V23.
Please note that the same document rendering correctly in Aspose V14.

SampleDocx.docx (16.7 KB)

AlignmentIssue.pdf (53.0 KB)

@osakpal Unfortunately, I still cannot reproduce the problem. I used the following code for testing:

Document doc = new Document(@"C:\Temp\in.docx");
doc.Save(@"C:\Temp\out_23.2.pdf");

out_23.2.pdf (50.4 KB)
out_24.9.pdf (50.5 KB)

@alexey.noskov Please refer to the POC solution created by me location in discussion thread above. Find the snippet for same

use the following documents and copy paste into \Document folder

623e9540-f174-40c0-9dba-e028a79df6ba-MC_CovLineBodilyInjury_3_t-1.docx (11.6 KB)

623e9540-f174-40c0-9dba-e028a79df6ba-MC_CovLineBodilyInjury_3_t-2.docx (12.9 KB)

623e9540-f174-40c0-9dba-e028a79df6ba-MC_CovLineBodilyInjury_3_t-3.docx (13.3 KB)

623e9540-f174-40c0-9dba-e028a79df6ba-MC_CovLineBodilyInjury_3_t-4.docx (13.5 KB)

623e9540-f174-40c0-9dba-e028a79df6ba-MC_CovLineBodilyInjury_3_t-5.docx (13.7 KB)

In AsposeV23PDFPopulator.cs change the following lines as (This is to generate pdf of shared document above)

foreach (System.Xml.XmlElement subDoc in subDocs)
{
    string sourceFile = GetSubdocSourceFile($"{rootPath}\\623e9540-f174-40c0-9dba-e028a79df6ba-MC_CovLineBodilyInjury_3_t-1.docx", subDoc);
    finalDocument = AddSubDoc(sourceFile, subDoc);
}

In AddSubDoc document method reference the document attached as

try
{
    // Load the additional documents to be appended
    Aspose.Words.Document Subdoc1 = new Aspose.Words.Document($"{rootPath}\\623e9540-f174-40c0-9dba-e028a79df6ba-MC_CovLineBodilyInjury_3_t-2.docx");
    Aspose.Words.Document Subdoc2 = new Aspose.Words.Document($"{rootPath}\\623e9540-f174-40c0-9dba-e028a79df6ba-MC_CovLineBodilyInjury_3_t-3.docx");
    Aspose.Words.Document Subdoc3 = new Aspose.Words.Document($"{rootPath}\\623e9540-f174-40c0-9dba-e028a79df6ba-MC_CovLineBodilyInjury_3_t-4.docx");
    Aspose.Words.Document Subdoc4 = new Aspose.Words.Document($"{rootPath}\\623e9540-f174-40c0-9dba-e028a79df6ba-MC_CovLineBodilyInjury_3_t-5.docx");

    // Append the documents to the main document
    mainDoc.AppendDocument(Subdoc1, ImportFormatMode.KeepSourceFormatting);
    mainDoc.AppendDocument(Subdoc2, ImportFormatMode.KeepSourceFormatting);
    mainDoc.AppendDocument(Subdoc3, ImportFormatMode.KeepSourceFormatting);
    mainDoc.AppendDocument(Subdoc4, ImportFormatMode.KeepSourceFormatting);

Input given as

Output coming as

@omkars Thank you for additional information. I finally managed to reproduce the problem on my side. It can be reproduced by simple conversion of 623e9540-f174-40c0-9dba-e028a79df6ba-MC_CovLineBodilyInjury_3_t-5.docx document to PDF.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WORDSNET-27399

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Hello @alexey.noskov , Additionally we also found below issues, here header of table is shifting towards right compared to input doc. And we also observed output is different in v14 and v23. Aspose v14 was working correctly.

Input doc-

v23 Output

v14 Output

Please find below screenshots our client faced alignment issues, which was working fine in v14

v23 Output


v14 Output

Attached below input docx
MC_PremiumSection.docx (15.9 KB)

MC_Header_Cov_Line.docx (17.3 KB)
MC_CovLineBodilyInjury_notWorking.docx (17.0 KB)

MC_CovLinePropertyDamage.docx (16.9 KB)

MC_CovLineMedicalPayments_5.docx (17.0 KB)

MC_CovLineUninsuredMotoristBodilyInjury_6.docx (17.0 KB)

Attached below v23 output pdf
v23_OutputPDF.pdf (54.3 KB)

@soma.das Looks like the same problem as WORDSNET-27399. We will keep you informed and let you know once it is resolved.

@alexey.noskov can you able to tell us what word docs cause this problem? is there a specific criterion to check those forms which would cause an issue for aspose during merge and conversion?

@osakpal The issue occurs because MS Word merges adjacent tables with different indents, and Aspose.Words does not.

The document appears to be generated by Aspose.Words. In the source xml, there are three consecutive w:tbl elements. MS Word treats them as a single table. Aspose.Words does not merge the tables because of different table attributes. Specifically, table 1 and table 2 have different left indents specified. Apparently, the logic that checks if a pair of tables can be merged should be revised.

For now the issue has been postponed and is not yet scheduled for development.

@alexey.noskov Any further update when the fix will be avaible?

@osakpal Unfortunately, there are no news regarding this issue yet.