在SMARTFORMS中需要打印的时候如果需要打印图片的话一般需要手动上传图片到服务器上,如果批量上传以后想预览的话系统没有提供标准的批量预览的功能,只能在SE78中一个个预览。下面介绍的也是一个个预览的,考虑在列表中双击的时候展示出来。
在屏幕 9000上创建容器 GL_IMAGE 并处理相应的PAI和PBO事件,在PBO事件中增加一个MODULE,在其中添加如下代码:
DATA: w_lines TYPE i.
TYPES pict_line(256) TYPE c.
DATA :
container TYPE REF TOcl_gui_custom_container,
editor TYPE REF TO cl_gui_textedit,
picture TYPE REF TO cl_gui_picture,
pict_tab TYPE TABLE OF pict_line,
url(255) TYPE c.
DATA: graphic_url(255).
DATA: BEGIN OF graphic_table OCCURS0,
line(255) TYPE x,
END OF graphic_table.
DATA: l_graphic_conv TYPE i.
DATA: l_graphic_offs TYPE i.
DATA: graphic_size TYPE i.
DATA: l_graphic_xstr TYPE xstring.
.
"刷新
CALL METHOD cl_gui_cfw=>flush.
"创建容器
CREATE OBJECT:container EXPORTINGcontainer_name = 'GL_IMAGE',
picture EXPORTING parent =container.
"获取图片
CALL METHODcl_ssf_xsf_utilities=>get_bds_graphic_as_bmp
EXPORTING
p_object ='GRAPHICS'
p_name = 'ZUS_LOGO'
p_id = 'BMAP'
p_btype = 'BCOL'
RECEIVING
p_bmp = l_graphic_xstr
.
"图片大小
graphic_size = XSTRLEN( l_graphic_xstr).
l_graphic_conv = graphic_size.
l_graphic_offs = 0.
"将图片数据放到内表中
WHILE l_graphic_conv > 255.
graphic_table-line =l_graphic_xstr+l_graphic_offs(255).
APPENDgraphic_table.
l_graphic_offs =l_graphic_offs + 255.
l_graphic_conv =l_graphic_conv - 255.
ENDWHILE.
graphic_table-line =l_graphic_xstr+l_graphic_offs(l_graphic_conv).
APPEND graphic_table.
"创建图片的URL
CALL FUNCTION 'DP_CREATE_URL'
EXPORTING
type = 'IMAGE'
subtype = 'X-UNKNOWN'
size = graphic_size
lifetime = 'T'
TABLES
data = graphic_table
CHANGING
url =url.
"根据URL 展示图片
CALL METHODpicture->load_picture_from_url
EXPORTING
url =url.
"显示模式 居中自适应
CALL METHODpicture->set_display_mode
EXPORTING
display_mode = picture->display_mode_fit_center.