Hello Support
I am using aspose word mail merge feature.where word template contains good formatting ,but after mail merge and save as pdf there is some formatting issue.please check
source file: ACCI Certificate of Origin ChAFTA.docx
Output file: a8512d10-8b99-4a21-9497-5502f348e3df.pdf
- Your input Word document.
- Please attach the output document that shows the desired behavior.
- Please create a standalone console application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.
please find sample code as AsposeSampleApp.part01,02,03,04.rar
sample input file: Test.DOCX
sample output file: output.docx
Issue highlight as:
Thanks for your help , can you send me API example.
Document doc = new Document(MyDir + "test.docx");
LayoutCollector collector = new LayoutCollector(doc);
LayoutEnumerator enumerator = new LayoutEnumerator(doc);
MarkHeaderFooterBoundaries(enumerator);
Table table = (Table)doc.FirstSection.Body.Tables[0];
Paragraph paragraph = (Paragraph)table.NextSibling;
var renderObject = collector.GetEntity(paragraph);
enumerator.Current = renderObject;
RectangleF location = enumerator.Rectangle;
//Add row to table
table.Rows.Add(table.LastRow.Clone(true));
foreach (Cell cell in table.LastRow.Cells)
{
cell.RemoveAllChildren();
cell.EnsureMinimum();
}
table.LastRow.RowFormat.HeightRule = HeightRule.Exactly;
table.LastRow.RowFormat.Height = footerposition - location.Y;
Aspose.Words.Saving.DocSaveOptions docOptions = new Aspose.Words.Saving.DocSaveOptions();
docOptions.SaveFormat = Aspose.Words.SaveFormat.Doc;
doc.Save(MyDir + "Out v16.12.0.doc", docOptions);
static double footerposition = 0;
public static double MarkHeaderFooterBoundaries(LayoutEnumerator enumerator)
{
do
{
if (enumerator.MoveLastChild())
{
MarkHeaderFooterBoundaries(enumerator);
enumerator.MoveParent();
}
if (enumerator.Type == LayoutEntityType.HeaderFooter)
{
if (enumerator.Kind.Equals("PRIMARYFOOTER"))
footerposition = enumerator.Rectangle.Top;
}
// Stop after all elements on the page have been proceed.
if (enumerator.Type == LayoutEntityType.Page)
return 0;
} while (enumerator.MovePrevious());
return 0;
}
Thanks for your help
Issue yet not resolved
please find attachment provided code behaving differently.