I noticed that, when converting a Word document to PDF, if the Word document has paragraphs with “Spacing After” set to greater than 0, the layout of PDF gets wierd. I have almost 100 Word Docs serving as templates and this seem to be a general case. Below a snippet of code used :
Aspose.Words.Document doc = new Aspose.Words.Document(requestedFile);
if (passedData != null && passedData.Tables.Count > 0)
{
// simple mail merge on root table
doc.MailMerge.Execute(passedData.Tables[0]);
// mail merge with regions
doc.MailMerge.ExecuteWithRegions(passedData);
}
MemoryStream stream = new MemoryStream();
doc.Save(stream, Aspose.Words.SaveFormat.AsposePdf);
// Read the xml into Aspose.Pdf.
Aspose.Pdf.Pdf pdf = new Aspose.Pdf.Pdf();
pdf.BindXML(stream, null);
stream.Close();
// Add these two lines to Speed up the conversion
pdf.IsTruetypeFontMapCached = true;
pdf.TruetypeFontMapPath = System.IO.Path.GetTempPath();
// pdf to response
pdf.Save("output.pdf");