01-09-2014 10:05 AM
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
01-10-2014 3:12 PM
Hello Ricardo,
OTF-PDF has limitations when it comes to Unicode. Often there is a need to install TrueType fonts (using RSTXPDF2 or RSTXPDF2UC) for the PDF converter, you can search for notes mentioning these reports.There are many SAP notes on this.
You seem to be using a custom device type ZWINCY which supposedly supports Cyrillic.
Maybe check SAP note 322998.
If you have a Unicode system, it is advisable to use a Unicode device type like SWINCF or PDFUC (because it will support more languages), and then the following note would apply: 999712.
Now it also depends whether you use the "proper" SAP fonts for Cyrillic. Typically, SAP device types use COURCYR,HELVCYR and TIMECYR for Cyrillic text.
Best regards,
Alexander
01-10-2014 3:12 PM
Hello Ricardo,
OTF-PDF has limitations when it comes to Unicode. Often there is a need to install TrueType fonts (using RSTXPDF2 or RSTXPDF2UC) for the PDF converter, you can search for notes mentioning these reports.There are many SAP notes on this.
You seem to be using a custom device type ZWINCY which supposedly supports Cyrillic.
Maybe check SAP note 322998.
If you have a Unicode system, it is advisable to use a Unicode device type like SWINCF or PDFUC (because it will support more languages), and then the following note would apply: 999712.
Now it also depends whether you use the "proper" SAP fonts for Cyrillic. Typically, SAP device types use COURCYR,HELVCYR and TIMECYR for Cyrillic text.
Best regards,
Alexander
01-13-2014 10:29 AM
Well right now, in development system i can send the PDF with the cyrillic characters ok...
The problem now is in Quality System where the email goes with the PDF, but inside the PDF there is nothing...it is empty with only 4kb instead of the 70kb of information.
I thought it was the OFT information to do with the fonts, but they're the same in both systems. And I checked the fonts in Quality System, and they seem to be there.
Anyone has any ideas ?