Byte serving pdf files:

Hi,
problem:
i have some pdf files outside the webroot and i have to serve those files to user as a fast web view.
Note: fast web view is a feature of IIS not coldfusion application server.
currently how i m doing this made a virtual directory to those pdf files folder and i redirect the user to the attachment
so the file serve by IIS itself.
however using this approach user can get the file if he knows the attachment file name. so this is a security concern.
can anyone suggest me any alternate solution for this security concern.
thanks
Prashant Gupta
Blog: http://chakdecoldfusion.blogspot.com/

Hi mack,
thanks for the quick reply however this is not my problem.
if i serve the pdf files using <cfcontent tag it takes time to load in the browser even if pdf file is marked for fast web view.
so i choose that i create a virtual directory and redirect the user to that file.
in this way IIS handle this request and since this is in-built feature of web server so user is
able to see the pdf as fast web view.
but my main security concern in this apporach is if user has file name then he can use the same url and get some other pdf file.
however i appreciate your reply.
thanks
Prashant

Similar Messages

  • Displaying byte array PDF file in Portal

    Hi,
    i need to display a PDF file. The PDF is stored in a byte array. This works fine when i run my code (see below) from the .jpf via the debugger/browser, but when i use it as a portlet, in the portal, it does not work ?
    Any help is much appreciated.
    Thanks
    Mark
    byte[] pdfDocument = docStore.getPDF();
    ServletOutputStream outPdf = response.getOutputStream();
    response.setContentType("application/pdf");
    outPdf.write(pdfDocument);
    outPdf.flush();
    outPdf.close();

    Mark,
    Note that the portal sets the content type (e.g, text/html) and encoding
    as the portal page starts rendering. In your case, the
    setContentType() would be useless since the servlet container won't let
    you change it. You can either use a popup browser window for the pdf as
    Kunal suggested, or use an iframe if you want to render the pdf inside
    the portlet window.
    Subbu
    Mark Gilleece wrote:
    Hi,
    i need to display a PDF file. The PDF is stored in a byte array. This works fine when i run my code (see below) from the .jpf via the debugger/browser, but when i use it as a portlet, in the portal, it does not work ?
    Any help is much appreciated.
    Thanks
    Mark
    byte[] pdfDocument = docStore.getPDF();
    ServletOutputStream outPdf = response.getOutputStream();
    response.setContentType("application/pdf");
    outPdf.write(pdfDocument);
    outPdf.flush();
    outPdf.close();

  • How to view server .pdf file in WDP

    Hi,
    I want to open/view the file(.pdf) in WebDynpro which is attched in SAP CRM transaction as document.
    Can anybody help me in this.
    Regards,
    Harshad.

    Hi patel,
    check this link,it's very useful
    Opening a PDF File from WebDynpro
    Re: UI element for interactive Form
    Re: PDF file on my view
    displaing the pdf,
    Displaying PDF file in browser
    Regards,
    vino
    Message was edited by:
            Vinoth Raja.V

  • Adf and visualizing a document on the server (pdf files)

    My company is generating lot of reports in PDF into a unix server using BO Report. We have ORA9Ias as a server and I would like to know if it is possible to generate an ADF,UIX application to visualize the report into the web server. Reports are store into a different path of the server. I use ANT a lot and I'm capable of generating XML files that would represent all the PDF available. I was thinking in using datacontrol with castor to read this information but I did not seen anything to upload the PDF into the UIX page....or JSP.....

    The only other way to upload the document to his site is to use Media Downloads, also known as Literature in some part of the system. Then, inside the InContext Editor you click on the link and and select page from my site, then link to the literature item created.
    That's all.
    Cheers,
    -mario

  • Uploading PDF-file from unix to SAP internal table

    Hi,
    i have to write an abap that sends a pdf-file from a unix (SAP server) by mail to some people.
    The mailing part is done, but for creating the attachment. I'm reading the pdf-file into an internal table (in a binary way). Then i'm using this int.table to send the mail.
    The email is sent with an attachment, but i cannot open the pdf-file because of an error ( file damaged ). So before sending it by mail, i'm downloading the pdf file to my pc by using WS_DOWNLOAD with the same internal table. The download file gives the same error.
    If i look at the size :
    - originally pdf file 71743 bytes
    - resulting pdf file 71665 bytes (281 lines x 255)
    The creation of the internal table is as follows :
    open dataset g_file for input in binary mode.
      check sy-subrc eq 0.
      do.
    *    read dataset g_file MAXIMUM LENGTH 255 into wa_pdf.
        read dataset g_file into wa_pdf.
        if sy-subrc ne 0. exit. endif.
        append wa_pdf_hex to i_pdf.
      enddo.
      close dataset g_file.
    where:
    types:  tt_pdf  type table of soli,   "raw 255 long
    data: i_pdf type tt_pdf,
             wa_pdf like line of i_pdf
    Is there a better way to read in the pdf-file ? Any suggestions ?
    regards,
    Hans
    [email protected]

    Hello Hans,
    this is a little example from a program to send mail with picture. The problem is the same
    form p_create_mail tables itab_html.
      data : object_hd_change like sood1 occurs 0 with header line,
             objpara          like selc  occurs 0 with header line,
             receivers        like soos1 occurs 0 with header line,
             packing_list     like soxpl occurs 0 with header line,
             fic_attach       like soli  occurs 0 with header line,
             struct_user_adress like usaddress ,
             v_file(80) type c ,
             v_buff(255) type c ,
             v_num(9) type n,
             v_length type i ,
             v_total_length type i,
             v_len(9) type n.
      move : 'HTM'  to object_hd_change-file_ext ,
             'PIOU' to object_hd_change-objdes.
      append object_hd_change.
    * Find email addr for the username.
      loop at s_bname.
        call function 'SUSR_USER_READ'
          exporting
            user_name                  = s_bname-low
          importing
            user_address               = struct_user_adress
          exceptions
            user_name_not_exists       = 1
            internal_error             = 2
            others                     = 3.
        select single smtp_addr
               into receivers-recextnam
               from adr6
               where addrnumber eq struct_user_adress-addrnumber
               and   persnumber eq struct_user_adress-persnumber.
        if sy-subrc eq space.
          move 'U' to receivers-recesc.
          append receivers.
        endif.
      endloop.
    * Get the picture.
      move '/sap_interfaces/D27/pzr_00/data/test/logopharma.gif'
           to v_file.
      open dataset v_file for input in binary mode.
      do.
        read dataset v_file into v_buff length v_length.
        v_total_length = v_length + v_total_length.
        move v_buff+0(v_length) to fic_attach-line+0(v_length).
        append fic_attach.
        if sy-subrc ne space.
          exit.
        endif.
      enddo.
      describe table fic_attach lines v_num.
      describe field fic_attach-line length v_len.
      move : 'Logo' to packing_list-objdes ,
             'Logo' to packing_list-objnam ,
             '1'    to packing_list-body_start ,
             'raw'  to packing_list-objtp ,
             'GIF'  to packing_list-file_ext .
      packing_list-body_num = v_num.
      packing_list-objlen   =  v_num * v_len.
      append packing_list.
    * Send mail.
      call function 'SO_OBJECT_SEND'
           exporting
               object_hd_change           = object_hd_change
               object_type                = 'RAW'
               owner                      = sy-uname
           tables
               objcont                    = itab_html
               objpara                    = objpara
               receivers                  = receivers
               packing_list               = packing_list
               att_cont                   = fic_attach
           exceptions
               others                     = 01.
    endform.                     " P_CREATE_MAIL.
    Regards
    Frédéric

  • View PDF File Without Adobe Reader Installed

    All,
    Is there a way to serve PDF files on a website to users without Adobe Reader installed on their machine?  Is there a plug-in that I can install on the webserver that will be used to launch PDF files instead?

    what device are you using?

  • How to show/print waiting message when system is serving pdf to browser

    Hi,
    does anybody know how to print/show "please wait for your request to be completed..." message when they try to click GeneratePdf button for example
    they way i do serving pdf to the browser is as below
    response.reset();
    response.setContentLength(contentLength);
    response.setContentType("application/pdf");
    response.setHeader("Content-disposition", "inline; filename=\""System.currentTimeMillis()+".pdf"+ "\"");
    output = new BufferedOutputStream(response.getOutputStream());
    while (contentLength-- > 0) {
    output.write(input.read());
    output.flush();and this is what was written in my popup jsp ( when user click GeneratePdf , the application will process it and at the end serve pdf file to the user using popup window )
    <body> <h1>Please Wait for your request to be completed...........</h1> </body> </html>
    <%
    boolean redirect=false;
    try{
    PdfDispatcher.dispatchApplication(response,session);
    }catch(Throwable t){
    System.out.println("Application Dispatcher Exception ... "+t.getMessage());
    System.out.println("Continue as per normal....");
    redirect = true; // will redirect to other jsp output
    if(redirect){
    //go to other jsp
    }The problem is my message above never got printed to the page ( i guess because the browser thinks that the response has not been completed )
    by the time the response has been completed the whole page will be cover in pdf document
    The reason i want to do this because my user complaining that they see blank page for long time when the system is slow to generate/server pdf to them.
    and it would be better to show some "waiting message" when the system is processing the application and server pdf at the end of the operations.
    anybody know how to workaround this?
    Thanks

    just_a_kid83 wrote:
    does anybody know how to print/show "please wait for your request to be completed..." message when they try to click GeneratePdf button for exampleUse JavaScript+DOM. Add a <div> somewhere in the page where the message should be displayed and put the message and an animated 'loading' gif in it. Hide the <div> using the CSS 'display' property which is set to 'none'. Then add an onclick event to the button/link which downloads the PDF file which gets the <div> element by its ID and set its 'display' property to 'block'.

  • Sample code to dynamically append bytes to pdf

    Hi,
    I need to dynamically append bytes to pdf. It would be great if some one post sample code for that.
    Thanks,
    Veerabhadrarao

    user10710231 wrote:
    i am unable to append the bytes to pdf file . Can you send me some code snippet.It is unnecessary to ask someone to invest time in you when you can easily google for the hundreds or thousands of example snippets already out there. You know what to look for now, now make some effort yourself. Its like asking someone to go buy a tooth brush for you when you know there is one somewhere upstairs, you just refuse to go look for it and make someone else do the work.

  • I can't delete pdf file !!! Please help

    I've got a 0 byte, errorous pdf file, which I can't delete. Neither in normal nor in safe mode.
    it just says pdf is no longer on the disk.
    I'm using Win vista. Any idea? Suggestions?

    What I would try if I encountered the situation:
    delete from a Command Prompt: del /f filename
    use Unlocker

  • Reading a pdf file from URL into Byte array/ByteBuffer in an applet.

    I'm trying to figure out why this particular snippet of code isn't working for me. I've got an applet which is supposed to read a .pdf and display it with a pdf-renderer library, but for some reason when I read in the .pdf files which sit on my server, they end up as being corrupt. I've tested it by writing the files back out again.
    I've tried viewing the applet in both IE and Firefox and the corrupt files occur. Funny thing is, when I trying viewing the applet in Safari (for Windows), the file is actually fine! I understand the JVM might be different, but I am still lost. I've compiled in Java 1.5. JVMs are 1.6. The snippet which reads the file is below.
    public static ByteBuffer getAsByteArray(URL url) throws IOException {
            ByteArrayOutputStream tmpOut = new ByteArrayOutputStream();
            URLConnection connection = url.openConnection();
            int contentLength = connection.getContentLength();
            InputStream in = url.openStream();
            byte[] buf = new byte[512];
            int len;
            while (true) {
                len = in.read(buf);
                if (len == -1) {
                    break;
                tmpOut.write(buf, 0, len);
            tmpOut.close();
            ByteBuffer bb = ByteBuffer.wrap(tmpOut.toByteArray(), 0,
                                            tmpOut.size());
            //Lines below used to test if file is corrupt
            //FileOutputStream fos = new FileOutputStream("C:\\abc.pdf");
            //fos.write(tmpOut.toByteArray());
            return bb;
    }I must be missing something, and I've been banging my head trying to figure it out. Any help is greatly appreciated. Thanks.

    Keshav.. wrote:
    I too was going through the same problem but I found for some pdfs it worked fine.I didnt get ur solution.Please explain bcoz it may work for every pdfThis thread is over 3 years old and dead. Please open a new thread which provides details of the problem you are having. Link to this thread if you think it is necessary.
    I shall lock this thread.

  • Download PDF file from Application Server in BSP

    Hello,
    We have a requirement on which we want to download a PDF file stored in Application server using BSP application. I have used function module  ARCHIVFILE_SERVER_TO_CLIENT but this FM will help only if i want to download file from GUI it won't work in BSP application.
    Further i have used class CL_BSP_UTILITY and download method to download file from application server but it is not working in desired manner.
    I am attaching my code for your reference:
    DATA: BUTTON_EVENT TYPE REF TO CL_HTMLB_EVENT_BUTTON ,
               EVENT TYPE REF TO IF_HTMLB_DATA.
    DATA: LS_HOURS LIKE LINE OF GT_HOURS.
    DATA STR TYPE STRING.
    DATA: OUTPUT TYPE STRING ,
              L_XSTRING TYPE XSTRING ,
               APP_TYPE TYPE STRING. 
    EVENT = CL_HTMLB_MANAGER=>GET_EVENT( REQUEST ).
    DATA PHY_NAME_OUT     TYPE SAPB-SAPPFAD.
    IF EVENT IS NOT INITIAL AND EVENT->EVENT_NAME = HTMLB_EVENTS=>BUTTON .
      BUTTON_EVENT ?= EVENT .
      CASE EVENT->EVENT_SERVER_NAME.
        WHEN 'test' .
          IF GT_HOURS IS NOT INITIAL.
            PHY_NAME_OUT = '/usr/sap/put/form16//01000200_2007.PDF'.
          OPEN DATASET PHY_NAME_OUT FOR INPUT IN TEXT MODE ENCODING DEFAULT.
            IF SY-SUBRC IS INITIAL.
              DO.
                READ DATASET PHY_NAME_OUT INTO STR.
                IF SY-SUBRC IS INITIAL.
                CONCATENATE
                    OUTPUT
                    str
                    cl_abap_char_utilities=>cr_lf
    INTO output SEPARATED BY space. "cl_abap_char_utilities=>horizontal_tab
                ELSE.
                  EXIT.
                ENDIF.
              ENDDO.
            ENDIF.
    *LOOP AT gt_hours INTO ls_hours.
    *CONCATENATE
    *OUTPUT
    *ls_hours-hour
    *cl_abap_char_utilities=>cr_lf
    *INTO output SEPARATED BY space. "cl_abap_char_utilities=>horizontal_tab
    *ENDLOOP.
            APP_TYPE = 'APPLICATION/PDF;charset=utf-16le'.
            CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
              EXPORTING
                TEXT     = OUTPUT
                MIMETYPE = 'APPLICATION/PDF;charset=utf-16le'
              IMPORTING
                BUFFER   = L_XSTRING.
            CONCATENATE CL_ABAP_CHAR_UTILITIES=>BYTE_ORDER_MARK_LITTLE
            L_XSTRING
            INTO L_XSTRING IN BYTE MODE.
            CALL METHOD CL_BSP_UTILITY=>DOWNLOAD
            EXPORTING
            OBJECT_S = L_XSTRING
            CONTENT_TYPE = APP_TYPE
            CONTENT_DISPOSITION = 'attachment;filename=webforms.pdf'
            RESPONSE = _M_RESPONSE
            NAVIGATION = NAVIGATION.
          ENDIF.
      ENDCASE.
    ENDIF.
    From this code i am able to download PDF file but it is not opening in local machine.
    If any other way to download file then please suggest.
    waiting for ur reply.
    Regards,
    Gagan

    Hi,
    you do the file reading wrong:
    have a look at:
    Local declarations.
      data:
        components          type stringtab,
        component           type string,
        path                type text255,
        file                type text255,
        line_length         type i,
       filecontent_binary type sdokcntbin,
        rows                type sytabix,
        content             type sdokcntbin,
        exception           type ref to cx_sy_file_access_error,
        exception_tmf       type ref to cx_sy_too_many_files ,
        block_size          type i value 1022,
        length              type i.
      field-symbols:
        <hex_container>     type x.
      constants:
        c_dms_blk_size      type i value 2550.
      clear file_size.
      try.
          open dataset file_name  for input in binary mode message message.
        catch cx_sy_file_open  into exception.
          case exception->textid.
            when '4182174D03030063000000000A1551B1'. raise access_error.
            when '41825AD355C3005E000000000A1551B1'. raise open_error.
            when '47E8B03AECE5BA07E10000000A114829'. raise already_open.
            when others.
          endcase.
        catch cx_sy_file_authority into exception.
          case exception->textid.
            when '4182174D03030063000000000A1551B1'. raise access_error.
            when 'A70BB8396F051547E10000000A11447B'. raise authority_error.
            when others.
          endcase.
        catch cx_sy_too_many_files into exception_tmf.
          case exception_tmf->textid.
            when '8708B73915F6B645E10000000A11447B'. raise too_many_files.
            when others.
          endcase.
      endtry.
      do.
        try.
            read dataset file_name into filecontent_binary-line.
            if sy-subrc <> 0.
              add  line_length to file_size.
              append filecontent_binary to file_content_binary.
              exit.
            else.
              add  line_length to file_size.
              append filecontent_binary to file_content_binary.
            endif.
          catch cx_sy_file_open_mode into exception.
            case exception->textid.
              when '9207B73915F6B645E10000000A11447B'. raise cx_sy_file_open_mode.
              when '9807B73915F6B645E10000000A11447B'. raise read_only.
              when '9E07B73915F6B645E10000000A11447B'. raise not_open.
              when '409D273A2D824360E10000000A11447B'. raise incompatible_mode.
              when others.
            endcase.
        endtry.
      enddo.
      try.
          close dataset file_name.
        catch cx_sy_file_close into exception.
          case exception->textid.
            when '4182174D03030063000000000A1551B1'. raise access_error.
            when 'C10BB8396F051547E10000000A11447B'. raise close_error.
            when others.
          endcase.
        catch cx_sy_file_access_error into exception.
          case exception->textid.
            when '4182174D03030063000000000A1551B1'. raise access_error.
            when others.
          endcase.
      endtry.
    Get file size.
      split file_name at '/' into table components.
      describe table components lines sy-tfill.
      read table components into component index sy-tfill.
      path = file_name.
      replace component in path with ''.
      file = component.
      call function '/EUH/MMS_GET_FILE_SIZE'
        exporting
          dir_name  = path
          file_name = file
        importing
          file_size = file_size.
    and function /euh/mms_get_file_size.
    ""Local Interface:
    *"  IMPORTING
    *"     VALUE(DIR_NAME) TYPE  TEXT255
    *"     VALUE(FILE_NAME) TYPE  TEXT255
    *"  EXPORTING
    *"     VALUE(FILE_SIZE) TYPE  SDOK_FSIZE
    *"  EXCEPTIONS
    *"      NO_AUTHORITY
    *"      ACTIVITY_UNKNOWN
    *"      NOT_A_DIRECTORY
    *"      NO_MEDIA_IN_DRIVE
    *"      TOO_MANY_ERRORS
    *"      TOO_MANY_FILES
    *"      BRACKET_ERROR_IN_FILENAME
    *"      NO_SUCH_PARAMETER
      types: begin of files,
               line like ocs_file,
             end of files.
      data: file type files,
         f_subrc like sy-subrc value 0,
         errno(3)    type c,
         errmsg(40)  type c,
         pos                        type i,
         len                        type i,
         parameter(120)             type c,
         help1(120)                 type c,
         help2(120)                 type c,
         error_counter              type i.
      data:
        dir_list  like  ocs_file occurs 0 with header line.
    CASE sy-subrc.
       WHEN 1. f_subrc = 64.
       WHEN 2. f_subrc = 65.
       WHEN 0.
      search dir_name for 'SY-HOST'.    "Is SY-HOST used in directory name?
      if sy-subrc = 0.
        pos = sy-fdpos + 7.
        move dir_name(sy-fdpos) to help1.
        move dir_name+pos to help2.
        concatenate help1 sy-host help2 into dir_name.
      endif.
      do 12 times.                                 " To avoid endless loop
        if dir_name cs '$('.           " Replace parameter by their value
          pos = sy-fdpos + 2.
          if dir_name cs ')'.
            len = sy-fdpos - pos.
            if len le 0.
              f_subrc = 4. exit.
            else.
              parameter = dir_name+pos(len).
              call 'C_SAPGPARAM' id 'NAME'  field parameter
                               id 'VALUE' field parameter.
              if sy-subrc = 0.
                len = pos + len + 1.
                pos = pos - 2.
                if pos > 0.
                  move dir_name(pos) to help1.
                else.
                  help1 = ''.
                endif.
                pos = strlen( dir_name ).
                if pos > len.
                  move dir_name+len to help2.
                else.
                  help2 = ''.
                endif.
                concatenate help1 parameter help2 into dir_name.
              else.
                f_subrc = 8. exit.
              endif.
            endif.
          else.
            exit.
          endif.
        else.
          exit.
        endif.
      enddo.
      shift dir_name right deleting trailing '/\ '.
      shift dir_name left deleting leading space.
      call 'C_DIR_READ_FINISH'                      " this is from RSWATCH0
            id 'ERRNO'  field errno
            id 'ERRMSG' field errmsg.
      call 'C_DIR_READ_START'
            id 'DIR'    field dir_name
            id 'FILE'   field file_name
            id 'ERRNO'  field errno
            id 'ERRMSG' field errmsg.
      case sy-subrc.
        when 1.
          case errno.
            when 2 or 20.  f_subrc = f_subrc + 66.
            when ' '. f_subrc = f_subrc + 67.
          endcase.
        when 0.
          clear error_counter.
          do.
            clear file.
            clear dir_list.
            call 'C_DIR_READ_NEXT'
                id 'TYPE'   field file-line-type
                id 'NAME'   field file-line-name
                id 'LEN'    field file-line-len
                id 'OWNER'  field file-line-owner
                id 'MTIME'  field file-line-mtime
                id 'MODE'   field file-line-acc_mode
                id 'ERRNO'  field errno
                id 'ERRMSG' field errmsg.   "sy-subrc = 3 is e.g. if return
            if sy-subrc = 0 or sy-subrc = 3."data do not fit into variables
              perform p6_to_date_time_tz(rstr0400) using
                    file-line-mtime
                    file-line-mod_time
                    file-line-mod_date.
              file_size = file-line-len.
              dir_list = file-line.
              append dir_list.
            elseif sy-subrc = 1.                 " nothing (more) found
              exit.
            else.
              if error_counter > 50.
                call 'C_DIR_READ_FINISH'
                    id 'ERRNO'  field errno
                    id 'ERRMSG' field errmsg.
                pos =  f_subrc mod 2.
                if pos = 0. f_subrc = f_subrc + 1. endif.
                exit.
              endif.
              add 1 to error_counter.
            endif.
            if sy-index > 1000.
              pos =  f_subrc mod 4.
              if pos = 0. f_subrc = f_subrc + 2. endif.
              exit.
            endif.
          enddo.
          call 'C_DIR_READ_FINISH'
               id 'ERRNO'  field errno
               id 'ERRMSG' field errmsg.
          if sy-opsys(3) = 'Win' and not ( file_name cs '*' ).
            describe table dir_list lines len.
            if len = 0.
              help1 = file_name.
              translate help1 to upper case.
              translate help1 using
                   'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.
              call 'C_DIR_READ_START'
                    id 'DIR'    field dir_name
                    id 'FILE'   field help1.
              if sy-subrc = 0.
                clear error_counter.
                do.
                  clear file.
                  clear dir_list.
                  call 'C_DIR_READ_NEXT'
                      id 'TYPE'   field file-line-type
                      id 'NAME'   field file-line-name
                      id 'LEN'    field file-line-len
                      id 'OWNER'  field file-line-owner
                      id 'MTIME'  field file-line-mtime
                      id 'MODE'   field file-line-acc_mode
                      id 'ERRNO'  field errno
                      id 'ERRMSG' field errmsg.
                  if sy-subrc = 0 or sy-subrc = 3.
                    help2 = file_name.
                    translate help2 to upper case.
                    help1 = file-line-name.
                    translate help1 to upper case.
                    if help1 = help2.
                      perform p6_to_date_time_tz(rstr0400) using
                         file-line-mtime
                         file-line-mod_time
                         file-line-mod_date.
                      dir_list = file-line.
                      append dir_list.
                    endif.
                  elseif sy-subrc = 1.
                    exit.
                  else.
                    if error_counter > 50.
                      call 'C_DIR_READ_FINISH'
                          id 'ERRNO'  field errno
                          id 'ERRMSG' field errmsg.
                      pos =  f_subrc mod 2.
                      if pos = 0. f_subrc = f_subrc + 1. endif.
                      exit.
                    endif.
                    add 1 to error_counter.
                  endif.
                  if sy-index > 1000.
                    pos =  f_subrc mod 4.
                    if pos = 0. f_subrc = f_subrc + 2. endif.
                    exit.
                  endif.
                enddo.
                call 'C_DIR_READ_FINISH'
                     id 'ERRNO'  field errno
                     id 'ERRMSG' field errmsg.
              endif.
            endif.
          endif.
      endcase.
    ENDCASE.
    CASE f_subrc.
       WHEN 1 OR 3.             RAISE too_many_errors.
       WHEN 2.                  RAISE too_many_files.
       WHEN 4 OR 5 OR 6 OR 7 OR 70 OR 71.
         RAISE bracket_error_in_filename.
       WHEN 8 OR 9 OR 10 OR 11 OR 74 OR 75.
         RAISE no_such_parameter.
       WHEN 64.                 RAISE no_authority.
       WHEN 65.                 RAISE activity_unknown.
       WHEN 66.                 RAISE not_a_directory.
       WHEN 67.                 RAISE no_media_in_drive.
    ENDCASE.
    endfunction.
    Now you will be able to get the filesize and the file in SDOK format sdokbin.
    Okay.
    You have to build an request and push the content to the user like:
      call method server->response->set_header_field( name = 'Content-Type' value = value ).
      describe field file_content_binary-line length line_length in byte mode.
      bytes_rest = file-size.
      loop at file_content_binaries assigning <file_content_binary>.
        move <file_content_binary>-line to data.
        if bytes_rest <= 0. "mismatch between line values and size
          exit.
        endif.
        if bytes_rest >= line_length.
          call method server->response->append_data( data = data
            length = line_length ).
        else.
          call method server->response->append_data( data = data
            length = bytes_rest ).
        endif.
        bytes_rest = bytes_rest - line_length.
      endloop.
    This will work.
    You can set the header fields like you want. Have also a look at sicf node contentserver
    and its handler: CL_HTTP_EXT_CSIF

  • PDF file downloading from server to client

    Hello,
    I am a newbie to Oralce UCM. Writing a component to merge some PDF files and allow user to save/open it on client side.
    The file downloaded is of 0 bytes and when opened it says -
    Adobe Reader could not open the the file because it is either not a suppported file type or because the file is damaged(It was sent as an email attachment and was not correctly decoded)
    this.m_binder.m_contentType = "application/pdf";
    this.m_binder.m_clientEncoding = "utf-8";
    DataStreamWrapper dataStreamWrapper = this.createNewDownloadStream();
    dataStreamWrapper.m_clientFileName = "MergedPDF";
    dataStreamWrapper.m_inStream = mergedPDF.getDocumentInputStream();
    dataStreamWrapper.m_inStreamActive = true;
    dataStreamWrapper.m_dataType = "application/pdf";
    try {
    this.m_httpImplementor.sendStreamResponse(this.m_binder, dataStreamWrapper);
    } catch (ServiceException e) {
    e.printStackTrace();
    Some clue would really help :)
    Thanks,
    Fauzia

    Hi Jiri,
    I have created and HCSP page where data is being populated dynamically. User may select some of the files from this page through checkbox. Page also has a download button which when clicked will merge all the selected documents and let the user open/save it.
    Information like Native URL, docName is passed on to the content server when the component is called (download button-click).
    Merging the PDFs, I have used a custom utility which takes url as a parameter and returns back the inputstream of merged PDF.
    And last, I have used DataStreamWrapper to send this inputstream back to the client as an attachment which can be read by IE.
    Also, I thought at first to use HTTPHeader where parameters like content-disposition, content-type can be set. But UCM already provides a better way to achieve this i.e. through DataStreamWrapper.
    public class MergePDF extends Service {
         public List<PdfDocumentSource> createPdfDocumentSourceList(
                   String... urlStrings) throws MalformedURLException {
              List<PdfDocumentSource> sourceList = new ArrayList<PdfDocumentSource>(
                        urlStrings.length);
              for (String url : urlStrings) {
                   URL urlDoc = new URL(url);
                   PdfDocumentSource pdfSource = new UrlPdfDocumentSource(urlDoc);
                   try {
                        System.out.println("URL in create method - "+urlDoc);
                        System.out.println("PDFSource input stream - "+pdfSource.getDocumentInputStream().available());
                   } catch (IOException e) {
                        e.printStackTrace();
                   sourceList.add(pdfSource);
              return sourceList;
         public void mergeAll() throws DataException, ServiceException {
              Properties property = this.m_binder.getLocalData();
              String urlStrings = "";
              List<PdfDocumentSource> sourceList;
              PdfDocumentSource mergedPDF = null;
              urlStrings = property.getProperty("webURL");
              String[] urls = urlStrings.split(";");
              try {
                   sourceList = createPdfDocumentSourceList(urls);
                   PdfMerge merge = new PdfMerge(sourceList, true);
                   try {
                        mergedPDF = merge.createMergedPdf();
                        transferToClient(mergedPDF);
                   } catch (PdfProcessingException e) {
                        e.printStackTrace();
              } catch (MalformedURLException e) {
                   e.printStackTrace();
              System.out.println("hello123");
              System.out.println("URLS - "+urlStrings);
         public void transferToClient(PdfDocumentSource mergedPDF){
              this.m_binder.m_contentType = "application/pdf";
              this.m_binder.m_clientEncoding = "utf-8";
              DataStreamWrapper dataStreamWrapper = this.createNewDownloadStream();
              dataStreamWrapper.m_clientFileName = "MergedPDF.pdf";
              dataStreamWrapper.m_inStream = mergedPDF.getDocumentInputStream();
              //dataStreamWrapper.m_inStreamActive = true;
              dataStreamWrapper.m_dataType = "application/pdf";
              try {
                   this.m_httpImplementor.sendStreamResponse(this.m_binder, dataStreamWrapper);
              } catch (ServiceException e) {
                   e.printStackTrace();
              * StringBuffer sb = this.createHttpResponseHeader();
              sb.append("Content-Type: application/pdf");
              sb.append("Content-Disposition: attachment; filename=fname.ext");
              //m_headerStr
              this.m_headerStr = sb.toString();
    }

  • Using a servlet to read a pdf file that is in remote server

    Hi,
    I read some topics about how to read a pdf file using a servlet...but my issue is that my pdf files are on a remote Sun solaris server (intranet) and my servlet will be in a public network (internet), so my question is, still be possible to use this solution to read my remote file ? how i can access the remote file ??
    any idea from where I can start ??
    best regards,
    carlos.

    You may use a FTP client component to connect with your servlet to the Sun server, retrieve the bytes and serve them to the browser. Instead of reading the stream from a local file, you will be reading from a network socket, but the code -if well written and designed- may be very similar.
    There are many good ftp client components for java, you may also use other protocols like HTTP or SCP (ssh file transfer).
    Regards,
    Martin Cordova
    http://www.martincordova.com
    Dinamica framework for J2EE
    - the easiest way to Java webapps...

  • Byte serving or pdf tuning

    hi all
    i would like to provide byte serving or pdf tuning in iplanet web server 6.0...let me briefly ..explain....
    when user views pdf file from iplanet web server in the place of downloading total pdf file...i want sent page by page to browser...so, how to provide byteserving in iplanet...
    thanks..

    Hi
    thanks for reply
    i am not disabling the http byte range..i want to tune..the byte range..
    web server can not send the complete large document...at a time..so, user should wait..to see the document ...
    in the place of that.....when the user is viewing..the first page...the web server continiosly sends the data...
    so, user does not need to wait...to download the complte large document..i.e. pdf file
    thanks

  • Byte Serving for pdf

    Hello, I make a servlet that sends pdf with byte serving. I have no problems with Windows Clients but with Macintosh clients (Explorer, Netscape 7 works) acrobat waits like expecting some data. Any idea if I must use some special header or do you have examples?

    It could be a content length problem.
    If you are creating the pdf 'on the fly' you could try
    writing it to a ByteArrayPrintWriter, convert it to a
    byte array, setContentLength(byteArray.length()) and
    write the byte array to the output stream.
    Hope this helps.Thanks. I'm not creating the pdf. Its a file on my server that I send. So I put the content-length to the size of the file.

Maybe you are looking for

  • Do i need antivirus in my new iMac?

    I just purchase a new Imac and I am asking if I need to get an antivirus software on my new machine>>

  • Question about index for some condition

    Hello expert, I have following condition in the where subclause, will you please tell if it will use index for transaction_log_fk ? pp.transaction_log_fk < p_transaction_log_fk Many Thanks,

  • Ant and the junit task

    Can anyone tell me how to run JUnit from Ant? I have a directory structure set up with the source files in src, the .class files in build, and the junit task in Ant seems to be unable to find my .class files. I can run the test using the java task (w

  • User Task -- isGroup and taskGroupID

    Hello. What are the isGroup and taskGroupID properties of User Task used for. I might be missing it, but I cannot find them in the documentation. I am asking because we are building functionality in which we are wanting to group tasks together. Thank

  • Can i keep iphoto library on remote disc

    Can I store iphoto library on a remote disc to help with hard disc. room.