PDF File opening error

Hi,
I have an BSP application in which I am fetching the pdf file data from an oracle table to a variable of data type xstring.
Now I have to display this xstring again in pdf format in this BSP. The pdf file is generated but while opening it is giving error "There is an error in opening this document.The file is damaged and could not be repaired".
What could be the reason.
My On initialisation code is as:
data: outputx type xstring.
(The pdf file data is fetched from oracle table to outputx.)
CREATE OBJECT cached_response TYPE CL_HTTP_RESPONSE EXPORTING add_c_msg
= 1.
    cached_response->set_header_field( name  =
          if_http_header_fields=>content_type
                                  value = 'application/pdf' ).
    cached_response->set_status( code = 200 reason = 'OK' ).
    cached_response->server_cache_expire_rel( expires_rel = 180 ).
    l_pdf_len = xstrlen( outputx ).
    response->set_data( data = outputx
                             length = l_pdf_len ).
     response->set_header_field(
                        name  = 'content-disposition'
                        value = 'attachment; filename=attach_pdf.pdf' ).
CALL FUNCTION 'GUID_CREATE'
      IMPORTING
        ev_guid_32 = guid.
    CONCATENATE runtime->application_url '/' guid '.pdf' INTO
display_url.
    cl_http_server=>server_cache_upload( url      = display_url
                                         response = cached_response ).
  navigation->response_complete( ).

Still the pdf file is not opening.
My On Initilisation code is as below:
EXEC SQL.
  OPEN CUR FOR SELECT ORDER_NO,ORDER_DESC,DOC_TYPE
             FROM SAPIBM.T_ORDER
             where ORDER_NO = :orderno
ENDEXEC.
refresh : t_order.
do.
  clear : wk_order.
  EXEC SQL.
    FETCH NEXT CUR INTO
                     :wk_order-ORDER_NO,
                     :wk_order-ORDER_DESC,
                     :WK_ORDER-DOC_TYPE
  ENDEXEC.
  if sy-subrc = 0.
    append wk_order   to t_order.
  else.
    exit.
  endif.
enddo.
EXEC SQL.
  CLOSE CUR
ENDEXEC.
if not t_order[] is initial.
  read table t_order into wk_order index 1.
  w_doctype = wk_order-doc_type.
  case w_doctype.
    when 'P'.
outputx = wk_order-order_desc.
CREATE OBJECT cached_response TYPE CL_HTTP_RESPONSE EXPORTING add_c_msg
= 1.
IF XSTRLEN( OUTPUTX ) > 0.
response->delete_header_field(
name = if_http_header_fields=>cache_control ).
response->delete_header_field(
name = if_http_header_fields=>expires ).
response->delete_header_field(
name = if_http_header_fields=>pragma ).
response->set_header_field(
name = if_http_header_fields=>content_type
value = 'application/pdf' ).
   response->set_status( code = 200 reason = 'OK' ).
   response->server_cache_expire_rel( expires_rel = 180 ).
    response->set_header_field(
                      name  = 'content-disposition'
                       value = 'attachment; filename=attach_pdf.pdf' )
    response->set_header_field(
                   name  = 'cache-control'
                   value = 'max-age=0' ).
    l_pdf_len = xstrlen( wk_order-order_desc ).
    response->set_data( data = wk_order-order_desc
                             length = l_pdf_len ).
    CALL FUNCTION 'GUID_CREATE'
      IMPORTING
        ev_guid_32 = guid.
    CONCATENATE runtime->application_url '/' guid '.pdf' INTO
display_url.
    cl_http_server=>server_cache_upload( url      = display_url
                                         response = cached_response ).
  navigation->response_complete( ).
endif.
  endcase.
endif.

Similar Messages

  • Encrypted PDF file open error

    Hi All,
    problem is when i open to outlook to check mail at that time i got mail but attached file is not open which is encrypted file
    so please help how to open attached file following process i do .
    1: convert otf to pdf file
    2: download pdf file into application server
    3:encrypt pdf file with password protect
    4:upload pdf file from application server
    5:send mail
    1. OTR 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                = gv_bin_filesize
    *   BIN_FILE                    =
        TABLES
          otf                         = gt_otf
          lines                       = gt_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.
    then download pdf file into application server using following code
    OPEN DATASET l_file FOR OUTPUT IN BINARY MODE  .
      IF  sy-subrc = 0 .
        LOOP AT gt_pdf_tab.
          TRANSFER gt_pdf_tab TO l_file .
        ENDLOOP.
        CLOSE DATASET l_file  .
      ELSE.
        WRITE : / 'operating system could not open file' .
      ENDIF.
    *Then i use command line mode Encryptpdf, from verypdf.com, *
    so successfuly file encrypted and password protected.*
    Then upload pdf filw which is encrypted form application server
    OPEN DATASET to_file FOR INPUT IN BINARY MODE.
      IF sy-subrc = 0.
        DO .
          READ DATASET to_file INTO gs_objbin. "GS_PDF_TAB.
          IF sy-subrc = 0.
            APPEND gs_objbin TO gt_objbin .  "GS_PDF_TAB TO GT_PDF_TAB.
          ELSE.
            EXIT.
          ENDIF.
        ENDDO.
        CLOSE DATASET to_file.
      ENDIF.
    then i use use FM SO_NEW_DOCUMENT_ATT_SEND_API1
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data                    = gs_docdata
         put_in_outbox                    = 'X'
         commit_work                      = 'X'
    * IMPORTING
    *   SENT_TO_ALL                      =
    *   NEW_OBJECT_ID                    =
        TABLES
          packing_list                     = gt_objpack
    *   OBJECT_HEADER                    =  I_OBJTXT
         contents_bin                     = gt_objbin
         contents_txt                     = i_objtxt
    *   CONTENTS_HEX                     =
    *   OBJECT_PARA                      =
    *   OBJECT_PARB                      =
          receivers                        = gt_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
    Edited by: Krupaji on Oct 27, 2010 11:31 AM

    Related FM SO_NEW_DOCUMENT_ATT_SEND_API1 you can check following example:
    clear : gs_docdata,gt_objbin. "
        refresh : gt_objbin . "
    *   gs_docdata-obj_name = 'ord_accept'.
        gs_docdata-obj_name = 'Invoice'.
        gs_docdata-expiry_dat = sy-datum + 10.
    *   gs_docdata-obj_descr = 'Your Invoice No : '.
        gs_docdata-obj_descr = detail1.
        gs_docdata-sensitivty = 'F'. "Functional object
        gs_docdata-doc_size = gv_desc_lines * 255.
        clear gs_objpack-transf_bin.
    * Start line of object header in transport packet
    *    GS_OBJPACK-TRANSF_BIN = 'X'.
        gs_objpack-doc_size = gv_desc_lines * 255.
        gs_objpack-head_start = 1.
        gs_objpack-head_num = 0.
        gs_objpack-body_start = 1.
        gs_objpack-body_num = gv_desc_lines.
        gs_objpack-doc_type = 'RAW'.
    *    GS_OBJPACK-OBJ_NAME = 'ORDER_ACCEPTANCE'.
    *    GS_OBJPACK-OBJ_DESCR = 'ORDER_ACCEPTANCE.PDF'.
        append gs_objpack to gt_objpack.
      endif.
    *• Passing the SAP Script text lines to SAPoffice: Single List with Column Length 255 table
      clear : gs_objbin, gs_pdf_tab.
    *&      Encrypted file
      filename = name.
      if name is initial.
        concatenate   'd:\pdf\' main_dtl-vbeln '.PDF' into name.
      filename = name.
    endif.
    data: pdf type ref to cl_hrasr00_pdf_generation.
      data : lt_data            type solix_tab.
      open dataset filename for input in binary mode.
      if sy-subrc eq 0.
        read dataset filename into filex.
      endif.
      if filex is not initial.
        call function 'SCMS_XSTRING_TO_BINARY'
          exporting
            buffer        = filex
          importing
            output_length = file_length
          tables
            binary_tab    = gt_objbin.
      endif.
      close dataset filename.
    describe table gt_objbin lines gv_tab_lines.
      clear gs_objbin.
      read table gt_objbin into gs_objbin index gv_tab_lines.
      if sy-subrc = 0.
        gs_objpack-doc_size = ( gv_tab_lines - 1 ) * 255 + strlen( gs_objbin ).
        gs_objpack-transf_bin = 'X'.
        gs_objpack-head_start = 1.
        gs_objpack-head_num = 0.
        gs_objpack-body_start = 1.
        gs_objpack-body_num = gv_tab_lines.
        gs_objpack-doc_type = 'PDF'.
        gs_objpack-obj_name = 'INVOICE'.
        gs_objpack-obj_descr = 'Invoice Order'.
        append gs_objpack to gt_objpack.
      endif.
    call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        exporting
          document_data                    = gs_docdata
         put_in_outbox                    = 'X'
         commit_work                      = 'X'
    * IMPORTING
    *   SENT_TO_ALL                      =
    *   NEW_OBJECT_ID                    =
        tables
          packing_list                     = gt_objpack
    *   OBJECT_HEADER                    =  I_OBJTXT
         contents_bin                     = gt_objbin
         contents_txt                     = i_objtxt
    *   CONTENTS_HEX                     =
    *   OBJECT_PARA                      =
    *   OBJECT_PARB                      =
          receivers                        = gt_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
      if sy-subrc <> 0.
        message id sy-msgid type sy-msgty number sy-msgno
                with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      else.
        open dataset name for input in binary mode.
        if sy-subrc eq 0.
          delete dataset filename.
        endif.

  • HT1338 safari pdf file open error

    Dear. Sir
    I have recently downloaded Adobe Reader X, new version. I don't have any problem with this application when I open the stored pdf file in my mac.
    However, it has serious problem with opening a new pdf file on safari.
    When I download pdf files, the pdf document shows as a black....!!! (No respond at all from Safari)
    Please help me out
    Yours faithfully 
    Euna Noh

    Back up all data.
    Triple-click the line of text below to select it, the copy the selected text to the Clipboard (command-C):
    /Library/Internet Plug-ins
    In the Finder, select
    Go ▹ Go to Folder
    from the menu bar, or press the key combination shift-command-G. Paste into the text box that opens (command-V), then press return.
    From the folder that opens, remove any items that have the letters “PDF” in the name. You may be prompted for your login password. Then quit and relaunch Safari, and test.
    The "Silverlight" web plugin distributed by Microsoft can also interfere with PDF display in Safari, so you may need to remove it as well, if it's present.
    If you still have the issue, repeat with this line:
    ~/Library/Internet Plug-ins
    If you don’t like the results of this procedure, restore the items from the backup you made before you started. Relaunch Safari again.

  • When I try to open a pdf file I get an error message stating "There was an error opening the document.  The file is damaged and could not be repaired."  Other pdf files open fine.

    When I try to open a pdf file I get an error message stating "There was an error opening the document.  The file is damaged and could not be repaired."  Other pdf files open fine.

    You need to get a new copy of the PDF.

  • I downloaded acrobat reader dc. after download completed, I could not open many PDF files. Error read: "could not open this file because its either not a supported file or because the file has been damaged". I opened a new user account and moved these fil

    I recently downloaded acrobat reader dc. After download was complete, I could not open PDF files. Error read "Adobe acrobat reader DC could not open this file because its either not a supported file or the file has been damaged". Any suggestions?

    HI davidd92392148,
    Is this error occurring for all PDF files that you try to open? There is an issue where all file icons can change to the PDF icon after installation, so is it possible that the files you're trying to open have been affected by this issue (and aren't actually PDF files)? Please see Application, file icons change to Acrobat/Reader icon.
    If that document isn't the key, then please tell us more about these files. Where are they stored? Did they open in previous versions of Reader?
    Best,
    Sara

  • How to fix the .pdf file with error "invalid annotation object"

    how to fix the .pdf file with error "invalid annotation object"

    As long as the PDF opens, then just try saving it to a new file name. There may be a preflight script that would help troubleshoot the issue.

  • Why can't I scroll or use MMB to open pages in new tab, when I have a PDF file opened in FF4?

    If I have a PDF file opened in firefox 4, I am for unknow reason unable to open pages in new tabs with MMB or scroll thepage up or down. The scroll function isn't working at all, and it seems like I'd be scrolling the PDF file, not the page of my current tab.

    Hi aK'
    Nice, memorable user name!
    -1712 is a timed out error. One reported cause (with other applications) is that the application is attempting to open a large number of files, or a file that no longer exists.
    Try holding down the shift key when launching preview. This prevents the application from attempting to open windows that were not closed before quitting the application.
    Regards,
    Barry

  • Why won't some pdf-files open on tablet/phone?

    I simply get the error saying: The document cannot be opened because it's not a valid pdf-document.
    However I have no problems opening the file with my laptop, only my phone and tablet (Jellybean 4.2.2) won't open it.
    My friends also have managed to open the file on their tablets (android/windows).
    Have reinstalled and checked updates and tried other programs but none has worked for me.
    I simply have no clue and would appreciate help.

    Hey,
    Seems like the problem was in the web browser I was using, as the file just
    didn't download correctly.
    Thanks for the help anyway, much appreciated.
    Tuomo
    2014-10-15 1:03 GMT+03:00 Tuomo Stenberg <[email protected]>:
    Hey,
    spent some time discussing this with some friends of mine and found out
    that the document can be opened by downloading it to the computer and
    transferring then to the tablet or phone. The difference is that when
    downloading with tablet/phone I get a .pdf file, which only has some html
    code. So I guess the problem has something to do with the encryption of the
    file. Here are the 2 different files I get as attachments. After all this
    might not have anything to do with adobe, but some other stuff I don't
    really understand.
    Tuomo
    2014-10-14 22:26 GMT+03:00 Romil Mittal <[email protected]>:
    >>     Why won't some pdf-files open on tablet/phone?  created by Romil
    >> Mittal <https://forums.adobe.com/people/Romil+Mittal> in *Adobe Reader
    >> for Android* - View the full discussion
    >> <https://forums.adobe.com/message/6825723#6825723>
    >>

  • Using browser javascript to copy selected text from a pdf file opened in Air app.

    I have posted this question on reader forum as well, but I think it is more suited here...
    I am trying to create a note-taking application in air. I want to extract selected text from pdf file as a string object or to the clipboard.
    Obviously, all pdfs in my local storage will not be scripted to recieve postMessages and act accordingly, and that is not practical either. So, my problem is, how can I copy the selected text in the pdf file (opened as an object in htmlloader within my Air app) to clipboard or directly in another control by say clicking a button in air application? I suppose, this is possible using javascript, however, I don't know which reader methods are exposed to the wrapper htmlloader control. In short, I want to execute app.execMenuItem("Copy") command through htmlloader javascript. Any alternate solutions are also welcome.
    This is similar to passing inbuilt commands/methods/functions (of adobe reader) to pdf-reader plugin embedded in a webpage via javascript. This is possible in IE where the pdf is rendered as activex object, and hence JSObject interface of pdf document/reader is accessible to the browser javascript. I have also read that this same JSObject is accessible to VB as interface for IAC, so as the Air is Adobe's own product, I was wondering if equivalent of JSObject is accessible to htmlloader control as well.
    Thanks in advance...
    Mits

    Thank you Thom for your reply...
    from
    http://www.adobe.com/devnet/acrobat/javascript.html
    ...Through JavaScript extensions, the viewer application and its plug-ins expose much of their functionality to document authors, form designers, and plug-in developers...
    As it is explicitly mentioned, that the functionality of adobe reader are exposed for plugin development, I thought someone here might have used external javascript to execute some safe methods in adobe reader. The functionality (i.e. external javascript interface-JSObject) is already available for VB programmers to develop IAC. Further, the Acrobat SDK example called "AcroPDFinHML" shows how one can embed a pdf-reader in a html page and execute some safe methods (like gotonextpage(), zooming etc.) in IE as ActiveX plugin. I have checked it myself for adobe reader 9, and it works perfectly, so there is no security issue as such to implement the same for another browser (like in my case, the htmlloader control in flex/air app).
    I intend to create a note taking application in air, where it is very much required that I should be able to copy selected text from various pdf documents, that are open in my app, and subsequently paste/collect/save the collected notes and process them afterwords (offcourse, from the pdfs that allow me copying text). However, it is not happening for me here. As the pdfs are opened through adobe reader plugin, it does not register the copy command executed by my air app. It registers the system level copy command (by keyboard shortcut Ctrl+C), but my air app has no way to execute the system level copy command programmatically. So I am kind of stuck here...
    Thanks again for your reply. Having known what am I intend to accomplish, any other (may be alternative) solutions will be appreciated nonetheless...
    Mits

  • File opening error

    hello friends,
    i am doing data migration with lsmw withe directinput method so i did everything fine till the end i defined the logicalfiles also correctly and defined everthing perfeclty
    but i am getting below error
    File open error
    belrd110\INPUT\CT.TXT Permission  denied
    can anyone let me know where this is going wrong
    i am having the authorisation at the server level also and in the read and convert steps records and data coming perfectly but when i excute it at the end it is giving such error
    ur help will be appreciated
    Naveen

    Hi Naveen,
    Did you write your statment like this?
    OPEN DATASET P_DOWN FOR OUTPUT IN TEXT MODE.
    If it is not working, try to create a new file and access the same.
    Thanks,
    Sreekanth

  • My pdf files open in media player how do I default it to adobe reader

    My pdf files open in media player how do I default it to adobe reader.   I have win 7 enterprise servic pack 1

    You'll have to change the file association of PDF files back to Adobe Reader; see http://windows.microsoft.com/en-in/windows-vista/change-which-programs-windows-uses-by-def ault

  • How do I make a link found in a .pdf file open in Firefox?

    When I have a .pdf file open in Adobe Reader, the link opens in Google Chrome.  How do I make it open in Firefox?

    Use Firefox as your default browser.

  • Whenever there is a pdf file open in one of the tabs then I can't use the scrolling (of my touchpad) in any other tab in FF4. How can this be corrected?

    Even if one of the open tabs contain a .pdf file opened in it, then I can't scroll the pages down in any other tab. Irrespective of which tab is active, the pages in the pdf get scrolled. :(
    I've tried to reinstall the Firefox, but that hasn't helped. In fact the problem continues even after I've done a complete system format.

    My workaround for this problem is to open the tabbed pdf document into a new Firefox window (Right-Click tab --> Move to New Window) which unlocks scrolling capabilities for all tabs in your original window.

  • When I have a pdf file open, I used to be able to click on "Bookmarks" tab on left side and allow me to click on each individual page and delete if I needed to.  Now when I click on the Bookmarks tab, that section is empty.  How can I get it to show each

    when I have a pdf file open, I used to be able to click on "Bookmarks" tab on left side and allow me to click on each individual page and delete if I needed to.  Now when I click on the Bookmarks tab, that section is empty.  How can I get it to show each page again?

    Hi chrismarks1,
    I think you may be confusing bookmarks with thumbnails. If you click the Page Thumbnails icon (the one above the Bookmarks icon), then you can delete a page by clicking its thumbnail, and clicking the Delete Pages icon (the trashcan icon). Just make sure that you're viewing the PDF file in Acrobat (rather than Acrobat Reader), as you can't delete pages from Reader.
    Best,
    Sara

  • How to highlight searched words in pdf file opens from web??

    Hello fellows
    I need to create a web page that holds couple controls include "search" button .When client clicks on the button the programm will search pdf file, open it in client reader with highlight on searched words ..
    Is that any posibility to do it using javascript on a client or c# ,vb.net on the server ??
    I'm very novice in PDF developing so any ideas or conclusions would be very usefull!

    Thank you for answer
    But maybe you have any idea how I can do it??
    This is very important feature for our project.
    Some additional information : our project will hosted in SharePoint 2007
    When I use adobe Ifilter for moss and set in querystring #search="searchword"  I get highlights, but only in a browser.
    But if a reader was configured to open client application this feature wasn't work.
    Any suggestion ???

Maybe you are looking for