首页 新闻 会员 周边

关于 c#调用ocx 出错的问题,求大神解答!!

0
[已解决问题] 解决于 2014-03-17 12:03
这个函数 实现 添加签章    
Public Function AddStampAnnot(ByRef pageNo As Integer, ByVal annotType As Integer, _
                                ByVal x As Integer, ByVal y As Integer) As PDFAnnotation

        pageNo = 0
        Dim pdfX As Single = 0
        Dim pdfY As Single = 0
        Dim bool As Boolean = Me.ConvertClientCoordToPageCoord(x, y, pageNo, pdfX, pdfY)

        Dim annots As PDFPageAnnots
        Try
            annots = Me.GetPageAnnots(pageNo)
        Catch ex As Exception

        End Try

        'Dim annots As PDFPageAnnots = Me.GetPageAnnots(pageNo)
        Dim pdfPoint As PDFPoint = Me.ConvertScreenPointToPDFPoint(New Drawing.Point(x, y))
        Dim path As String = ""

        If pdfPoint.X < 0 Then
            pdfPoint.X = 0
        End If
        If pdfPoint.Y < 0 Then
            pdfPoint.Y = 0
        End If
        If pdfPoint.X > Me.GetPageWidth(CShort(pageNo)) Then
            pdfPoint.X = Me.GetPageWidth(CShort(pageNo))
        End If
        If pdfPoint.Y > Me.GetPageHeight(CShort(pageNo)) Then
            pdfPoint.Y = Me.GetPageHeight(CShort(pageNo))
        End If



        Select Case annotType
            ' メモ
            Case 1
                path = Windows.Forms.Application.StartupPath + "\Resources\icons\memo.bmp"
                ' 依頼
            Case 2
                path = Windows.Forms.Application.StartupPath + "\Resources\icons\irai.bmp"
                ' 回答
            Case 3
                path = Windows.Forms.Application.StartupPath + "\Resources\icons\kaitou.bmp"
                ' デビクラ
            Case 4
                path = Windows.Forms.Application.StartupPath + "\Resources\icons\debi.bmp"
                ' RAS管理
            Case 5
                path = Windows.Forms.Application.StartupPath + "\Resources\icons\ras.bmp"
                'ジャンプ
            Case 6
        End Select
        Dim fs As New IO.FileStream(path, IO.FileMode.Open)

        Dim data(CInt(fs.Length)) As Byte
        fs.Read(data, 0, data.Length)

        Dim p As IntPtr = Marshal.AllocCoTaskMem(data.Length)
        Marshal.Copy(data, 0, p, data.Length)
        Dim buffer As Integer = p.ToInt32
        Dim size As Integer = data.Length
        Dim guid As New Guid()
        Dim key As String = guid.NewGuid().ToString() + "|" _
                            + annotType.ToString()
        fs.Close()
        Dim annot As PDFAnnot = annots.AddStampAnnot(CSng(pdfPoint.X), CSng(pdfPoint.Y - 20), CSng(pdfPoint.X + 20), _
                            CSng(pdfPoint.Y), buffer, size, 3, key)
        'Dim annot As PDFAnnot = annots.AddStampAnnot(CSng(x - 10), CSng(y + 10), CSng(x + 10), _
        '            CSng(y - 10), buffer, size, 3, key)
        annot.Hidden = True
        annot.Subject = pageNo.ToString()
        Dim annotation As New PDFAnnotation(annot)
        annotation.PageIndex = pageNo
        Return annotation

    End Function
 
 

annots = Me.GetPageAnnots(pageNo)
这句就出错了
不是每次都会出错  
大约有三分之一的情况会出错
 
错误代码:

場所 Microsoft.Win32.OAVariantLib.ChangeTypeEx(Variant& result, Variant source, Int32 lcid, Int32 cvType, Int16 flags)
場所 Microsoft.Win32.OAVariantLib.ChangeType(Variant source, Type targetClass, Int16 options, CultureInfo culture)
場所 System.OleAutBinder.ChangeType(Object value, Type type, CultureInfo cultureInfo)
場所 System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
場所 FoxitPDFSDKProLib._DFoxitPDFSDK.GetPageAnnots(Int32 pageIndex)
場所 AxFoxitPDFSDKProLib.AxFoxitPDFSDK.GetPageAnnots(Int32 pageIndex)
場所 mhi.Components.hispec.PDFPageView.AddStampAnnot(Int32& pageNo, Int32 annotType, Int32 x, Int32 y) 場所 D:\snss\2013\ryoin本番20131030\Hi_SpecII\mhi.Components.hispec\PDFPageView.vb:行 1103

求大神解答啊!!

小小菜菜鸟的主页 小小菜菜鸟 | 初学一级 | 园豆:40
提问于:2013-12-18 16:32
< >
分享
最佳答案
0

已解决

小小菜菜鸟 | 初学一级 |园豆:40 | 2014-03-17 12:03
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册