超声打印

procedure Trepform.frxptBeforePrint(Sender: TfrxReportComponent);
var filepath: string;
  
  rptformats: string;
 
 
  chname, fname: string;
  docharset, dofontchange: Boolean;
  charsetindex, I: Integer;
  picconter: Integer;
begin
  ExportFileName := DateTimeToStr(dm.Mqry.fieldbyname('baogaoriqi').AsDateTime) + dm.mqryname.AsString;
  picconter := 0; {默认的打印图片为0}
 
 
//   sHostpitalLogo,
//   sHostpitalName,
 if frxpt.FindObject('caInfo') <> nil then
    (frxpt.FindObject('caInfo') as TfrxMemoView).Memo.Text := s_CaInfo;
  if frxpt.FindObject('hostname') <> nil then
    (frxpt.FindObject('hostname') as TfrxMemoView).Memo.Text := sHostpitalName;
   if frxpt.FindObject('hostname1') <> nil then
    (frxpt.FindObject('hostname1') as TfrxMemoView).Memo.Text := sHostpitalName;
  if frxpt.FindObject('logo') <> nil then
  begin
    if FileExists(sHostpitalLogo) then
      (frxpt.FindObject('logo') as TfrxPictureView).Picture.LoadFromFile(sHostpitalLogo);
  end;
   if frxpt.FindObject('logo1') <> nil then
  begin
    if FileExists(sHostpitalLogo) then
      (frxpt.FindObject('logo1') as TfrxPictureView).Picture.LoadFromFile(sHostpitalLogo);
  end;
  if ((frxpt.FindObject('reportTitle') as TfrxMemoView) <> nil) then
    (frxpt.FindObject('reportTitle') as TfrxMemoView).Text := mainunit.P_reportTitle;
      {这两行的决定超声所见和超声提示是否支持多行显示}
 
 
  chname := mySysParms.getElementTextAttribute('/config/Print', 'charset', 'font_DEFAULT_CHARSET');
  fname :=  mySysParms.getElementTextAttribute('/config/Print', 'font_fontname', '宋体');
  dofontchange :=mySysParms.getElementBooleanAttribute('/config/Print','font_fontChange',True);
  docharset:= mySysParms.getElementBooleanAttribute('/config/Print','font_used', True);
 
  IdentToCharset(chname, charsetindex);
  for i := 0 to frxpt.ComponentCount - 1 do
  begin
    if TComponent(frxpt.Components[i]) is TfrxRichView then
      (TComponent(frxpt.Components[i]) as TfrxRichView).Wysiwyg := mainunit.Print_Wysiwyg;
    if TComponent(frxpt.Components[i]) is TfrxMemoView then
    begin
      (TComponent(frxpt.Components[i]) as TfrxMemoView).Wysiwyg := mainunit.Print_Wysiwyg;
      if docharset then
      begin
        (TComponent(frxpt.Components[i]) as TfrxMemoView).font.Charset := charsetindex;
        if (TComponent(frxpt.Components[i]) as TfrxMemoView).Name <> 'hostname' then
          (TComponent(frxpt.Components[i]) as TfrxMemoView).font.name := fname;
      end;
    end;
  end;
 
 
 
  filepath :=SPath.LocalPath+ dm.mqryimagepath.AsString;
  filepath:=StringReplace(filepath,'\\','\',[rfReplaceAll]) ;
  Exportpath:=filepath;
  if FileExists(filepath + '\rpt1.jpg') then
    picconter := picconter + 1;
  if FileExists(filepath + '\rpt2.jpg') then
    picconter := picconter + 1;
  if FileExists(filepath + '\rpt3.jpg') then
    picconter := picconter + 1;
  if FileExists(filepath + '\rpt4.jpg') then
    picconter := picconter + 1;
  if FileExists(filepath + '\rpt5.jpg') then
    picconter := picconter + 1;
  if FileExists(filepath + '\rpt6.jpg') then
    picconter := picconter + 1;
 
  rptformats := dm.mqryrep_format.AsString;
  rptformats := StringReplace(rptformats, 'D:\stusdata\reportformat\', '', [rfReplaceAll]);
  if frxpt.FindObject('ReportTitle1') <> nil then
    (frxpt.FindObject('ReportTitle1') as TfrxReportTitle).Tag := picconter;
  if FileExists(filepath + '\rpt1.jpg') then
  begin
    if frxpt.FindObject('Picture1') <> nil then
      (frxpt.FindObject('Picture1') as TfrxPictureView).Picture.LoadFromFile(filepath + '\rpt1.jpg');
  end;
  if FileExists(filepath + '\rpt2.jpg') then
  begin
    if frxpt.FindObject('Picture2') <> nil then
      (frxpt.FindObject('Picture2') as TfrxPictureView).Picture.LoadFromFile(filepath + '\rpt2.jpg');
  end;
  if FileExists(filepath + '\rpt3.jpg') then
  begin
    if frxpt.FindObject('Picture3') <> nil then
      (frxpt.FindObject('Picture3') as TfrxPictureView).Picture.LoadFromFile(filepath + '\rpt3.jpg');
  end;
  if FileExists(filepath + '\rpt4.jpg') then
  begin
    if frxpt.FindObject('Picture4') <> nil then
      (frxpt.FindObject('Picture4') as TfrxPictureView).Picture.LoadFromFile(filepath + '\rpt4.jpg');
  end;
  if FileExists(filepath + '\rpt5.jpg') then
  begin
    if frxpt.FindObject('Picture5') <> nil then
      (frxpt.FindObject('Picture5') as TfrxPictureView).Picture.LoadFromFile(filepath + '\rpt5.jpg');
  end;
  if FileExists(filepath + '\rpt6.jpg') then
  begin
    if frxpt.FindObject('Picture6') <> nil then
      (frxpt.FindObject('Picture6') as TfrxPictureView).Picture.LoadFromFile(filepath + '\rpt6.jpg');
  end;
 if  frxpt.FindObject('dbjinchasuojian')<> nil then
    (frxpt.FindObject('dbjinchasuojian') as TfrxMemoView).Font.Size:=i_ReportSJTS_FontSize;
 if  frxpt.FindObject('dbjianchajielun')<> nil then
    (frxpt.FindObject('dbjianchajielun') as TfrxMemoView).Font.Size:=i_ReportSJTS_FontSize;
  if  frxpt.FindObject('Memo44')<> nil then
    (frxpt.FindObject('Memo44') as TfrxMemoView).Font.Size:=i_ReportSJTS_FontSize;
  if FileExists(filepath + '\CeLiang.jpg') then
  begin
    if frxpt.FindObject('Picturecl') <> nil then
      (frxpt.FindObject('Picturecl') as TfrxPictureView).Picture.LoadFromFile(filepath + '\CeLiang.jpg');
  end;
//  if frxpt.FindObject('PageFooter1')<> nil then
//     begin
//        if (frxpt.FindObject('Page1') as TfrxReportPage).PageCount>1 then
//          begin
//            (frxpt.FindObject('PageFooter1') as TfrxPageFooter).PrintOnFirstPage:=False;
//            (frxpt.FindObject('PageFooter1') as TfrxPageFooter).PrintOnLastPage:=true;
//          end
//         else
//           begin
//             (frxpt.FindObject('PageFooter1') as TfrxPageFooter).PrintOnFirstPage:=true;
//            (frxpt.FindObject('PageFooter1') as TfrxPageFooter).PrintOnLastPage:=true;
//           end;
//
//     end;
//frxpt.Engine.
end;

 

Posted in 超声工作站文档.