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: 

CONVERT_OTF error while opening the file in acrobat professional.

Former Member
0 Kudos

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.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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

2 REPLIES 2

Former Member
0 Kudos

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

Former Member
0 Kudos

Thanks very much Max. You solution worked. Points has been rewarded. Thanks again.