12-02-2011 3:29 PM
Hi Gurus,
I'm using 'CONVERT_OTF' to convert smartform to PDF and then I'm saving the file to application server (Code shown below). ADOBE Acrobat Viewer can handle this error when you open the PDF file - you don't get an error message.
Adobe Acrobat Professional can also open the corrupted file but you'll get the following message if you close it:
'Do you want to save changes to file before closing?'
Kindly help me why some files can be processed successfully and some files gets corrupted.
call function 'CONVERT_OTF'
exporting
format = 'PDF'
max_linewidth = 132
importing
bin_filesize = v_len_in
BIN_FILE = LD_BINFILE
tables
otf = i_otf
lines = i_tline
exceptions
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
others = 4.
if sy-subrc <> 0.
perform protocol_update.
endif.
loop at i_tline.
translate i_tline using '~'.
concatenate wa_buffer i_tline into wa_buffer.
endloop.
translate wa_buffer using '~'.
do.
i_objbin = wa_buffer.
append i_objbin.
shift wa_buffer left by 255 places.
if wa_buffer is initial.
exit.
endif.
enddo.
open dataset v_unix for output in binary mode
message v_message.
if sy-subrc ne 0.
message 'Could not open file for saving' type 'E'.
endif.
loop at i_objbin.
transfer i_objbin to v_unix.
endloop.
close dataset v_unix.
12-02-2011 4:23 PM
Hi
Try to use binary data:
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
IMPORTING
BIN_FILESIZE = BIN_FILESIZE
BIN_FILE = BIN_FILE
TABLES
OTF = OTFDATA
LINES = T_LINES
EXCEPTIONS
ERR_MAX_LINEWIDTH = 1
ERR_FORMAT = 2
ERR_CONV_NOT_POSSIBLE = 3
ERR_BAD_OTF = 4
OTHERS = 5.
PDF_CONTENT = CL_DOCUMENT_BCS=>XSTRING_TO_SOLIX( BIN_FILE ).
OPEN DATASET FILE_NAME FOR OUTPUT IN BINARY MODE.
IF SY-SUBRC <> 0.
ENDIF.
LOOP AT PDF_CONTENT INTO L_PDF.
TRANSFER L_PDF TO FILE_NAME.
ENDLOOP.
CLOSE DATASET FILE_NAME.
Max
12-02-2011 4:23 PM
Hi
Try to use binary data:
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
IMPORTING
BIN_FILESIZE = BIN_FILESIZE
BIN_FILE = BIN_FILE
TABLES
OTF = OTFDATA
LINES = T_LINES
EXCEPTIONS
ERR_MAX_LINEWIDTH = 1
ERR_FORMAT = 2
ERR_CONV_NOT_POSSIBLE = 3
ERR_BAD_OTF = 4
OTHERS = 5.
PDF_CONTENT = CL_DOCUMENT_BCS=>XSTRING_TO_SOLIX( BIN_FILE ).
OPEN DATASET FILE_NAME FOR OUTPUT IN BINARY MODE.
IF SY-SUBRC <> 0.
ENDIF.
LOOP AT PDF_CONTENT INTO L_PDF.
TRANSFER L_PDF TO FILE_NAME.
ENDLOOP.
CLOSE DATASET FILE_NAME.
Max
12-29-2011 1:18 PM
Thanks very much Max. You solution worked. Points has been rewarded. Thanks again.