cancel
Showing results for 
Search instead for 
Did you mean: 

Using xString to display as PDF in a custom container

former_member184386
Active Participant
0 Kudos

Hello gurus,

I have a SmartForm that was converted to xstring using CONVERT_OTF, I want to use the xstring now to display it as PDF inside a custom container.

I tried using class cl_gui_html_viewer together with cl_gui_custom_container but the form always turns up blank.



Convert xstring to binary table to pass to the LOAD_DATA method
  call function 'SCMS_XSTRING_TO_BINARY'
    exporting
      buffer     = lv_content
    tables
      binary_tab = lt_data.

  call method pdf_html_control->load_data
    exporting
      url          = l_myurl
      size         = l_pdf_size
      type         = 'application'                          "#EC NOTEXT
      subtype      = 'pdf'                                  "#EC NOTEXT
    importing
      assigned_url = l_url
    changing
      data_table   = l_pdf_data
    exceptions
      others       = 1.

  call method g_html_control->show_url( url = lv_url
    in_place = 'X' ).

Need advice on how to accomplish this, or is there another way to do this?

Thanks in advance.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

I've done this using FM CONVERT_OTF_2_PDF not CONVERT_OTF.

Rob

former_member184386
Active Participant
0 Kudos

Thanks for the quick reply Rob, but what I actually wanted to figure out is how to display the PDF inside a custom container. Regards.

Former Member
0 Kudos

Here is some code I have that is used in an ESS application. But I think it wall also work in R3:

DATA: html_container TYPE REF TO cl_gui_custom_container,
      html_viewer TYPE REF TO cl_gui_html_viewer,
      url(80) TYPE c,

module display_pdf output.

CREATE OBJECT html_container
  EXPORTING
    container_name = 'PDF_VIEWER'.
CREATE OBJECT html_viewer
  EXPORTING
    parent = html_container.

url = 'PDF.pdf'.
CALL METHOD html_viewer->load_data
  EXPORTING
    url          = url
    size         = size
    type         = 'text'
    subtype      = 'pdf'
  IMPORTING
    assigned_url = url
  CHANGING
    data_table   = lines_pdf[].

CALL METHOD html_viewer->show_data
  EXPORTING
    url      = url
    in_place = 'X'.

ENDMODULE.                 " DISPLAY_PDF  OUTPUT

Rob

former_member184386
Active Participant
0 Kudos

Did you have to convert the internal table lines_pdf[] from xstring to text or binary?

Former Member
0 Kudos

No conversion from the FM output (like TDLINE).

Rob

former_member184386
Active Participant
0 Kudos

Hi Rob,

What's the table parameter DOCTAB_ARCHIVE in FM CONVERT_OTF_2_PDF do?

Former Member
0 Kudos

It's a table that's (I think) returned by the FM. I pass it empty and never look at it.

Rob

former_member184386
Active Participant
0 Kudos

Hi Rob,

I think I'm almost there, just maybe a small problem - I see a pop-up window that says "File does not begin with '%PDF-'.

Did I miss something here?

Thanks again.

Former Member
0 Kudos

I think it's telling you that the PDF file is corrupt. In fact, it may be empty. Have you looked at the internal table to ensure it is populated?

Rob

former_member184386
Active Participant
0 Kudos

Is this because we converted our system to Unicode? If yes, is there another step to take perhaps converting the text to xtring or binary?

former_member184386
Active Participant
0 Kudos

The OTF table is populated, but after running the FM CONVERT_OTF_2_PDF, the output table (PDF) contains a bunch of ascii characters.