Skip to Content
0

how to design pdf with abap from spool

Jun 09, 2017 at 06:25 AM

76

avatar image
Former Member

HI,

i have created a pdf via spool. The content of this spool data it type = TEXT and it contains html tags like <H1> <br> etc.

This tags where not interpreted in my pdf.

so how can i design the pdf or how can i achieve that my html tags where interpreted right from the pdf ?

Any help here

here is my code and a sample picture of the pdf...

SPAN {
font-family: "Courier New";
font-size: 10pt;
color: #000000;
background: #FFFFFF;
}
.L0S31 {
font-style: italic;
color: #808080;
}
.L0S52 {
color: #0000FF;
}
.L0S55 {
color: #800080;

}
.L0S70 {
color: #808080;
}
I_PRT_DATA    Importing  type PRI_PARAMS    Drucker-Parameter
C_PDF_DATA    Changing   type  EHSW_TT_TLINE    Pdf Daten

METHOD create_pdf .
  DATA:  lf_spoolid   TYPE i
        ,lf_bytecount TYPE i
        ,ls_pdf       TYPE tline
        ,xstring      TYPE xstring
        .
  FIELD-SYMBOLS:  <fs_pdf>  TYPE tline
                  ,<fs_xstr> TYPE x.

*== Spoolauftrag wird geschrieben ==
  NEW-PAGE PRINT ON PARAMETERS i_prt_data NO DIALOG NO-TITLE NO-HEADING.
  LOOP AT c_pdf_data ASSIGNING <fs_pdf>.
    <fs_pdf>-tdformat = sy-tabix.
    WRITE:/ <fs_pdf>-tdformat.
    WRITE:/ <fs_pdf>-tdline.
  ENDLOOP.

  lf_spoolid = sy-spono.
  NEW-PAGE PRINT OFF.

*== Spool to PDF Generierung ==
  CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
    EXPORTING
      src_spoolid              = lf_spoolid
      no_dialog                = abap_true
      get_size_from_format     = abap_true
      dst_device               = i_prt_data-pdest
    IMPORTING
      pdf_bytecount            = lf_bytecount
    TABLES
      pdf                      = c_pdf_data
    EXCEPTIONS
      err_no_abap_spooljob     = 1
      err_no_spooljob          = 2
      err_no_permission        = 3
      err_conv_not_possible    = 4
      err_bad_destdevice       = 5
      user_cancelled           = 6
      err_spoolerror           = 7
      err_temseerror           = 8
      err_btcjob_open_failed   = 9
      err_btcjob_submit_failed = 10
      err_btcjob_close_failed  = 11
      OTHERS                   = 12.
  IF sy-subrc <> 0.
    MESSAGE 'Fehler beim Erzeugen der PDF-Datei aus dem Spoolauftrag' TYPE 'E'.
  ENDIF.

*== Convert tline (pdf) to xstring ==
  LOOP AT c_pdf_data INTO ls_pdf.
    ASSIGN ls_pdf TO <fs_xstr> CASTING.
    CONCATENATE xstring <fs_xstr> INTO xstring IN BYTE MODE.
  ENDLOOP.

*== PDF Anzeige im WD ==
  cl_wd_runtime_services=>attach_file_to_response(
  EXPORTING
    i_filename      = 'TEST.pdf'
    i_content       = xstring
    i_mime_type     = 'application/pdf'
*      i_in_new_window = ABAP_FALSE
*      i_inplace       = ABAP_FALSE
    ).
ENDMETHOD.
pdf-with-html.png (13.3 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers