2011-07-04 15 views
0

私はオフィス文書をpdf.iに変換したいのですが、Microsoft Officeサービスddlを使用したくありません。 これは私が使用したコード、オフィス文書をC言語でPDFに変換する#

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(); 

私はcom.doesの誰も私を助けるかもしれない何も知らないアセンブリを使用するようにしたいですか?私はitextsharp.itは変換を行いませんみましたです。 cutepdfはpdfに直接変換できません。これで私を助けてください。私はゴーストスクリプトを試しました。それはpostscriptsをpdfに変換します。私はオフィス文書を.psに変換する方法を見つけることができませんでした。私の要求を満たすのに使うことができる他の無料の図書館はありますか?

ここ ありがとう

答えて

0

私は最近、PDFに文書を変換する無料のソフトウェアをたくさん見てきたと私はそれらのどれも私の要件を満たしていなかったことを認めなければならない私を助けてください。一部のコンバーターは悪くないが、ライセンスは制限的だった。私はあなたが良い非自由なコンバータを見つけなければならないと思う。

あなたは見にPDFコンバータのこのリストを取ることができます。Converters

+0

提案がありますか?あなたは試したことがあるいくつか私に電話できますか?私はそのddlと同じくらい長い間は気にしません。 –

0

私は変換を行うためにOpen Officeを自動化することをお勧めします。無料で、私の経験ではfarは、自動化された変換タスクに使用されている場合、Microsoft Officeよりも安定しています。

同様の質問hereの回答を参照してください。コードサンプルが含まれています。

関連する問題