开发者

Convert Word 2007 Document to Word 2003 Programmatically in ASP.NET

开发者 https://www.devze.com 2022-12-26 18:33 出处:网络
Does anyone know of any component or library (preferably op开发者_Go百科en source) that would allow me to convert Word 2007 documents to Word 2003 with ASP.NET?To use Visual Studio Tools for Office (V

Does anyone know of any component or library (preferably op开发者_Go百科en source) that would allow me to convert Word 2007 documents to Word 2003 with ASP.NET?


To use Visual Studio Tools for Office (VSTO) you need to install Office 2007 on server.

Microsoft.Office.Tools.Word.Document.SaveAs

public virtual void SaveAs (
    [OptionalAttribute] ref Object FileName,
    [OptionalAttribute] ref Object FileFormat,
    [OptionalAttribute] ref Object LockComments,
    [OptionalAttribute] ref Object Password,
    [OptionalAttribute] ref Object AddToRecentFiles,
    [OptionalAttribute] ref Object WritePassword,
    [OptionalAttribute] ref Object ReadOnlyRecommended,
    [OptionalAttribute] ref Object EmbedTrueTypeFonts,
    [OptionalAttribute] ref Object SaveNativePictureFormat,
    [OptionalAttribute] ref Object SaveFormsData,
    [OptionalAttribute] ref Object SaveAsAOCELetter,
    [OptionalAttribute] ref Object Encoding,
    [OptionalAttribute] ref Object InsertLineBreaks,
    [OptionalAttribute] ref Object AllowSubstitutions,
    [OptionalAttribute] ref Object LineEnding,
    [OptionalAttribute] ref Object AddBiDiMarks
)

You need to specify custom FileFormat from WdSaveFormat enumeration.

I didn't found how to force exatly old, 2003 format but you can save it in RTF (WdSaveFormat.wdFormatRTF)


Could you instead install (or have your users install) the Microsoft Office Compatability Pack? This allows Word 2003 to open documents saved by Word 2007 in both binary (.doc) and XML (.docx) formats.

If you have a stream of 2007 documents arriving at your company then maybe you could write a Word 2003 Add-In that uses a FileSystemWatcher to monitor a folder in which the files get placed. It would then open and re-save the files to a new location, in 2003 format.


Just as a followup, I was given the go-ahead to use Aspose.Words for .NET. I appreciate your comments and suggestions to this question. Thank you!

0

精彩评论

暂无评论...
验证码 换一张
取 消