Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Issue while printing PDF files

Former Member
0 Kudos

Hi All ,

I am trying to print PDF document with the help of the method cl_gui_frontend_services=>execute . Below is the code for the same ,

CALL METHOD cl_gui_frontend_services=>execute

EXPORTING

document = gv_fname

  • APPLICATION =

  • PARAMETER =

  • DEFAULT_DIRECTORY =

  • MAXIMIZED =

  • MINIMIZED =

  • SYNCHRONOUS =

operation = 'PRINT'

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.

Gv_fname contains the path of the file to be printed . The file is present on the desktop.

Using the above method I am able to print the PDF document but it opens up a blank Acrobat reader while printing . I am looking for a solution to avoid opening of blank Acrobat reader while printing the PDF document .

Please let me know if there is any other way to print PDF files .

Any information leading to a solution for this problem would be highly appreciated.

Thanks in advance .

5 REPLIES 5

Former Member
0 Kudos

Hi,

Just u can see the below code.

***TO GET THE SMART FORM

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

FORMNAME = 'ZB_EX_VEHICLE_ACTIVITY_FORM'

IMPORTING

FM_NAME = FM_NAME

EXCEPTIONS

NO_FORM = 1

NO_FUNCTION_MODULE = 2

OTHERS = 3 .

IF SY-SUBRC <> 0.

ELSE.

IF SMART_PARAM IS INITIAL.

CTRL_PARA-DEVICE = 'PRINTER'.

CTRL_PARA-PREVIEW = 'X'.

************************************************

***below you just check in fm_name u r passing in exporting day_late and prog_pha. these ***two fields iam passing to smartforms. so in smartforms u need to declare in form ***interfaceas prog_pha and day_late. if u want to pass table then u can pass table in ***tables and also u need to declare it in smartforms in form interface.

CALL FUNCTION FM_NAME

EXPORTING

CONTROL_PARAMETERS = CTRL_PARA

USER_SETTINGS = 'X'

PROG_PHA = PROG_PHA

DAY_LATE = DAY_LATE

L_SYSDATE = L_SYSDATE

TABLES

IT_ACTIVITY_FINAL = IT_ACTIVITY_FINAL

EXCEPTIONS

FORMATTING_ERROR = 1

INTERNAL_ERROR = 2

SEND_ERROR = 3

USER_CANCELED = 4

OTHERS = 5.

IF SY-SUBRC <> 0.

ENDIF.

ENDIF.

***TO GET PDF FILE

IF SMART_PARAM-Z_R3_PDF = 'X'.

***below u can give the file name, here iam given vehicle_activity_report and date and time. ***u can give instead of vehicle_activity_report u can give according to ur requirement.

concatenate

'C:/VEHICLE_ACTIVITY_REPORT' sy-datum4(2) SY-DATUM6(2) SY-DATUM+0(4) '_' sy-uzeit '.pdf' into WS_FULLPATH.

OUTPUT_OPTIONS-TDDEST = 'LP01'.

OUTPUT_OPTIONS-TDNOPREV = 'X'.

OUTPUT_OPTIONS-TDNEWID = 'X'.

OUTPUT_OPTIONS-TDIMMED = ' '.

CTRL_PARA-NO_DIALOG = 'X'.

CTRL_PARA-GETOTF = 'X'.

CALL FUNCTION FM_NAME

EXPORTING

CONTROL_PARAMETERS = CTRL_PARA

OUTPUT_OPTIONS = OUTPUT_OPTIONS

USER_SETTINGS = 'X'

PROG_PHA = PROG_PHA

DAY_LATE = DAY_LATE

L_SYSDATE = L_SYSDATE

IMPORTING

JOB_OUTPUT_INFO = MY_OUTPUT_INFO

JOB_OUTPUT_OPTIONS = JOB_OUTPUT_OPTIONS

TABLES

IT_ACTIVITY_FINAL = IT_ACTIVITY_FINAL

EXCEPTIONS

FORMATTING_ERROR = 1

INTERNAL_ERROR = 2

SEND_ERROR = 3

USER_CANCELED = 4

OTHERS = 5 .

IF SY-SUBRC <> 0.

ENDIF.

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

FORMAT = 'PDF'

IMPORTING

BIN_FILESIZE = BIN_FILESIZE

TABLES

OTF = MY_OUTPUT_INFO-OTFDATA

LINES = LINES

EXCEPTIONS

ERR_MAX_LINEWIDTH = 1

ERR_FORMAT = 2

ERR_CONV_NOT_POSSIBLE = 3

ERR_BAD_OTF = 4

OTHERS = 5.

IF SY-SUBRC <> 0.

ENDIF.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

FILENAME = WS_FULLPATH

FILETYPE = 'BIN'

TABLES

DATA_TAB = LINES .

IF SY-SUBRC <> 0.

ENDIF.

ENDIF.

Hope useful for u.

former_member182426
Active Contributor
0 Kudos

hi,

i think there is no PRINT which u specify for OPERATION. just chek the method.

there is only OPEN operation in execute method....

Are you getting print out of PDF file data.

Regards,

shankar.

0 Kudos

yes i do get a print out but the only issue is that it opens up a blank acrobat reader application.. So the user has to manually close it . I m looking for a solution to avoid this .

0 Kudos

hi,

just check it out with same method by passing CLOSE to OPERATION parameter.

Reagrds,

Shankar.

vishal_agrawal3
Participant
0 Kudos

Hi All,

Am facing the same problem. After printing, the adobe acrobat reader is still open. Did anyone find any solution to this problem?

Regards,

Vishal Agrawal