Missing text when converting docx to pdf with office-interop RRS feed

  • Question

  • I have issue that when converting word DOCX files with word-interop to PDF it happends ocassionally that file does not convert well - some part of text is missing at the place where page ends.

    In my current situation there is missing one text bubble with two lines of text.

    I have created a mini test application that converts test.docx to pdf and I see that problem appears on two machines "Windows Server 2008 R2 Standard" with "Office 2010". It also happends on "Windows 7 Professional" with "Office 2013", and it does not on another one with same configuration.

    I'm looking for some leads where to look for solving this problem.

    Edit: Here is a image to show what do I mean by "missing one text bubble with two lines of text".
    Left: original document in word.
    Middle: Interop conversion output.
    Right: manually saved DocX to PDF in Word

    To see enlarged version:

    Tuesday, September 3, 2013 11:50 AM

All replies

  • Hi Miro,

    I failed to reproduce your issue in my lab environment (Office 2013), here is my code:

    static void PrintWord()
                object oMissing = Type.Missing;
                Microsoft.Office.Interop.Word.Application wordapp = new Microsoft.Office.Interop.Word.Application();
                Microsoft.Office.Interop.Word.Document worddoc = wordapp.Documents.Open("E:/1.docx");
                    string outputfile = "E:/1.pdf";
                    if (!Directory.Exists(outputfile))
                        DirectoryInfo TheFolder = new DirectoryInfo(outputfile);
                    worddoc.SaveAs("E:/1.pdf", Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatPDF);
                catch (Exception ex)

    Please see the below screenshot:

    Would you mind sharing your code and sample word document file with us through Skydrive.

    In addition, as you mentioned “It also happened on Windows 7 Professional with Office 2013, and it does not on another one with same configuration”.

    Would you please tell us any difference between these 2 machines (e.g. Windows version and Office mode: 32-bit or 64-bit).


    Sophia Gou <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED> MSDN Community Support Please remember to "Mark as Answer" the responses that resolved your issue.

    Thursday, September 5, 2013 2:20 AM
  • Hello Sophia

    here is excerpt from my code, it is pretty much the same as yours:

    	Application wordApp;
    	wordApp = new Application();
    	string fileName = Path.GetTempFileName();
    	Document doc = wordApp.Documents.Open(fileName);
    	object outputFileName = Path.GetTempFileName();
    	object fileFormat = WdSaveFormat.wdFormatPDF;
    	doc.SaveAs(ref outputFileName, ref fileFormat);
    	return File.ReadAllBytes(outputFileName.ToString());
    catch (Exception exception)
    	throw exception;
    I was looking on differences on those two Windows 7 machines and there is no difference in system or office, they are both:

    Windows 7 Enterprise, 64bit SP1
    Office 2013 MSO 64bit

    It is unfortunate that I can't provide the document as it is internal document and I can't give it to public. I'm looking for ways how to produce similair document which causes the issue and I can provide it here.

    Best regards


    Friday, September 6, 2013 2:22 PM