将图元文件传递给fastreport masterdata图像控件

我需要将图形(元文件)传递给每个打印记录的masterdata波段上的image1控件。 不幸的是,我无法在onbeforeprint事件中使用Loadfromfile方法,因为图元文件是另一个文件的一部分,因此我必须先提取它,然后将其传递给masterdata的控件。 我尝试使用用户函数声明选项,但是它们使用Variant类型,因此,我无法分配图元文件。 我是FR的新手。还有另一种方法可以完成这项工作吗? 谢谢你。

ACACmi 回答:将图元文件传递给fastreport masterdata图像控件

定义一个用户函数,该函数接受图片对象的名称以及报告中需要的其他任何参数。

if( isset( $_FILES['image'] ) ){
    /* an image was uploaded */
    $obj=(object)$_FILES['image'];
    $tmp=$obj->tmp_name;
    $name=$obj->name;

    if( is_uploaded_file( $tmp ) ){
        $filename = time() . uniqid( rand() ) . $name;
        move_uploaded_file( $tmp,"vendorProfile/{$filename}" );
        $saveArr['image'] = $filename;  
    }

} else {
    /* no image uploaded - do something else */

}

定义功能:

frxReport1.AddFunction(
  'procedure MyTest(const APicViewName : string)','CustomFunctions','This is the description of the MyTest function'
);

procedure TForm1.MyTest(const APicViewName : string); var Pic : TfrxPictureView; Stream : TStream; begin Pic := TfrxPictureView(frxReport1.FindObject(APicViewName)); if(not Assigned(Pic)) or (not Pic.ClassType.InheritsFrom(TfrxPictureView)) then Exit; Stream := <TMemoryStream/TFileStream/...>.Create; try //load and process your image as you need and load it into the Stream //... Stream.Position := 0; Pic.LoadPictureFromStream(Stream); finally Stream.Free; end; end; 事件处理程序中:

frxReport1.OnUserFunction
本文链接:https://www.f2er.com/3040583.html

大家都在问