简体   繁体   English

如何使用 ExecWB 命令将页面打印为 pdf

[英]How to use ExecWB command for printing pages as pdf

I am trying the below code used to print a webpage as pdf我正在尝试使用以下代码将网页打印为 pdf

 IE.ExecWB 6, 2, "U:\Translations", Null

I am not sure how to specify the path name in the above syntax.我不确定如何在上述语法中指定路径名。 The parameters as as follows:参数如下:

object.ExecWB nCmdID, nCmdExecOpt, [pvaIn], [pvaOut]

browser.ExecWB method does not have any parameter to pass the file path . browser.ExecWB方法没有任何参数来传递文件路径

object.ExecWB nCmdID, nCmdExecOpt, [pvaIn], [pvaOut]

The ExecWB method requires an OLE Command ID to be passed in to identify the command to execute. ExecWB 方法需要传入一个 OLE 命令 ID 来标识要执行的命令。 This value nCmdID is of type Long.此值 nCmdID 的类型为 Long。 The nCmdExecOpt parameter represents the value for the command execution option. nCmdExecOpt 参数表示命令执行选项的值。 Together, these values instruct the control as to what supported command to execute and what degree of user prompting should occur.这些值一起指示控件执行什么受支持的命令以及应该发生什么程度的用户提示。

The last two parameters pvaIn and paOut are optional and is usually set to either NULL or an empty string.最后两个参数 pvaIn 和 paOut 是可选的,通常设置为 NULL 或空字符串。

Here is a complete list for the 1st parameter这是第一个参数的完整列表

OLECMDID_OPEN                   1   Open
OLECMDID_NEW                    2   Create a new document
OLECMDID_SAVE                   3    Preservation
OLECMDID_SAVEAS                 4    Save as
OLECMDID_SAVECOPYAS             5    
OLECMDID_PRINT                  6   Print
OLECMDID_PRINTPREVIEW           7   Print preview
OLECMDID_PAGESETUP              8   Page setup
OLECMDID_SPELL                  9   The spelling check
OLECMDID_PROPERTIES             10  Attribute
OLECMDID_CUT                    11  Shear
OLECMDID_COPY                   12  Replication
OLECMDID_PASTE                  13  Paste
OLECMDID_PASTESPECIAL           14  Paste special
OLECMDID_UNDO                   15  Revoke
OLECMDID_REDO                   16  Repeat
OLECMDID_SELECTALL              17  Select all
OLECMDID_CLEARSELECTION         18  Clear selection
OLECMDID_ZOOM                   19  
OLECMDID_GETZOOMRANGE           20  
OLECMDID_UPDATECOMMANDS         21  The update command
OLECMDID_REFRESH                22  Refresh
OLECMDID_STOP                   23  Stop it
OLECMDID_HIDETOOLBARS           24  Hide toolbar
OLECMDID_SETPROGRESSMAX         25  Progress bar maximum
OLECMDID_SETPROGRESSPOS         26  Progress bar position
OLECMDID_SETPROGRESSTEXT        27  Progress bar text
OLECMDID_SETTITLE               28  Set the title
OLECMDID_SETDOWNLOADSTATE       29  Set download status
OLECMDID_STOPDOWNLOAD           30  Stop downloading
OLECMDID_ONTOOLBARACTIVATED     31  
OLECMDID_FIND                   32  Search
OLECMDID_DELETE                 33  Delete
OLECMDID_HTTPEQUIV              34  
OLECMDID_HTTPEQUIV_DONE         35  
OLECMDID_ENABLE_INTERACTION     36  Allow the interaction
OLECMDID_ONUNLOAD               37  When uninstall
OLECMDID_PROPERTYBAG2           38  
OLECMDID_PREREFRESH             39  
OLECMDID_SHOWSCRIPTERROR        40  
OLECMDID_SHOWMESSAGE            41  Display a message
OLECMDID_SHOWFIND               42  Display search
OLECMDID_SHOWPAGESETUP          43  Display page setup
OLECMDID_SHOWPRINT              44  Display and printing
OLECMDID_CLOSE                  45  Close
OLECMDID_ALLOWUILESSSAVEAS      46  
OLECMDID_DONTDOWNLOADCSS        47  
OLECMDID_UPDATEPAGESTATUS       48  
OLECMDID_PRINT2                 49  Print 2
OLECMDID_PRINTPREVIEW2          50  Print preview
OLECMDID_SETPRINTTEMPLATE       51  Set the print template
OLECMDID_GETPRINTTEMPLATE       52  Get a print template
OLECMDID_PAGEACTIONBLOCKED      55  
OLECMDID_PAGEACTIONUIQUERY      56  
OLECMDID_FOCUSVIEWCONTROLS      57  
OLECMDID_FOCUSVIEWCONTROLSQUERY 58  
OLECMDID_SHOWPAGEACTIONMENU     59  
OLECMDID_ADDTRAVELENTRY         60  
OLECMDID_UPDATETRAVELENTRY      61  
OLECMDID_UPDATEBACKFORWARDSTATE 62  
OLECMDID_OPTICAL_ZOOM           63  
OLECMDID_OPTICAL_GETZOOMRANGE   64  
OLECMDID_WINDOWSTATECHANGED     65  windows status change

Here is a complete list for the 2nd parameter这是第二个参数的完整列表

OLECMDEXECOPT_DODEFAULT         0   Default parameters
OLECMDEXECOPT_PROMPTUSER        1   Prompt the user, namely the pop-up dialog box
LECMDEXECOPT_DONTPROMPTUSER     2   User is not prompted
OLECMDEXECOPT_SHOWHELP          3   displays help

IE.ExecWB method can be used to print the web page as PDF but it will prompt the user to select the folder and ask the file name to save it. IE.ExecWB方法可用于将 web 页面打印为 PDF 但它会提示用户 select 文件夹并询问文件名以保存它。

This method does not have any parameter to pass the file path.该方法没有任何参数来传递文件路径。 So if you are looking for using the path written in your code than you need to change your logic and modify your code based on that.因此,如果您正在寻找使用代码中编写的路径,那么您需要更改您的逻辑并基于此修改您的代码。

References:参考:

(1) ExecWB method (1) ExecWB 方法

(2) Microsoft Internet Controls (2) 微软互联网控制

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM