Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

File does not begin with %PDF

Hi,

I have I developed a application WDA to display the employee photo. I have used the component InteractiveForm in layout to do this.

I got the photo from archivelink (BINARY) and convert it to XSTRING. See the source below:

call function 'SCMS_AO_TABLE_GET'

exporting

arc_id = archivelink-archiv_id

doc_id = archivelink-arc_doc_id

comp_id = 'data'

importing

length = lv_length

tables

data = lt_data

exceptions

error_http = 1

error_archiv = 2

error_kernel = 3

error_config = 4

others = 5.

if sy-subrc ne 0.

exit.

endif.

call function 'SCMS_BINARY_TO_XSTRING'

exporting

input_length = lv_length

importing

buffer = foto

tables

binary_tab = lt_data.

The problem is: Some machines are showing the adobe error "File does not begin with %PDF", therefore others have no problem.

What I can do to solve it ?

Can anybody help me?

Thanks a lot,

Former Member
replied

>I can't to use an Image UI element because this element only shows an image with url (string) and not with xstring.

Yes, but you can take your XSTRING content and place it in the ICM cache and generate a temporary URL for it. The ICM Cache URL will be relative so HTTPS shouldn't be a problem. Perhaps in Web Dynpro Java such a solution as the InteractiveForm was necessarily, but in Web Dynpro ABAP we have the ICM Cache and this will defintely avoid the file does not begin with %PDF - as the PDF Reader was not designed to display images alone - but PDF documents.

Here is a sample:

METHOD push_content_into_icm_cache.
*@78\QImporting@  I_PATH  TYPE STRING  DEFAULT '/sap/public'
*@78\QImporting@  I_FORMAT  TYPE STRING  DEFAULT 'BMP'  Supports JPG/GIF/TIFF/PNG
*@78\QImporting@  I_CACHE_TIMEOUT TYPE I  DEFAULT 60  Cache Timeout in Seconds
*@7B\QReturning@  VALUE( R_URL )  TYPE STRING URL To the Cached Resource
*@03\QException@  ZCX_ABAP_BITMAP   Bitmap Processing Exceptions


****Create the cached response object that we will insert our content into
  DATA: cached_response TYPE REF TO if_http_response.
  CREATE OBJECT cached_response
    TYPE
      cl_http_response
    EXPORTING
      add_c_msg        = 1.
*  cached_response->set_compression( options = cached_response->IF_HTTP_ENTITY~CO_COMPRESS_IN_ALL_CASES ).
  TRY. " ignore, if compression can not be switched on
      CALL METHOD cached_response->set_compression
        EXPORTING
          OPTIONS = cached_response->co_compress_based_on_mime_type
        EXCEPTIONS
          OTHERS  = 1.
    CATCH cx_root.
  ENDTRY.
****set the data and the headers
  DATA: l_app_type TYPE string.
  DATA: l_xstring TYPE xstring.
  CASE i_format.
    WHEN 'BMP'.
      cached_response->set_data( me->gx_content ).
      l_app_type = 'image/x-ms-bmp'.
    WHEN 'GIF'.
      me->get_content_ext_format(
        EXPORTING
          i_format  = i_format
        IMPORTING
          e_xstream = l_xstring ).
      cached_response->set_data( l_xstring ).
      l_app_type = 'image/gif'.
    WHEN 'JPG'.
      me->get_content_ext_format(
        EXPORTING
          i_format  = i_format
        IMPORTING
          e_xstream = l_xstring ).
      cached_response->set_data( l_xstring ).
      l_app_type = 'image/jpeg'.
    WHEN 'TIF'.
      me->get_content_ext_format(
        EXPORTING
          i_format  = i_format
        IMPORTING
          e_xstream = l_xstring ).
      cached_response->set_data( l_xstring ).
      l_app_type = 'image/tiff'.
    WHEN 'PNG'.
      me->get_content_ext_format(
        EXPORTING
          i_format  = i_format
        IMPORTING
          e_xstream = l_xstring ).
      cached_response->set_data( l_xstring ).
      l_app_type = 'image/png'.
    WHEN OTHERS.
      RAISE EXCEPTION TYPE zcx_abap_bitmap.
  ENDCASE.
*
  cached_response->set_header_field( name  = if_http_header_fields=>content_type
                                     value = l_app_type ).

****Set the Response Status
  cached_response->set_status( code = 200 reason = 'OK' ).

****Set the Cache Timeout - 60 seconds - we only need this in the cache
****long enough to build the page and allow the IFrame on the Client to request it.
  cached_response->server_cache_expire_rel( expires_rel = i_cache_timeout ).

****Create a unique URL for the object
  DATA: guid TYPE guid_32.
  CALL FUNCTION 'GUID_CREATE'
    IMPORTING
      ev_guid_32 = guid.
  CONCATENATE i_path '/' guid '.' i_format INTO r_url.

****Cache the URL
  cl_http_server=>server_cache_upload( url      = r_url
                                       response = cached_response ).
ENDMETHOD.

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question