Skip to Content
0
Jan 09, 2014 at 10:05 AM

Problem Creating PDF with Cyrillic Characters

308 Views

Good morning.

I'm trying to create a PDF from a internal table (so far not a problem 😊 ). The problem comes when the characters are in Cyrillic (in this case Bulgarian).

After creating the PDF, the characters that appear are nothing like what they should be. Can someone help me please ?

After creating the PDF, this is sent by email.

Here is the program I have:

REPORT  zzt_rjm_3.

 DATA:
       go_send_request         TYPE REF TO cl_bcs,
       gt_text                              TYPE bcsy_text,
       gt_bin_content               TYPE solix_tab,
       gs_bin_content              LIKE LINE OF gt_bin_content,
       go_document                 TYPE REF TO cl_document_bcs,
       go_sender                      TYPE REF TO cl_sapuser_bcs,
       go_recipient                   TYPE REF TO if_recipient_bcs,
       go_bcs_exception        TYPE REF TO cx_bcs,
       lv_sent_to_all                TYPE os_boolean,
       gt_txt_content                TYPE soli_tab,
       gs_txt_content               LIKE LINE OF gt_txt_content,
         bin_filesize                   TYPE i,
         obj_len                          TYPE so_obj_len.


 *     --------------- Begin ----------------
 TRY.
 *-- Create persistent send request
     go_send_request = cl_bcs=>create_persistent( ).

 *-- Create Document type text
     APPEND 'This is the email Body' TO gt_text.
     go_document = cl_document_bcs=>create_document( i_type    = 'RAW'
                                                                                                          i_text    = gt_text
                                                                                                          i_length  = '38'
                                                                                                          i_subject = 'RJM TEST' ).
 *-- Create Attachment type Raw
     PERFORM create_pdf.
  
     MOVE bin_filesize TO   obj_len   .

     CALL METHOD go_document->add_attachment
       EXPORTING
         i_attachment_type     = 'PDF'
         i_attachment_subject  = 'Attach Subject'
        i_attachment_size     = obj_len
         i_attachment_language = 'W'
         i_att_content_hex     = gt_bin_content.


 *-- Add Document to send request
     CALL METHOD go_send_request->set_document( go_document ).

 *-- Set Sender
     go_sender = cl_sapuser_bcs=>create( sy-uname ).
     CALL METHOD go_send_request->set_sender
       EXPORTING
         i_sender = go_sender.

 *-- Add Recipient
     go_recipient = cl_cam_address_bcs=>create_internet_address( 'ricardo.monteiro-ex@email.com' ).
     CALL METHOD go_send_request->add_recipient
       EXPORTING
         i_recipient = go_recipient
         i_express   = 'X'.

 *-- Send Document
     CALL METHOD go_send_request->send(
       EXPORTING
         i_with_error_screen = 'X'
       RECEIVING
         result              = lv_sent_to_all ).

     IF lv_sent_to_all = 'X'.
       WRITE 'Success'.
     ENDIF.

     COMMIT WORK.

   CATCH cx_bcs INTO go_bcs_exception.
     WRITE: 'Error Occurred:'(001).
     WRITE: 'Error Type:'(002), go_bcs_exception->error_type.
     EXIT.

 ENDTRY.

*&---------------------------------------------------------------------* *& Form CREATE_PDF *&---------------------------------------------------------------------* FORM create_pdf . DATA: t_otf TYPE STANDARD TABLE OF itcoo, t_otf_conversion TYPE TABLE OF tline, binarchivobject TYPE /ixos/bf_tt_docs_bin, options TYPE itcpo, pdf_xstring TYPE xstring, header TYPE thead, result TYPE itcpp, * bin_filesize TYPE i, it_text_table TYPE tline_t, is_text_table LIKE LINE OF it_text_table, l_devtype TYPE rspoptype. is_text_table-tdline = 'Колело верижно :DWKFSD-SPR106 00 00 01'. "This is the text in Cyrillic to be sent in the PDF APPEND is_text_table TO it_text_table. * header = i_header. header-tdform = 'ECSC_PRINT_SAPSC'. header-tdstyle = 'S_DOCUS1'. options-tdcopies = 1. options-tdcover = space. options-tdgetotf = 'X'. options-tddest = 'ZWINCY'. options-tdimmed = 'X'. CALL FUNCTION 'PRINT_TEXT' EXPORTING device = 'PRINTER' dialog = ' ' header = header options = options IMPORTING result = result TABLES lines = it_text_table[] otfdata = t_otf. CALL FUNCTION 'CONVERT_OTF' EXPORTING format = 'PDF' IMPORTING bin_filesize = bin_filesize bin_file = pdf_xstring TABLES otf = t_otf lines = t_otf_conversion. CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' EXPORTING buffer = pdf_xstring TABLES binary_tab = binarchivobject. gt_bin_content = cl_document_bcs=>xstring_to_solix( ip_xstring = pdf_xstring ). ENDFORM. " CREATE_PDF