Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Print PDF file directly to store printer

Hi Gurus,

Having not found a solution, we think we need help from you. We have searched forums and google but have not found adequate solutions.

We are a retailer having different stores. Our main office is using SAP. Each store has its printer and defined in our SAP system. We want to print PDF files directly to store printer using SAP . How should we do that ? We think there are 2 steps:

1) Upload PDF files from network directory into SAP (We done it, no problem)

2) Having now PDF files in internal tables, how should we proceed to print PDF files using store printers?

Please note that we do not want to use CL_GUI_PDFVIEWER since we do not want to display the PDF and having the obligation to choose the print option from dialog and also we do not want to call Adobe OLE object to print

Any answer would be appreciated

Thank you very much

Former Member
replied

Hi Dean, we had the same requirement here. There are no SAP tools to print an existing PDF via the SAP spool. We solved it by calling PDF viewer on a frontend station with parameter /t. That will print the PDF without any user intervention. Please find the stripped coding below. It reads the installed Adobe acrobat reader from registry and starts print of PDF.

This will only work when there is a connection to a frontend station that has Acrobat reader installed. So it will not work when run from a batch job. If you or anyone else knows a better solution printing PDF then I am interested. There are some 3th party tools to convert PDF into SAP spool using BC-XDC.

Regards Jack

DATA:
  zlv_filep       TYPE filep VALUE 'C:\temp\file.pdf',
  zlv_extension   TYPE filep,
  zlv_key         TYPE string,
  zlv_application TYPE string,
  zlv_program     TYPE string,
  zlv_parameter   TYPE string.

* Extension.
CALL FUNCTION 'CV120_SPLIT_FILE'
  EXPORTING
    pf_file          = zlv_filep
  IMPORTING
    pfx_dotextension = zlv_extension.

* Application
zlv_key = zlv_extension.
CALL METHOD cl_gui_frontend_services=>registry_get_value
  EXPORTING
    root      = cl_gui_frontend_services=>hkey_classes_root
    key       = zlv_key
  IMPORTING
    reg_value = zlv_application.

* Executable
CONCATENATE zlv_application '\shell\open\command' INTO zlv_key.
CALL METHOD cl_gui_frontend_services=>registry_get_value
  EXPORTING
    root      = cl_gui_frontend_services=>hkey_classes_root
    key       = zlv_key
  IMPORTING
    reg_value = zlv_program.
REPLACE ALL OCCURRENCES OF '"%1"' IN zlv_program WITH ''.

* Print (/t for Acrobat Reader)
CONCATENATE  '/t' zlv_filep  INTO zlv_parameter SEPARATED BY space.
CALL METHOD cl_gui_frontend_services=>execute
  EXPORTING
    application = zlv_program
    parameter   = zlv_parameter.

5 View this answer in context
Not what you were looking for? View more on this topic or Ask a question