| /// <summary>             /// Exparts word document to PDF or XPS.
 /// </summary>
 private static void exportWordDoc2Pdf()
 {
 Microsoft.Office.Interop.Word.ApplicationClass word = new Microsoft.Office.Interop.Word.ApplicationClass();
 
 object fileName =@"Quick Guide.docx";
 object falseValue = false;
 object trueValue = true;
 object missing = Type.Missing;
 word.Visible = true;
 
 //
 // Loads an existing word document.
 Microsoft.Office.Interop.Word.Document doc =
 word.Documents.Open(ref fileName,
 ref missing, ref trueValue, ref missing, ref missing,
 ref missing, ref missing, ref missing, ref missing,
 ref missing, ref missing, ref missing, ref missing,
 ref missing, ref missing, ref missing);
 
 
 // Sets export format. Another possiblity: wdExportFormatXPS
 Microsoft.Office.Interop.Word.WdExportFormat paramExportFormat =
 
 Microsoft.Office.Interop.Word.WdExportFormat.wdExportFormatPDF;
 bool paramOpenAfterExport = false;
 Microsoft.Office.Interop.Word.WdExportOptimizeFor
 paramExportOptimizeFor =
 
         Microsoft.Office.Interop.Word.WdExportOptimizeFor.wdExportOptimizeForPrint              Microsoft.Office.Interop.Word.WdExportRange paramExportRange =
 
 Microsoft.Office.Interop.Word.WdExportRange.wdExportAllDocument;
 int paramStartPage = 0;
 int paramEndPage = 0;
 Microsoft.Office.Interop.Word.WdExportItem paramExportItem =
 
 Microsoft.Office.Interop.Word.WdExportItem.wdExportDocumentContent;
 bool paramIncludeDocProps = true;
 bool paramKeepIRM = true;
 Microsoft.Office.Interop.Word.WdExportCreateBookmarks
 paramCreateBookmarks =
 Microsoft.Office.Interop.Word.WdExportCreateBookmarks.wdExportCreateWordBookmarks;
 bool paramDocStructureTags = true;
 bool paramBitmapMissingFonts = true;
 bool paramUseISO19005_1 = false;
 string newFileName = "c:\\Temp\\test.pdf";
 
 //
 // Export the file to PDF.
 doc.ExportAsFixedFormat(newFileName,
 paramExportFormat, paramOpenAfterExport,
 paramExportOptimizeFor, paramExportRange, paramStartPage,
 paramEndPage, paramExportItem, paramIncludeDocProps,
 paramKeepIRM, paramCreateBookmarks, paramDocStructureTags,
 paramBitmapMissingFonts, paramUseISO19005_1,
 ref missing);
 
 doc.Close(ref missing, ref missing, ref missing);
 
 doc = null;
 
 word.Quit(ref missing, ref missing, ref missing);
 
 GC.Collect();
 GC.WaitForPendingFinalizers();
 GC.Collect();
 GC.WaitForPendingFinalizers();
 }
 |