cancel
Showing results for 
Search instead for 
Did you mean: 

How print smartform with pictures in PDF document from WEBUI

Former Member
0 Kudos

Hello.

I have extension class "cl_bsp_wd_view_controller" to "Zcl_bsp_wd_view_controller",  where implemented "PrintForm.htm".

Into "PrintForm.htm"(Pic. 1*) I create smartform(Pic. 1*), convert otf = (Pic. 2*) and fill data "if_http_response" (Pic. 3*).

If installed "Acrobat.Reader" or earlier, it's not working - picture isn't displayed

If installed "FoxitReader" - all work. But, I need, than work tith "Acrobat Reader".

How to solve this problem?

thanks.

P.S. CRM 7.0

and

Sorry for my English

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member212653
Active Contributor
0 Kudos

Can you please elaborate the problem, when you are using Acrobat Reader the PDF file is displayed but picture in the PDF is not displayed. Is that correct?

Former Member
0 Kudos

No, sorry.

If installed Acrobat Reader on my computer,

and try print from WEBUI, document not opening(Pic 4 error Adobe Reader.jpg).

If look in smartforms - all good (Pic. 5 logo smartforms.jpg),

and if Install FoxitReader all good too (Pic. 6 logo FoxitReader.jpg)

Pic 4 error Adobe Reader.jpg

Pic. 5 logo smartforms.jpg

Pic. 6 logo FoxitReader.jpg

darren_bambrick2
Active Participant
0 Kudos

Hi

You need to convert the otf returned from the smartform call to xstring and send this to the page that is rendering the smartform

<pre>

call function 'CONVERT_OTF'

      exporting

        format                      = 'PDF'

*        MAX_LINEWIDTH               = 132

*        ARCHIVE_INDEX               = ' '

*        COPYNUMBER                  = 0

      importing

        bin_filesize                = l_pdf_len

  bin_file                    = l_pdf_xstring       " binary file

      tables

        otf                         = ls_output_data-otfdata

        lines                       = lt_lines

      exceptions

        err_max_linewidth           = 1

        err_format                  = 2

        err_conv_not_possible       = 3

        err_bad_otf                 = 4

        others                      = 5


you also need to set the the content header of the page to render pdf

  _m_response->set_header_field( name  = 'content-type'

value = '

application/pdf

' ).

_m_response->set_header_field( name  = 'content-type'

                             value = 'application/pdf' ).

* some Browsers have caching problems when loading PDF format

_m_response->set_header_field(

                    name  = 'cache-control'

                    value = 'max-age=0' ).

* start PDF viewer either in the Browser or as a separate window

pdf_in_browser = abap_true.

if pdf_in_browser is initial.

   _m_response->set_header_field(

                      name  = 'content-disposition'

                   value = 'attachment; filename=adobe.pdf' ).

endif.

navigation->use_auto_submit_form( ).

* finally display PDF format in Browser

l_pdf_len = xstrlen( l_pdf_xstring ).

_m_response->set_data( data   = l_pdf_xstring

                     length = l_pdf_len ).

navigation->response_complete( ).

</pre>

Former Member
former_member212653
Active Contributor
0 Kudos

This looks more like problem with Adobe Acrobat reader. Have tried any other version of Acrobat Reader or any other machine.

darren_bambrick2
Active Participant
0 Kudos

Sorry, I can't access the images.

have you set your control parameters correctly ?

e.g.

ls_control_parameters-no_dialog = abap_true.
ls_control_parameters-getotf    = abap_true.

Former Member
0 Kudos

This looks more like problem with Adobe Acrobat reader. Have tried any other version of Acrobat Reader or any other machine.

I have tried on some more computer, and used Acrobat Reader from 8 to 10 version - anywhere doesn't work.

Former Member
0 Kudos

Sorry, I can't access the images.

have you set your control parameters correctly ?

e.g.

ls_control_parameters-no_dialog = abap_true.
ls_control_parameters-getotf    = abap_true


Yes, I have this too.

former_member212653
Active Contributor
0 Kudos

Use program RSTXPDFT4 to download the Spool Request as PDF to your desktop. Check if that is opening with acrobat reader.

You can also use the given program to download the Smartform as PDF directly.

http://wiki.sdn.sap.com/wiki/display/Snippets/Convert+Smartform+to+PDF+format

Former Member
0 Kudos

Just simply - save/open PDF document from program works correctly. But from WEB - doesn't...

Ok, thanks. I will check your variant and I answer you later...

darren_bambrick2
Active Participant
0 Kudos

Ok, I can access the images now.  Everything looks good.

can you confirm the filename for the attachment.  you have lv_blank lv_docno.

can you change this to adobe.pdf or something like that and see does this work

Former Member
0 Kudos

I show you my part code.

I can not understand why it not work.

*----------------------------------------------------------------*

DATA:

    l_function_module_name TYPE rs38l_fnam,

    lv_blank               TYPE tdsfname.

    lv_blank = 'ZTEST_PICTURE'.

   

    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

        EXPORTING

            formname           = lv_blank

        IMPORTING

            fm_name            = l_function_module_name

        EXCEPTIONS

            no_form            = 1

            no_function_module = 2

            others             = 3.   

           

*----------------------------------------------------------------*

DATA:

    l_devtype    TYPE rspoptype.

   

    CALL FUNCTION 'SSF_GET_DEVICE_TYPE'

        EXPORTING

            i_language             = sy-langu

        IMPORTING

            e_devtype              = l_devtype

        EXCEPTIONS

            no_language            = 1

            language_not_installed = 2

            no_devtype_found       = 3

            system_error           = 4

            others                 = 5.   

*----------------------------------------------------------------*

DATA:

    ls_control_parameters  TYPE ssfctrlop,

    ls_output_options      TYPE ssfcompop,

    ls_output_data         TYPE ssfcrescl.

    ls_control_parameters-langu     = sy-langu.

    ls_control_parameters-no_dialog = abap_true.

    ls_control_parameters-getotf    = abap_true.

   

    ls_output_options-tdprinter = l_devtype.

   

    CALL FUNCTION l_function_module_name

        EXPORTING

            control_parameters   = ls_control_parameters

            output_options       = ls_output_options

            user_settings        = space

        IMPORTING

            job_output_info      = ls_output_data

        EXCEPTIONS

            formatting_error     = 1

            internal_error       = 2

            send_error           = 3

            user_canceled        = 4

            others               = 5.

*----------------------------------------------------------------*

DATA:

    l_pdf_len       TYPE i,

    l_pdf_xstring      TYPE xstring,

    lt_otfdata        TYPE tsfotf,

    lt_lines        TYPE TABLE OF tline.

    lt_otfdata = ls_output_data-otfdata.

  CALL FUNCTION 'CONVERT_OTF'

       EXPORTING

         format                = 'PDF'

       IMPORTING

         bin_filesize          = l_pdf_len

         bin_file              = l_pdf_xstring " binary file

       TABLES

         otf                   = lt_otfdata

         lines                 = lt_lines

       EXCEPTIONS

         err_max_linewidth     = 1

         err_format            = 2

         err_conv_not_possible = 3

         err_bad_otf           = 4

         others                = 5 .

        

*----------------------------------------------------------------*

    response->set_header_field( name  = 'content-type'

                                value = 'application/pdf' ).

    response->set_header_field( name  = 'cache-control'

                                value = 'max-age=0' ).

    response->set_header_field( name  = 'content-disposition'

                                value = 'attachment; filename=somename.pdf' ).

    l_pdf_len = xstrlen( l_pdf_xstring ).

   

    response->set_data( data   = l_pdf_xstring

                        length = l_pdf_len ).

    _m_navigation->response_complete( ).

*----------------------------------------------------------------*

darren_bambrick2
Active Participant
0 Kudos

Hi

I copied the code into my system CRM 7 and it works.

I have a smartform that displays an image of a graph and the code worked perfectly.  I am using adobe reader 10.1.4, but I have been doing this sort of stuff for years and never had a problem with adobe reader versions.

It seems that Sourav Bhaduri is correct in saying that it is an adobe issue.  Can you re-install adobe ?

former_member212653
Active Contributor
0 Kudos

In the method response->set_data can you pass the actual l_pdf_len returned from CONVERT_OTF FM instead of calculating xstrlen again. Sometimes incorrect filesize gives such error.