on 08-04-2008 3:40 PM
Hi,
How to convert OTF to PDF ?.
Thanks
Rames
You can use:
IF sy-batch NE 'X'.
CALL FUNCTION 'SSFCOMP_PDF_PREVIEW'
EXPORTING
i_otf = v_otf_output-otfdata
EXCEPTIONS
convert_otf_to_pdf_error = 1
cntl_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ramesh.
I would like to suggest,
ARCHIV_CVT_OTF_2_PDF_SAMPLE OTF to PDF conversion
SCMS_AO_OTF_TO_PDF
CONVERT_OTFSPOOLJOB_2_PDF
CONVERT_OTF_2_PDF
CONVERT_OTF_2_PDF_ARCHIVELINK
SX_OBJECT_CONVERT_OTF_PDF
I would like to suggest a couple of references,
[SDN - Reference - OTF unicode output conversion to PDF|;
[SDN - Reference - OTF format to PDF format conversion|;
Hope that's usefull.
Good Luck & Regards.
Harsh Dave
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'ZSMARTFORM'
IMPORTING
fm_name = lf_fm_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
-----Get OTF data--
ls_control_param-getotf = 'X'.
ls_control_param-no_dialog = 'X'.
ls_control_param-preview = 'X'.
CALL FUNCTION lf_fm_name
EXPORTING
control_parameters = ls_control_param
output_options = wa_options
user_settings = ' '
IMPORTING
job_output_info = job_output_info
TABLES
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
it_otf[] = job_output_info-otfdata[].
--
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
IMPORTING
bin_filesize = bin_filesize
TABLES
otf = it_otf[]
lines = it_lines
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
--
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
bin_filesize = bin_filesize
filename = filename(file path)
filetype = 'BIN'
TABLES
data_tab = it_lines
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 22.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Internal Table declarations
DATA: I_OTF TYPE ITCOO OCCURS 0 WITH HEADER LINE,
I_TLINE TYPE TABLE OF TLINE WITH HEADER LINE,
I_RECEIVERS TYPE TABLE OF SOMLRECI1 WITH HEADER LINE,
I_RECORD LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
Objects to send mail.
I_OBJPACK LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE,
I_OBJTXT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
I_OBJBIN LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
I_RECLIST LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE,
Work Area declarations
WA_OBJHEAD TYPE SOLI_TAB,
W_CTRLOP TYPE SSFCTRLOP,
W_COMPOP TYPE SSFCOMPOP,
W_RETURN TYPE SSFCRESCL,
WA_DOC_CHNG TYPE SODOCCHGI1,
W_DATA TYPE SODOCCHGI1,
WA_BUFFER TYPE STRING,u201DTo convert from 132 to 255
Variables declarations
V_FORM_NAME TYPE RS38L_FNAM,
V_LEN_IN LIKE SOOD-OBJLEN,
V_LEN_OUT LIKE SOOD-OBJLEN,
V_LEN_OUTN TYPE I,
V_LINES_TXT TYPE I,
V_LINES_BIN TYPE I.
CALL FUNCTION u2018SSF_FUNCTION_MODULE_NAMEu2019
EXPORTING
FORMNAME = u2018ZTESTu2019
IMPORTING
FM_NAME = V_FORM_NAME
EXCEPTIONS
NO_FORM = 1
NO_FUNCTION_MODULE = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
W_CTRLOP-GETOTF = u2018Xu2019.
W_CTRLOP-NO_DIALOG = u2018Xu2019.
W_COMPOP-TDNOPREV = u2018Xu2019.
CALL FUNCTION V_FORM_NAME
EXPORTING
CONTROL_PARAMETERS = W_CTRLOP
OUTPUT_OPTIONS = W_COMPOP
USER_SETTINGS = u2018Xu2019
IMPORTING
JOB_OUTPUT_INFO = W_RETURN
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
USER_CANCELED = 4
OTHERS = 5.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
I_OTF[] = W_RETURN-OTFDATA[].
CALL FUNCTION u2018CONVERT_OTFu2019
EXPORTING
FORMAT = u2018PDFu2019
MAX_LINEWIDTH = 132
IMPORTING
BIN_FILESIZE = V_LEN_IN
TABLES
OTF = I_OTF
LINES = I_TLINE
EXCEPTIONS
ERR_MAX_LINEWIDTH = 1
ERR_FORMAT = 2
ERR_CONV_NOT_POSSIBLE = 3
OTHERS = 4.
Fehlerhandling
IF SY-SUBRC <> 0.
ENDIF.
LOOP AT I_TLINE.
TRANSLATE I_TLINE USING u2018~u2019.
CONCATENATE WA_BUFFER I_TLINE INTO WA_BUFFER.
ENDLOOP.
TRANSLATE WA_BUFFER USING u2018~u2019.
DO.
I_RECORD = WA_BUFFER.
APPEND I_RECORD.
SHIFT WA_BUFFER LEFT BY 255 PLACES.
IF WA_BUFFER IS INITIAL.
EXIT.
ENDIF.
ENDDO.
Attachment
REFRESH:
I_RECLIST,
I_OBJTXT,
I_OBJBIN,
I_OBJPACK.
CLEAR WA_OBJHEAD.
I_OBJBIN[] = I_RECORD[].
o
+
#
*
o
+ Create Message Body
1. Title and Description
I_OBJTXT = u2018test with pdf-Attachment!u2019.
APPEND I_OBJTXT.
DESCRIBE TABLE I_OBJTXT LINES V_LINES_TXT.
READ TABLE I_OBJTXT INDEX V_LINES_TXT.
WA_DOC_CHNG-OBJ_NAME = u2019smartformu2019.
WA_DOC_CHNG-EXPIRY_DAT = SY-DATUM + 10.
WA_DOC_CHNG-OBJ_DESCR = u2019smartformu2019.
WA_DOC_CHNG-SENSITIVTY = u2018Fu2019.
WA_DOC_CHNG-DOC_SIZE = V_LINES_TXT * 255.
1. Main Text
wa_doc_chng-doc_size = ( v_lines_txt - 1 ) * 255 + strlen( i_objtxt )
*.
CLEAR I_OBJPACK-TRANSF_BIN.
I_OBJPACK-HEAD_START = 1.
I_OBJPACK-HEAD_NUM = 0.
I_OBJPACK-BODY_START = 1.
I_OBJPACK-BODY_NUM = V_LINES_TXT.
I_OBJPACK-DOC_TYPE = u2018RAWu2019.
APPEND I_OBJPACK.
o
+
1. Attachment
(pdf-Attachment)
I_OBJPACK-TRANSF_BIN = u2018Xu2019.
I_OBJPACK-HEAD_START = 1.
I_OBJPACK-HEAD_NUM = 0.
I_OBJPACK-BODY_START = 1.
Länge des Attachment ermitteln
DESCRIBE TABLE I_OBJBIN LINES V_LINES_BIN.
READ TABLE I_OBJBIN INDEX V_LINES_BIN.
I_OBJPACK-DOC_SIZE = V_LINES_BIN * 255 .
I_OBJPACK-BODY_NUM = V_LINES_BIN.
I_OBJPACK-DOC_TYPE = u2018PDFu2019.
I_OBJPACK-OBJ_NAME = u2019smartu2019.
I_OBJPACK-OBJ_DESCR = u2018testu2019.
APPEND I_OBJPACK.
CLEAR I_RECLIST.
I_RECLIST-RECEIVER = u2018email idu2019.
I_RECLIST-REC_TYPE = u2018Uu2019.
APPEND I_RECLIST.
CALL FUNCTION u2018SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = WA_DOC_CHNG
PUT_IN_OUTBOX = u2018Xu2019
TABLES
PACKING_LIST = I_OBJPACK
OBJECT_HEADER = WA_OBJHEAD
CONTENTS_BIN = I_OBJBIN
CONTENTS_TXT = I_OBJTXT
RECEIVERS = I_RECLIST
EXCEPTIONS
TOO_MANY_RECEIVERS = 1
DOCUMENT_NOT_SENT = 2
DOCUMENT_TYPE_NOT_EXIST = 3
OPERATION_NO_AUTHORIZATION = 4
PARAMETER_ERROR = 5
X_ERROR = 6
ENQUEUE_ERROR = 7
OTHERS = 8.
Another EXample
you may use the FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF' to convert the fom
into PDF.
But first to get the printed form from the spool, use FUNCTION
'RSPO_FIND_SPOOL_REQUESTS'.
Then you may send it to your PC, email, fax, etc by reading the record in
the lines of table IT_PDF_OUTPUT.
Note: You may also use program RSTXPDFT4 as a reference to get code
examples which uses different functions to perform the creation of PDFand
download the form to the PC,etc.
CALL FUNCTION 'RSPO_FIND_SPOOL_REQUESTS'
EXPORTING
RQOWNER = SY-UNAME
TABLES
SPOOLREQUESTS = SPOOL_REQUESTS.
READ TABLE SPOOL_REQUESTS INDEX 1.
GD_SPOOL_NR = SPOOL_REQUESTS-RQIDENT.
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
SRC_SPOOLID = GD_SPOOL_NR
NO_DIALOG = C_NO
IMPORTING
PDF_BYTECOUNT = GD_BYTECOUNT
PDF_SPOOLID = PDFSPOOLID
BTC_JOBNAME = JOBNAME
BTC_JOBCOUNT = JOBCOUNT
TABLES
PDF = IT_PDF_OUTPUT
EXCEPTIONS
ERR_NO_OTF_SPOOLJOB = 1
ERR_NO_SPOOLJOB = 2
ERR_NO_PERMISSION = 3
ERR_CONV_NOT_POSSIBLE = 4
ERR_BAD_DSTDEVICE = 5
USER_CANCELLED = 6
ERR_SPOOLERROR = 7
ERR_TEMSEERROR = 8
ERR_BTCJOB_OPEN_FAILED = 9
ERR_BTCJOB_SUBMIT_FAILED = 10
ERR_BTCJOB_CLOSE_FAILED = 11.
CHECK SY-SUBRC = 0.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Check the below code.
* Variable declarations
DATA:
w_form_name TYPE tdsfname VALUE 'ZSURESH_TEST',
w_fmodule TYPE rs38l_fnam,
w_cparam TYPE ssfctrlop,
w_outoptions TYPE ssfcompop,
W_bin_filesize TYPE i, " Binary File Size
w_FILE_NAME type string,
w_File_path type string,
w_FULL_PATH type string.
* Internal tables declaration
* Internal table to hold the OTF data
DATA:
t_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,
* Internal table to hold OTF data recd from the SMARTFORM
t_otf_from_fm TYPE ssfcrescl,
* Internal table to hold the data from the FM CONVERT_OTF
T_pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE.
* This function module call is used to retrieve the name of the Function
* module generated when the SMARTFORM is activated
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = w_form_name
* VARIANT = ' '
* DIRECT_CALL = ' '
IMPORTING
fm_name = w_fmodule
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* Calling the SMARTFORM using the function module retrieved above
* GET_OTF parameter in the CONTROL_PARAMETERS is set to get the OTF
* format of the output
w_cparam-no_dialog = 'X'.
w_cparam-preview = space. " Suppressing the dialog box
" for print preview
w_cparam-getotf = 'X'.
* Printer name to be used is provided in the export parameter
* OUTPUT_OPTIONS
w_outoptions-tddest = 'LP01'.
CALL FUNCTION w_fmodule
EXPORTING
* ARCHIVE_INDEX =
* ARCHIVE_INDEX_TAB =
* ARCHIVE_PARAMETERS =
control_parameters = w_cparam
* MAIL_APPL_OBJ =
* MAIL_RECIPIENT =
* MAIL_SENDER =
output_options = w_outoptions
* USER_SETTINGS = 'X'
IMPORTING
* DOCUMENT_OUTPUT_INFO =
job_output_info = t_otf_from_fm
* JOB_OUTPUT_OPTIONS =
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
t_otf[] = t_otf_from_fm-otfdata[].
* Function Module CONVERT_OTF is used to convert the OTF format to PDF
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
MAX_LINEWIDTH = 132
* ARCHIVE_INDEX = ' '
* COPYNUMBER = 0
* ASCII_BIDI_VIS2LOG = ' '
* PDF_DELETE_OTFTAB = ' '
IMPORTING
BIN_FILESIZE = W_bin_filesize
* BIN_FILE =
TABLES
otf = T_OTF
lines = T_pdf_tab
EXCEPTIONS
ERR_MAX_LINEWIDTH = 1
ERR_FORMAT = 2
ERR_CONV_NOT_POSSIBLE = 3
ERR_BAD_OTF = 4
OTHERS = 5
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* To display File SAVE dialog window
CALL METHOD cl_gui_frontend_services=>file_save_dialog
* EXPORTING
* WINDOW_TITLE =
* DEFAULT_EXTENSION =
* DEFAULT_FILE_NAME =
* FILE_FILTER =
* INITIAL_DIRECTORY =
* WITH_ENCODING =
* PROMPT_ON_OVERWRITE = 'X'
CHANGING
filename = w_FILE_NAME
path = w_FILE_PATH
fullpath = w_FULL_PATH
* USER_ACTION =
* FILE_ENCODING =
EXCEPTIONS
CNTL_ERROR = 1
ERROR_NO_GUI = 2
NOT_SUPPORTED_BY_GUI = 3
others = 4
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Use the FM GUI_DOWNLOAD to download the generated PDF file onto the
* presentation server
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE = W_bin_filesize
filename = w_FULL_PATH
FILETYPE = 'BIN'
* APPEND = ' '
* WRITE_FIELD_SEPARATOR = ' '
* HEADER = '00'
* TRUNC_TRAILING_BLANKS = ' '
* WRITE_LF = 'X'
* COL_SELECT = ' '
* COL_SELECT_MASK = ' '
* DAT_MODE = ' '
* CONFIRM_OVERWRITE = ' '
* NO_AUTH_CHECK = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* WRITE_BOM = ' '
* TRUNC_TRAILING_BLANKS_EOL = 'X'
* WK1_N_FORMAT = ' '
* WK1_N_SIZE = ' '
* WK1_T_FORMAT = ' '
* WK1_T_SIZE = ' '
* IMPORTING
* FILELENGTH =
tables
data_tab = T_pdf_tab
* FIELDNAMES =
* EXCEPTIONS
* FILE_WRITE_ERROR = 1
* NO_BATCH = 2
* GUI_REFUSE_FILETRANSFER = 3
* INVALID_TYPE = 4
* NO_AUTHORITY = 5
* UNKNOWN_ERROR = 6
* HEADER_NOT_ALLOWED = 7
* SEPARATOR_NOT_ALLOWED = 8
* FILESIZE_NOT_ALLOWED = 9
* HEADER_TOO_LONG = 10
* DP_ERROR_CREATE = 11
* DP_ERROR_SEND = 12
* DP_ERROR_WRITE = 13
* UNKNOWN_DP_ERROR = 14
* ACCESS_DENIED = 15
* DP_OUT_OF_MEMORY = 16
* DISK_FULL = 17
* DP_TIMEOUT = 18
* FILE_NOT_FOUND = 19
* DATAPROVIDER_EXCEPTION = 20
* CONTROL_FLUSH_ERROR = 21
* OTHERS = 22
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Hope it is very useful to you.
Thanks,
Phani Diwakar.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
94 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.