Skip to content Skip to sidebar Skip to footer

In Shellexecute, How To Specify Print Parameters Like Page Range, Tray Etc?

This is the code I'm using to print a pdf file on a Windows machine using Python. I've adobe Acrobat Reader installed to aid in printing. win32api.ShellExecute(0,'print',file_path,

Solution 1:

The linked documentation states what what you want is not possible. Commented extracts (emphasize mine):

Syntax:

HINSTANCE ShellExecute(
  _In_opt_ HWND    hwnd,
  _In_opt_ LPCTSTR lpOperation,
  _In_     LPCTSTR lpFile,
  _In_opt_ LPCTSTR lpParameters,
  _In_opt_ LPCTSTR lpDirectory,
  _In_     INT     nShowCmd
);

Parameters...

  • lpOperation [in, optional]

    Type: LPCTSTR

    A pointer to a null-terminated string, referred to in this case as a verb, ... The following verbs are commonly used:...

    print

    Prints the file specified by lpFile. If lpFile is not a document file, the function fails.

So when you use "print" as a verb lpFile shall be a document file

...

  • lpParameters [in, optional]

    Type: LPCTSTR

    If lpFile specifies an executable file, this parameter is a pointer to a null-terminated string that specifies the parameters to be passed to the application. The format of this string is determined by the verb that is to be invoked. If lpFile specifies a document file, lpParameters should be NULL.

So when you use print as the verb, lpFile must be a document file, and lpParameters must be null: there is no provision to pass additional parameters to a ShellExecute print action.

Post a Comment for "In Shellexecute, How To Specify Print Parameters Like Page Range, Tray Etc?"