0
我正在編寫一個應用程序,它需要通過c#從Word文檔生成PDF。我相信這可能使用CutePDF,儘管我會歡迎其他工具/ API的建議。有沒有人有這方面的經驗?使用CutePDF或替代工具通過c#打印PDFs
我正在編寫一個應用程序,它需要通過c#從Word文檔生成PDF。我相信這可能使用CutePDF,儘管我會歡迎其他工具/ API的建議。有沒有人有這方面的經驗?使用CutePDF或替代工具通過c#打印PDFs
如果Word互操作是一個選項,並且您擁有Word 2007或Word 2010,那麼您可以讓Word自己爲您作爲普通的另存爲。
例子:
http://msdn.microsoft.com/en-us/library/bb412305(v=office.12).aspx
報價示例代碼上面的鏈接:
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();
}