05-25-2011 8:53 PM
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
05-26-2011 5:27 AM
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.
05-26-2011 5:27 AM
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.
04-09-2013 9:55 AM
05-05-2015 12:23 PM
Hi Jack,
I have similar requirement to print pdf files and I have written the above code but it opens pdf file instead of print.Can you please help me in this.
Thanks,
Suman
06-03-2011 9:42 PM
In fact, we decided to use thirsd party coverter sofware from Seal Systems. This allow us to read external MS Office files + PDF and convert them to PCL, POSTSRIPT data to print thse direcly to printer
Thanks Jack
05-27-2016 4:53 AM
Dear Dean Ton:
how to conver them to POSTSRIPT data to print thse direcly to printer,I have similar requirement to print pdf files.
03-09-2015 7:19 AM
Hi,
It is really late to give response this post. But still who ever refering to this post for the same issue this solution is useful for achieving same in background:
Even same can be used in smartforms, for getting spool request in PDF format as well which will decrease the size of file when printing in SAP printer.
ct_tline is PDF output:
DATA: lv_pdfsource TYPE xstring.
FIELD-SYMBOLS:<p> TYPE x. " <p> type any.
LOOP AT ct_tline INTO cs_tline.
ASSIGN cs_tline TO <p> CASTING TYPE x.
CONCATENATE lv_pdfsource <p> INTO lv_pdfsource IN BYTE MODE.
ENDLOOP.
* ->Create spool request in PDF format
CALL FUNCTION 'ADS_CREATE_PDF_SPOOLJOB'
EXPORTING
printer = 'LOCL' "Printer name supporting PDF device type
* DEST =
pages = 1
pdf_data = lv_pdfsource "XSTRING internal table
* NAME =
* SUFFIX1 =
* SUFFIX2 =
* COPIES =
* PRIO =
IMMEDIATE_PRINT = 'X'
* AUTO_DELETE =
* TITLELINE =
* RECEIVER =
* DIVISION =
* AUTHORITY =
* LIFETIME = '0'
* IMPORTING
* SPOOLID =
* EXCEPTIONS
* NO_DATA = 1
* NOT_PDF = 2
* WRONG_DEVTYPE = 3
* OPERATION_FAILED = 4
* CANNOT_WRITE_FILE = 5
* DEVICE_MISSING = 6
* NO_SUCH_DEVICE = 7
* OTHERS = 8
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
10-09-2015 2:41 PM