cancel
Showing results for 
Search instead for 
Did you mean: 

Display PDF itab in HTML viewer w/o file

former_member185943
Participant
0 Kudos
2,069

Hello!

If I download PDF internal table (for example, converted from spool) to file, I can easily display it in a CL_GUI_HTML_VIEWER control. Is there a way to pass PDF data directly to HTML viewer, without using intermediate file?

Thanks!

Kind regards,

Igor Barbaric

Accepted Solutions (1)

Accepted Solutions (1)

athavanraja
Active Contributor
0 Kudos

You need to use the following methods of htmlviewer class


call method l_html_control->load_data
    exporting
      type                 = 'text'
      subtype              = 'html'
    importing
      assigned_url         = l_url
    changing
      data_table           = l_new_html_page
    exceptions
      others               = 4.
  if sy-subrc <> 0.
    message id sy-msgid type sy-msgty number sy-msgno
               with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  endif.

  call method l_html_control->show_data
    exporting
      url                  = l_url
    exceptions
      others                 = 3.
  if sy-subrc <> 0.
    message id sy-msgid type sy-msgty number sy-msgno
               with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  endif.

l_new_html_page will hold the PDF data and also

type = 'text'

subtype = 'html'

has to maintained for PDF.

I havent tried this but it should work.

Regards

Raja

former_member185943
Participant
0 Kudos

Thanks, Raja!

It works, but not with subtype = 'html'. It needs to be subtype = 'pdf'.

Kind regards,

Igor

athavanraja
Active Contributor
0 Kudos

Hi Igor,

sorry, i mean to say PDF only there, but over looked it.

Regards

Raja

Former Member
0 Kudos

Hi Raja/Igor:

I am trying to do the same, but getting a message "File does not begin with '%PDF-'"

Can you please tell me what I might be doing wrong? If you can share how you achieved this, that will be very helpful.

Thanks,

JB

Former Member
0 Kudos

You need to convert pdf table (tline) to byte mode.

types: pdfx(134) type x.

data: lt_pdf type standard table of tline,

lt_pdfx(134) type standard table of pdfx,

lv_cline(134) type c.

field-symbols: <xline> type x.

loop at lt_pdf into lv_cline.

assign lv_cline to <xline> casting.

append <xline> to lt_pdfx.

endloop.

call method html_control->load_data

EXPORTING

url = 'file.pdf'

size = bytecount

type = 'application'

subtype = 'pdf'

IMPORTING

assigned_url = l_url

CHANGING

data_table = l_pdfx[]

EXCEPTIONS

others = 1.

Answers (0)