Dear expert,
I have the following code to print a PDF in a loop. It works but the PDFs are printed out of order. So I tried to use 'synchronous' option. However now I have to close the adobe reader application manually before it would go to the next print. I noticed others had the same issue (see below thread), but no resolutions though. Do you guys come across such issue before? I even coded to close the adobe reader app using tastkill (see further below), however it kills the adobe app totally even before the PDF is sent to the printer. Any thoughts? Any help would be greatly appreciated.
https://scn.sap.com/thread/1955518
CALL METHOD cl_gui_frontend_services=>execute
EXPORTING
* document =
application = 'AcroRd32'
parameter = wa_auffile-line
* default_directory =
* maximized =
minimized = 'X'
synchronous = 'X'
operation = ' '
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
bad_parameter = 3
file_not_found = 4
path_not_found = 5
file_extension_unknown = 6
error_execute_failed = 7
synchronous_failed = 8
not_supported_by_gui = 9
OTHERS = 10.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF. " IF sy-subrc <> 0.
Below is the code to auto close adobe application.
CALL METHOD cl_gui_frontend_services=>execute
EXPORTING
* document =
application = 'taskkill'
parameter = '/F /IM acroRD32.exe'
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
bad_parameter = 3
file_not_found = 4
path_not_found = 5
file_extension_unknown = 6
error_execute_failed = 7
synchronous_failed = 8
not_supported_by_gui = 9
OTHERS = 10.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF. " IF sy-subrc <> 0.
Many thanks.
Joanna