Free Support Forum - aspose.com

Word to PDF - Spacing After/Before messing up PDF layout

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);<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

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");

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

Thank you for your inquiry.

Spacing before and after are handled sometimes incorrectly. It’s a known issue. But to make any conclusions I’d like to see one of the templates you are using in Mail Merge. Please attach it here in the forum.

Regards,