我想務實地將office文檔轉換爲pdf.i,不想使用Microsoft Office服務ddl。 這是我想用一個組件不是com.does人知道任何可能幫助我嗎?我想itextsharp.it不做轉換,我使用的代碼,將office文檔轉換爲pdf中的c#
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();
。而cutepdf無法直接轉換爲pdf。請幫我解決這個問題。我嘗試了ghostscript。但它將postscripts轉換爲pdf我找不到辦公室文件轉換爲.ps。有沒有其他免費的圖書館可以用來滿足我的要求?
請幫我在這裏 感謝名單
有什麼建議嗎?你能告訴我幾個你已經嘗試過的嗎?我不會介意,只要它是一個ddl。 –