在 Windows Server 2008 上使用 ABCpdf.NET 将 Office 文件转换为 PDF 时出现异常

发布于 2024-08-07 08:10:20 字数 1837 浏览 8 评论 0原文

有人从 ABCpdf 中得到了这个例外吗?我们在 Server 2008 上运行,仅在转换 Office 文件(Word 和 Excel)时遇到问题。这一切在 Server 2003 上运行良好。因为我们只遇到 Office 文件问题,我想知道这是否与 Server 2008 上的 XPS 支持有关?调用此函数的代码作为 Windows 服务运行。

Private Overloads Function ConvertMicrosoftOfficeDocToPdf(ByVal inputFile As Byte(), ByVal fileExt As String) As Byte()
    Dim abcDoc As WebSupergoo.ABCpdf7.Doc = Nothing

    Try
        abcDoc = New WebSupergoo.ABCpdf7.Doc()

        Dim xro As New WebSupergoo.ABCpdf7.XReadOptions()
        xro.FileExtension = fileExt

        Try
            abcDoc.Read(inputFile, xro)
        Catch ex As Exception
            System.Diagnostics.Trace.Write(ex.ToString())
            Throw ex
        End Try

        Dim fileBytes As Byte() = abcDoc.GetData()
        Return fileBytes
    Finally
        If Not abcDoc Is Nothing Then
            abcDoc.Clear()
            abcDoc.Dispose()
        End If
    End Try
End Function

WebSupergoo.ABCpdf7.Internal.PDFException: 试图读或写保护 记忆。这通常是一个迹象 其他内存已损坏。 ---> System.AccessViolationException: 尝试读或写保护 记忆。这通常是一个迹象 其他内存已损坏。 在 WebSupergoo.ABCpdf7.Internal.NDoc._InvokeMethod(IntPtr inDoc、Int32 inMethod、Int32 inIndex、 Int32 inFlags、字符串 inParams、 字符串&输出错误) 在 WebSupergoo.ABCpdf7.Internal.NDoc.InvokeMethod(IntPtr inDoc、Int32 inMethod、Int32 inIndex、 Int32 inFlags、字符串 inParams、 字符串&输出错误) 在WebSupergoo.ABCpdf7.Doc.PrintToXps(字符串 输入文件、字符串输出文件、Int32 超时,字符串打印机名称) 在 WebSupergoo.ABCpdf7.Operations.XpsImportOperation.ImportAny(文档 文档、字符串路径、Int32 超时) 在 WebSupergoo.ABCpdf7.XReadOptions.ImportXpsAny(文档 文档、字符串路径、布尔值清除) 在 WebSupergoo.ABCpdf7.XReadOptions.Read(文档 doc、Byte[] 数据、ReadModuleType 模块) 在 WebSupergoo.ABCpdf7.XReadOptions.Read(文档 doc,字节[]数据)

Has anyone delt with this exception from ABCpdf? We're running on Server 2008 and only have issues converting Office files (Word and Excel). This all worked well on Server 2003. Because we're only having issues with Office files I wonder if it's related to the XPS support on Server 2008? The code that calls into this function is running as a Windows Service.

Private Overloads Function ConvertMicrosoftOfficeDocToPdf(ByVal inputFile As Byte(), ByVal fileExt As String) As Byte()
    Dim abcDoc As WebSupergoo.ABCpdf7.Doc = Nothing

    Try
        abcDoc = New WebSupergoo.ABCpdf7.Doc()

        Dim xro As New WebSupergoo.ABCpdf7.XReadOptions()
        xro.FileExtension = fileExt

        Try
            abcDoc.Read(inputFile, xro)
        Catch ex As Exception
            System.Diagnostics.Trace.Write(ex.ToString())
            Throw ex
        End Try

        Dim fileBytes As Byte() = abcDoc.GetData()
        Return fileBytes
    Finally
        If Not abcDoc Is Nothing Then
            abcDoc.Clear()
            abcDoc.Dispose()
        End If
    End Try
End Function

WebSupergoo.ABCpdf7.Internal.PDFException:
Attempted to read or write protected
memory. This is often an indication
that other memory is corrupt. --->
System.AccessViolationException:
Attempted to read or write protected
memory. This is often an indication
that other memory is corrupt.
at WebSupergoo.ABCpdf7.Internal.NDoc._InvokeMethod(IntPtr
inDoc, Int32 inMethod, Int32 inIndex,
Int32 inFlags, String inParams,
String& outErr)
at WebSupergoo.ABCpdf7.Internal.NDoc.InvokeMethod(IntPtr
inDoc, Int32 inMethod, Int32 inIndex,
Int32 inFlags, String inParams,
String& outErr)
at WebSupergoo.ABCpdf7.Doc.PrintToXps(String
inputFile, String outputFile, Int32
timeout, String printerName)
at WebSupergoo.ABCpdf7.Operations.XpsImportOperation.ImportAny(Doc
doc, String path, Int32 timeout)
at WebSupergoo.ABCpdf7.XReadOptions.ImportXpsAny(Doc
doc, String path, Boolean clear)
at WebSupergoo.ABCpdf7.XReadOptions.Read(Doc
doc, Byte[] data, ReadModuleType
module)
at WebSupergoo.ABCpdf7.XReadOptions.Read(Doc
doc, Byte[] data)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

坠似风落 2024-08-14 08:10:20

此处添加了一个名为“桌面”的文件夹:

C:\Windows\SysWOW64\config\systemprofile\

http://social.msdn.microsoft.com/Forums/en/innovateonoffice/thread/b81a3c4e-62db-488b-af06-44421818ef91

Added a folder called "Desktop" here:

C:\Windows\SysWOW64\config\systemprofile\

http://social.msdn.microsoft.com/Forums/en/innovateonoffice/thread/b81a3c4e-62db-488b-af06-44421818ef91

撩起发的微风 2024-08-14 08:10:20

实际问题是您尝试写入文件的文件夹向 IIS_IUSR 授予写入权限。那么它应该可以工作。

Actual problem is that the folder where you are trying write the file, give the write permission to IIS_IUSR. Then it should work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文