title: convert office documents to pdf in c#
body: <p>i want to pragmatically convert office documents to pdf.i do not want to use the microsoft office service ddl.
  this is the code which i used,</p>
  
  <pre><code>using System;
  using System.IO;
  using Microsoft.Office.Interop.Word;
  using System;
  using System.Collections.Generic;
  using System.IO;
  using System.Linq;
  using System.Text;
  using System.IO.Compression;
  using Document = Microsoft.Office.Interop.Word.Document;
     namespace pdfconversion
  {
      public class PdfMerge
      {
          static void Main()
          {
              var wordApplication = new Microsoft.Office.Interop.Word.Application();
              Document wordDocument = null;
              object paramSourceDocPath = @"C:\testfile.doc";
              object paramMissing = Type.Missing;
              string paramExportFilePath = @"C:\Temp\Test1234.xps";
              WdExportFormat paramExportFormat = WdExportFormat.wdExportFormatXPS;
              bool paramOpenAfterExport = false;
              WdExportOptimizeFor paramExportOptimizeFor =
                  WdExportOptimizeFor.wdExportOptimizeForPrint;
              WdExportRange paramExportRange = WdExportRange.wdExportAllDocument;
              int paramStartPage = 0;
              int paramEndPage = 0;
              WdExportItem paramExportItem = WdExportItem.wdExportDocumentContent;
              bool paramIncludeDocProps = true;
              bool paramKeepIRM = true;
              WdExportCreateBookmarks paramCreateBookmarks =
                  WdExportCreateBookmarks.wdExportCreateWordBookmarks;
              bool paramDocStructureTags = true;
              bool paramBitmapMissingFonts = true;
              bool paramUseISO19005_1 = false;
                  try
              {
                  // Open the source document.
                  wordDocument = wordApplication.Documents.Open(
                      ref paramSourceDocPath, ref paramMissing, ref paramMissing,
                      ref paramMissing, ref paramMissing, ref paramMissing,
                      ref paramMissing, ref paramMissing, ref paramMissing,
                      ref paramMissing, ref paramMissing, ref paramMissing,
                      ref paramMissing, ref paramMissing, ref paramMissing,
                      ref paramMissing);
                     // Export it in the specified format.
                  if (wordDocument != null)
                      wordDocument.ExportAsFixedFormat(paramExportFilePath,
                          paramExportFormat, paramOpenAfterExport,
                          paramExportOptimizeFor, paramExportRange, paramStartPage,
                          paramEndPage, paramExportItem, paramIncludeDocProps,
                          paramKeepIRM, paramCreateBookmarks, paramDocStructureTags,
                          paramBitmapMissingFonts, paramUseISO19005_1,
                          ref paramMissing);
              }
              catch (Exception ex)
              {
                  // Respond to the error
              }
              finally
              {
                  // Close and release the Document object.
                  if (wordDocument != null)
                  {
                      wordDocument.Close(ref paramMissing, ref paramMissing,
                          ref paramMissing);
                      wordDocument = null;
                  }
                      // Quit Word and release the ApplicationClass object.
                  if (wordApplication != null)
                  {
                      wordApplication.Quit(ref paramMissing, ref paramMissing,
                          ref paramMissing);
                      wordApplication = null;
                  }
                     GC.Collect();
                  GC.WaitForPendingFinalizers();
                  GC.Collect();
                  GC.WaitForPendingFinalizers();
  </code></pre>
  
  <p>i want to use a assembly not a com.does anyone know anything that might help me?i tried itextsharp.it does not do the converting. and cutepdf is not able to convert to pdf directly. please help me out with this.i have tried ghostscript. but it converts postscripts to pdf i couldn't find a way to convert office documents to .ps. is there any other free library which i can use to meet my requirement?</p>
  
  <p>please help me out here
  thanx </p>