1

我正在开发一个被一百多个用户使用的 VB6 应用程序。它生成一个 Word 文档,然后将该文档的 TIFF 图像保存在数据库中。目前,它只是将打印机设置为 Microsoft Office Document Image Writer,将文档“打印”到设置的位置,然后将生成的 TIFF 文件导入数据库。但是,该组织正在将每个人都升级到 Office 07,这意味着 Microsoft Office Document Image Writer 即将消失。所以,我想知道以编程方式从 Word 转换为 TIFF 有多难。
我们已经将 C# (.NET 3.5) 控件库作为 COM 引入,因此这似乎是放置功能的好地方。在某个时候,我会将整个应用程序转换为 3.5,所以我希望任何新代码都已经存在,这样可以转换的更少。

编辑:我很欣赏这些建议,但我真的很想在不使用昂贵的第三方组件的情况下尝试这样做。很难让有钱的人看到花费数千美元来修复曾经免费工作的东西的好处。另外,我真的对自己推出它所需要的东西很感兴趣。有点自虐,我知道,但我开始编程是因为我渴望知道事情是如何运作的...... :)

感谢你的帮助!

4

4 回答 4

2

As far as I know (and a quick google seems to confirm this), both the TIFF format and DOC binary format specifications are available for free on the web. Therefore, and this would be a fairly big and complex project (I'm thinking man months rather than man weeks), you could write code to read the DOC document and populate an object model. You could then write more code to then output the object model as a TIFF document.

But, just think of some of the complexities: Tables, formatting, character sets, spacing, embedded content, etc. Eek! I guess this is why it is normally the job of expensive third party libraries or professional document management systems.

Out of interest, might this be the time to move away from proprietary document formats and store the document in the DB as something more manageable?

于 2009-02-04T16:47:51.310 回答
1

您可以使用 Microsoft Windows 提供的标准“传真”驱动程序以编程方式将 Word 文档转换为 TIFF。这项工作的关键是确保 OutputFileName 具有“.tiff”的扩展名这是示例代码(VB.net 和 Word 2010):

Dim objWdDoc As Word.Document
Dim objWord As Word.Application
Dim sDesktop As String = Environment.GetEnvironmentVariable("userprofile") & "\Desktop\"

objWord = CreateObject("Word.Application")
objWdDoc = objWord.Documents.Open(sDesktop & "testdocument.doc")
objWord.Visible = True

'Select Printer
objWord.ActivePrinter = "Fax"
'Print to Tiff
objWdDoc.PrintOut(Range:=WdPrintOutRange.wdPrintAllDocument, _
                      OutputFileName:=sDesktop & "test.tiff", _
                      Item:=WdPrintOutItem.wdPrintDocumentContent, _
                      PrintToFile:=True)
'Close Document
objWdDoc.Close()
'Close Word
objWord.Quit()
'General Cleanup
objWdDoc = Nothing
objWord = Nothing
于 2013-06-24T19:59:31.293 回答
0

试试Aspose.Word组件

于 2009-02-04T16:06:14.763 回答
0

Microsoft Office Document Image Writer 在 Office 2007 中仍然可用(至少在 Enterprise 中)——它是一个可选组件。

于 2009-02-16T22:11:41.947 回答