Free Support Forum - aspose.com

Conversion from Word to PDF losing some document formatting

When I convert my Word document to PDF using the following code, some of the lines do not show up and most of the boxes do not show up. Is my conversion code incorrect, or is there a bug? The Word document after mail merge has the boxes and lines correct, so I think the problem is with the conversion to PDF. Thanks. I would attach the files for you, but I don't see an option to do that.

Document doc = new Document(stream);

doc.MailMerge.ExecuteWithRegions(dataSet);

doc.Save(@"c:\temp.doc");

MemoryStream mergedStream = new MemoryStream();

// save to special pdf/xml format

doc.Save(mergedStream, SaveFormat.FormatAsposePdf);

//Seek to the beginning so it can be read by XmlDocument.

mergedStream.Seek(0, SeekOrigin.Begin);

//Load the document into an XmlDocument

XmlDocument xmlDoc = new XmlDocument();

xmlDoc.Load(mergedStream);

//Load the XML document into Aspose.Pdf

Pdf pdf = new Pdf();

//Make sure the images that were saved by Aspose.Words into Windows temporary

//folder are automatically deleted by Aspose.Pdf when they are no longer needed.

pdf.IsImagesInXmlDeleteNeeded = true;

pdf.BindXML(xmlDoc, null);

//*** Aspose.Pdf font cache, see comments below.

pdf.IsTruetypeFontMapCached = false;

//If you convert to PDF multiple files in your application,

//uncomment the following lines to improve the speed of conversion.

//pdf.IsTruetypeFontMapCached = true;

//pdf.TruetypeFontMapPath =

MemoryStream pdfStream = new MemoryStream();

//Now produce the PDF file.

pdf.Save(pdfStream);

Thanks for considering Aspose.

Please contact me at kevin.zuo@aspose.com.

We will investigate this issue and respond you ASAP.

Thanks for considering Aspose.

The boxes and lines not shown is because of lack supports of Aspose.Words. In Drawing Objects only Images and textboxes are rendered, other shapes are ignored when doing convertion. Here is the illustration about this issue at :

http://www.aspose.com/Wiki/default.aspx/Aspose.Words/DrawingObjectsIssues.html

There is a complete list about limits of conversion. You can find at :

http://www.aspose.com/Products/Aspose.Words/Aspose.Words.Converters.xls

This thread is moved to the forum of Aspose.Words, the developers of their group will give more detail informations.

Kevin's post pretty much covers the problem. I have nothing to add at the moment.

Best regards,