We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Layout problems converting word documents with Autoshapes to PDF

Hello all,
I am having problems converting word 2003 documents with auto shapes to Pdf. Documents convert fine but layout of generated document does not match the original. Please see attached word document “sample.doc” and PDF “sample.pdf” and look at the space in PDF document below first autoshape. This extra space is throwing alignment off when generated PDF is superimposed on another image. I am using Aspose.words for .Net Version and Aspose.PDF for .Net Version Sample code to convert from word to PDF is as follows

string wordFileName = "c:\temp\sample.doc";
string pdfFileName = Path.Combine(Path.GetDirectoryName(wordFileName), Path.GetFileNameWithoutExtension(wordFileName) + ".pdf");
if (File.Exists(pdfFileName))
string licenseFileName = @"c:\temp\Aspose.Total.lic";
Aspose.Words.License wordLicense = new Aspose.Words.License();
Aspose.Pdf.License pdfLicense = new Aspose.Pdf.License();
Aspose.Words.Document wordDocument = new Document(wordFileName);
System.IO.MemoryStream asposePdfXmlStream = new MemoryStream();
wordDocument.Save(asposePdfXmlStream, SaveFormat.AsposePdf);
// Convert from PDF xml format to actual PDF 
asposePdfXmlStream.Seek(0, SeekOrigin.Begin);
Aspose.Pdf.Pdf pdfDocument = new Aspose.Pdf.Pdf();
pdfDocument.CompressionLevel = 0;
pdfDocument.BindXML(asposePdfXmlStream, null);
pdfDocument.IsImagesInXmlDeleteNeeded = true;
MessageBox.Show("Converted Word File " + wordDocument + " to pdf " + pdfFileName);

Help me this is driving me up the wall

Thank you for your inquiry.
Your code is okay. I can add two things: when creating a System.IO.MemoryStream it is better to put all related code into using block to guarantee resource deallocation. You don’t need setting IsImagesInXmlDeleteNeeded since it is true by default. But when you set it this should be done before BindXML.
I see the difference in vertical layouting. It is better to avoid floating shapes in this situation. I can suggest using tables with partially invisible borders. The horizontal lines will be represented by visible borders.
Please let us know whether this workaround is suitable for you. If you cannot change the document then we’ll ask Aspose.Pdf Team for their expertise.

Thanks for the quick reply. One thing i forgot to add “Word Documents I am trying to convert are generated by a Third Party application i do not have any control over”. Is there something that can be done in aspose classes to change the floating shapes to table(s)

Okay, I’ve asked Aspose.Pdf Team to take a look on this document.

Any update on this issue? Also is there a way to change properties on these autoshapes either using Aspose classes or using Word Automation

Thank you for your patience.
Aspose.Pdf Team haven’t replied yet. Please try Aspose.Pdf DLL attached in this post:
It gives closer results and can be trusted since it was attached by Aspose.Pdf developers for another customer.

Hi Rao,

Thanks for considering aspose products.
I am a developer of aspose pdf team. I tried to convert the attached doc into pdf. In my test, it worked well when using our latest version Aspose.Pdf and Aspose.Words I have attached the dll of Aspose.Pdf and the resulted pdf. Please try it. Thanks.

Best regards.