| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1851 人关注过本帖
标题:JS中的大括号怎么转化到VB中,脑袋都想破了
只看楼主 加入收藏
yyl67
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2018-4-3
结帖率:0
收藏
已结贴  问题点数:20 回复次数:2 
JS中的大括号怎么转化到VB中,脑袋都想破了
我想给Acrobat做个自动签名的软件,在Acrobat_JavaScript帮助文档中看到以下内容:
var ppklite = security.getHandler("Adobe.PPKLite");
ppklite.login("abc123", "/C/signatures/DPSmith.apf");
var f = this.getField("mySignature");
this.resetForm(["mySignature"]);
f.signatureSign( ppklite,
  { password: "abc123",
    location: "San Jose, CA",
    reason: "I am approving this document",
    contactInfo: "dpsmith@,
    appearance: "Fancy"  });

以下为我写的内容,就是以上的的“signatureSign”不知道怎么转换,请大神教教我,已经想了好几天了,我对JS和VB都不怎么熟:
Private Sub CommandButton1_Click()      'MI签名
    AvaidPathName
    Dim Obj_acroapp As Acrobat.CAcroApp
    Dim Obj_MI_File_AVDoc As Acrobat.CAcroAVDoc
    Dim Obj_MI_File_PDDoc As Acrobat.CAcroPDDoc
    Dim Obj_MI_File_AVPageView As Acrobat.CAcroAVPageView
    Dim Obj_MI_File_JS As Object     'JavaScript对象
    Dim Obj As Object                'JavaScript实例
    Dim oSig As Object              '签名对象
    Dim ppklite As Object            '签名文件
    Dim myInfo As Object            '签名里面的信息
   
    Dim Obj_ECN_File As Acrobat.CAcroPDDoc
    Dim Current_Page As Integer                      '原始ECN页面的页码,准备删除该页
    Dim MI_Page_Nums As Integer                       'MI文件的总页数
    Dim MI_File_Name As String                        'MI文件名
    Dim ECN_File_Name As String                       '扫描ECN文件名
    Dim File_Path As String                          'PDF文件所在的路径
    Set Obj_acroapp = CreateObject("AcroExch.app")
    Set Obj_MI_File_AVDoc = CreateObject("AcroExch.AVDoc")
    Set Obj_MI_File_PDDoc = CreateObject("AcroExch.PDDoc")
   

    Set Obj_ECN_File = CreateObject("AcroExch.PDDoc")
    File_Path = ParsePath(ListView1.ListItems.Item(1))
    ECN_File_Name = Dir(File_Path + "201*.pdf")         '在插进去的文件的所在目录查找以"201"开头的pdf文件名
   
    If ECN_File_Name = "" Then                                                      '如果找不到ECN页,程序退出
        MsgBox ("当前目录找不到类似201开头的扫描ECN,请再次检查!")
        End
    End If
   
    If Obj_MI_File_AVDoc.Open(ListView1.ListItems.Item(1), "") = True Then      '打开MI文件
        Set Obj_MI_File_PDDoc = Obj_MI_File_AVDoc.GetPDDoc
        Set Obj_MI_File_AVPageView = Obj_MI_File_AVDoc.GetAVPageView
    Else
        MsgBox ("文件" + ListView1.ListItems.Item(1) + "失败")
    End If
   
    Obj_ECN_File.Open (File_Path + ECN_File_Name)              '打开ECN文件
   
    MI_Page_Nums = Obj_MI_File_PDDoc.GetNumPages                      '找出MI有多少页
        
    If Obj_ECN_File.GetNumPages > 1 Then                                                        '检测扫描的ECN文件有多少页,如果超过1页,很可能文件选错了
        MsgBox ("文件" + ECN_File_Name + "页面超过1页,请只保留1页后再试...")
        End
    End If
   
    If Obj_MI_File_PDDoc.InsertPages(-1, Obj_ECN_File, 0, Obj_ECN_File.GetNumPages(), 0) = False Then '将扫描的ECN页面插入MI的第1页
        MsgBox ("插入ECN页面失败!")
    End If
   
    If Obj_MI_File_AVDoc.FindText("engineering change notice", 0, 1, 1) = True Then
        Current_Page = Obj_MI_File_AVPageView.GetPageNum
        If Obj_MI_File_PDDoc.DeletePages(Current_Page, Current_Page) = False Then
            MsgBox ("原始ECN页面删除失败!")
        End If
    Else
        MsgBox ("MI中找不到原始ECN页面,是否已经删除了?")
    End If
   
   
    Set jso = Obj_MI_File_PDDoc.GetJSObject                                          '创建JavaScript对象
    Set Obj = jso.addField("PE", "signature", 0, Array(250, 680, 300, 650))            '在首页增加个签名-PE
    Set oSig = jso.getField("PE")
    Set myInfo = oSig.SignatureInfo()
    oSig.display = 1                                                                          '设置签名域隐藏,1为隐藏,0为显示
   
    Set ppklite = jso.security.getHandler("Adobe.PPKLite")
   
    If ppklite.login("111111", "/D/JYJiang.apf") = True Then
        jso.resetForm (oSig)                                        '须先重置
        oSig.signatureSign ppklite, ("password", "111111")
        ppklite.logout
    End If        
        
    If Obj_MI_File_PDDoc.Save(PDSaveFull, ListView1.ListItems.Item(1)) = False Then
        MsgBox ("文件保存失败")
    End If
   
    Obj_MI_File_PDDoc.Close                '以下为清理工作
    Obj_ECN_File.Close
   
    Obj_acroapp.Exit
    Set Obj_acroapp = Nothing
    Set Obj_MI_File_PDDoc = Nothing
    Set Obj_ECN_File = Nothing
   
    MsgBox (CommandButton1.Caption + "操作完成")
End Sub

Private Sub ListView1_OLEDragDrop(Data As MSComctlLib.DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single)
    If Effect = 7 Then
        ListView1.ListItems.Clear
        ListView1.ListItems.Add , "L1", Data.Files(1)
        If IsFileExists(ListView1.ListItems.Item(1)) = False Then
            MsgBox ("文件不存在")
        End If
    End If
End Sub

Private Sub UserForm_Initialize()
    ListView1.ColumnHeaders.Add , "", "FileName", ListView1.Width - 3
End Sub

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
    Application.Visible = True
End Sub

Function IsFileExists(ByVal strfileName As String) As Boolean   '判断文件是否存在
    If Dir(strfileName, 16) <> Empty Then
        IsFileExists = True
    Else
        IsFileExists = False
    End If
End Function

Function HasFile(ByVal strfileName As String) As Boolean    '判断文件是否存在
    If IsFileExists(strfileName) = False Then
        HasFile = False
    Else
        HasFile = True
    End If
End Function

Sub AvaidPathName() '先判断是否有拖文件过来,如果有,再判断文件是否存在
    If ListView1.ListItems.Count = 0 Then
        MsgBox ("请先选择需要签名或删除签名的PDF文件!")
        End
        Exit Sub
   
    ElseIf HasFile(ListView1.ListItems.Item(1)) = False Then
        MsgBox ("文件不存在")
        End
        Exit Sub
    ElseIf StrComp(UCase(GetFileExt(ListView1.ListItems.Item(1))), "PDF") <> 0 Then
        MsgBox ("文件类型不符,请选择PDF文件")
        End
    End If
End Sub

Function ParsePath(sPathIn As String) As String '此函数从字符串中分离出路径
   Dim i As Integer
   For i = Len(sPathIn) To 1 Step -1
     If InStr(":\", Mid$(sPathIn, i, 1)) Then Exit For
   Next
   ParsePath = Left$(sPathIn, i)
 End Function
 
 Function ParseFileName(sFileIn As String) As String    '此函数从字符串中分离出文件名
   Dim i As Integer
   For i = Len(sFileIn) To 1 Step -1
     If InStr("\", Mid$(sFileIn, i, 1)) Then Exit For
   Next
   ParseFileName = Mid$(sFileIn, i + 1, Len(sFileIn) - i)
 End Function
 
 Function GetFileExt(sFileName As String) As String     '此函数从字符串中分离出文件扩展名
   Dim P As Integer
   For P = Len(sFileName) To 1 Step -1
     If InStr(".", Mid$(sFileName, P, 1)) Then Exit For
   Next
   GetFileExt = Right$(sFileName, Len(sFileName) - P)
 End Function
搜索更多相关主题的帖子: Dim 文件 If Then End 
2018-04-03 10:53
wlrjgzs
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:26
帖 子:212
专家分:1566
注 册:2017-4-10
收藏
得分:20 
连个联系方式都不留?
2018-04-03 18:03
yyl67
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2018-4-3
收藏
得分:0 
不知道你说的联系方式是指什么,我是昨天才注册这个网站的,以下是我的微信号:
aqbj18
2018-04-04 11:23
快速回复:JS中的大括号怎么转化到VB中,脑袋都想破了
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.025972 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved