on 03-26-2009 10:34 PM
Hi,
I need to upload a REGULAR PDF and present it on the screen.
How can I upload a PDF from a drive and present it on the WD?
I am not talking about an interactive PDF.
Thanks,
Itay
You can use the fileUpload UI element to bring the PDF from the client desktop to the application server. It will be in a binary string at this point.
How you show it depends upon if you want to open it in its own window or inplace within Web Dynpro. If you want to open it within its own window, consider simply using the cl_wd_runtime_services=>attach_file_to_response method. Pass in the binary string you uploaded and filename and you will be all set.
If on the other hand you want to show it inplace, then use the interactiveForm UI element. Don't supply a dataSource or templateSource. Instead bind the pdfSource to the binary string you uploaded in the first step.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Thanks for the quick reply.
I put a node named PDFOBJ.
I added the file upload and I want to present it in a new window.
I put the code below and it just opens the window and closes it but it is not showing the PDF.
Do you have any idea what is wrong?
Thanks,
Itay
DATA lo_el_context TYPE REF TO if_wd_context_element.
DATA ls_context TYPE wd_this->element_context.
DATA lv_pdfobj LIKE ls_context-pdfobj.
* get element via lead selection
lo_el_context = wd_context->get_element( ).
* get single attribute
lo_el_context->get_attribute(
EXPORTING
name = `PDFOBJ`
IMPORTING
value = lv_pdfobj ).
CALL METHOD cl_wd_runtime_services=>attach_file_to_response
EXPORTING
i_filename = 'FILE'
i_content = lv_pdfobj
i_mime_type = 'application/pdf'
i_in_new_window = ABAP_TRUE
* i_inplace = ABAP_FALSE
.
hi Itay,
In my case its working fine.
I have a Context Node - FileContent ( Cardinality - 1..1 and Selection 0..1)
Under this Node , I have Context Attribute FC type XString.
I am using FileUpload UI Element which is binded to FC. File is Uploaded and data in now in FC.
You just Read this Context using Control Wizard ( Control + F7) and use attach_file_to_response later to open PDF in new Window.
It will work fine.
I have written below mentioned code:
DATA lo_nd_cn_filecontent TYPE REF TO if_wd_context_node.
DATA lo_el_cn_filecontent TYPE REF TO if_wd_context_element.
DATA ls_cn_filecontent TYPE wd_this->element_cn_filecontent.
DATA lv_fc TYPE wd_this->element_cn_filecontent-fc.
navigate from <CONTEXT> to <CN_FILECONTENT> via lead selection
lo_nd_cn_filecontent = wd_context->get_child_node( name = wd_this->wdctx_cn_filecontent ).
@TODO handle non existant child
IF lo_nd_cn_filecontent IS INITIAL.
ENDIF.
get element via lead selection
lo_el_cn_filecontent = lo_nd_cn_filecontent->get_element( ).
@TODO handle not set lead selection
IF lo_el_cn_filecontent IS INITIAL.
ENDIF.
get single attribute
lo_el_cn_filecontent->get_attribute(
EXPORTING
name = `FC`
IMPORTING
value = lv_fc ).
CALL METHOD cl_wd_runtime_services=>attach_file_to_response
EXPORTING
i_filename = 'FILE'
i_content = lv_fc
i_mime_type = 'application\pdf'
i_in_new_window = ABAP_TRUE
i_inplace = ABAP_FALSE
.
Try putting Break Point.
You could also use another approach.
Upload the File and later Navigate to other view to show PDF.
Have a Interactive UI Element there and bind its PDFSource Property to Context Attribute FC (Xstring).
This way also it will work without any code.
I hope it helps.
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.