各位大虾:
1.我在做一个批量打印信封的软件,这信封里的内容比如邮编收件人地址名称啊等等要求可以由用户自己定义打印的位置打印的字体,信封的大小也可以设置,说穿了就是在软件里提供一个代表信封的界面,然后由用户在上面放入了想打印的对象,并且可以随意的调整这些对象有谁做过此类软件,提供点思路看,如何达到此目的就象超级打印信件这个软件一样的功能

解决方案 »

  1.   

    恐怕简单的不行,
    只好模拟一个可以拖动的信封界面,用户可以自由拖动一些显示的模块,并添加图片等东西,
    创建一个QuickReport报表,用户按了打印以后,动态将显示模块上的对象的
    位置大小等属性传给QuickReport报表上的各种动态组件,然后显示打印界面,开始打印。
      

  2.   

    写一个类!
    给你一段打印相关代码!procedure printerprint();
    var i,j,cwidth:integer;
    begin
       PointX:=GetDeviceCaps(printer.Handle,LOGPIXELSX)/25.4;//每毫米打印机的像素数
       PointY:=GetDeviceCaps(printer.Handle,LOGPIXELSy)/25.4;
       cwidth:=0;
       coltitlewidth:=0;
       Recordcount:=0;
       pleft:=strtofloat(zhizhang[0])*PointX;
       pright:=strtofloat(zhizhang[1])*PointX;
       ptop:=strtofloat(zhizhang[2])*PointY;
       pbottom:=strtofloat(zhizhang[3])*PointY;
       pwidth:=printer.PageWidth-pleft-pright;
       pheight:=printer.PageHeight-ptop-pbottom;
       //计算网格每列长度占总长的比例并得到在纸张上相映的位置   SetLength(colsX,len);
       SetLength(colswidth,len);
       for i:=0 to len-1 do cwidth:=cwidth+strtoint(s[i]);
       for i:=0 to len-1 do colswidth[i]:=(strtoint(s[i])/cwidth)*pwidth;
       colsx[0]:=pleft;
       for i:=1 to len-1 do colsx[i]:=colsx[i-1]+colswidth[i-1];
       printer.BeginDoc;
       x:=pleft;
       y:=ptop;
       detailfootheight:=0;
       with printer.Canvas do
         begin
          if mingxi[0]='Vertical' then
            begin
              Font.Name:= liebaioti[2];
              Font.Color:=strtoint(liebaioti[3]);
              Font.Size:=strtoint(liebaioti[4]);
              Font.Style:= strtoFontStyle(liebaioti[5]);
              for i:=0 to length(liebaiotistr)-1 do
              if coltitlewidth<TextWidth(liebaiotistr[i]) then coltitlewidth:=TextWidth(liebaiotistr[i]);
            end;
          if strtobool(mingxiwei[0]) then
            begin
              Font.Name:= mingxiwei[3];
              Font.Color:=strtoint(mingxiwei[4]);
              Font.Size:=strtoint(mingxiwei[5]);
              Font.Style:= strtoFontStyle(mingxiwei[6]);
              detailfootheight:= TextHeight('无')+10;
            end;
          if strtobool(yemei[0]) then
             begin
               printpageheader;
               y:=y+20;
             end;
          if strtobool(biaoti[0]) then printtitle;
          y:=y+strtoint(mingxi[3])*PointY;
          if strtobool(mingxitou[0]) then printDetailhead;
          Pen.Color:=strtoint(biankuang[0]);
          Pen.Style:=strtopenStyle(biankuang[1]);
          Pen.Width:=strtoint(biankuang[2]);
          Polyline([point(x,y),point(pwidth+pleft,y)]);
          if strtobool(liebaioti[0]) and (strtoArrange(mingxi[0])<>Vertical) and  not strtobool(liebaioti[8]) then printcolstitle;
          Pen.Color:=strtoint(biankuang[0]);
          Pen.Style:=strtopenStyle(biankuang[1]);
          Pen.Width:=strtoint(biankuang[2]);
          Polyline([point(x,y),point(pwidth+pleft,y)]);
          Pen.Color:=strtoint(hengxian[0]);
          Pen.Style:=strtopenStyle(hengxian[1]);
          Pen.Width:=strtoint(hengxian[2]);
          Polyline([point(x,y),point(pwidth+pleft,y)]);
          hang:=0;
          while memo[hang]<>'???????????????????????????????????????????????' do  hang:=hang+1;
          hang:=hang+1;
          for i:=hang to memo.Count-2 do
            begin
              len:=0;   //读入各个字段内容
              SetLength(mingxistr,len);
              for j:=0 to length(widestring(memo[hang])) do
              if widestring(memo[hang])[j]='┆' then
                begin
                 len:=len+1;
                 SetLength(mingxistr,len);
                end else if len>0 then mingxistr[len-1]:=mingxistr[len-1]+widestring(memo[hang])[j];
              if y+detailrowheight+detailfootheight>pheight+ptop then
                begin
                  Pen.Color:=strtoint(biankuang[0]);
                  Pen.Style:=strtopenStyle(biankuang[1]);
                  Pen.Width:=strtoint(biankuang[2]);
                  Polyline([point(x,y),point(pwidth+pleft,y)]);
                  Pen.Color:=strtoint(hengxian[0]);
                  Pen.Style:=strtopenStyle(hengxian[1]);
                  Pen.Width:=strtoint(hengxian[2]);
                  Polyline([point(x,y),point(pwidth+pleft,y)]);
                  if strtobool(yejiao[0]) then printpagefooter;
                  //*******换页*********
                  printer.NewPage;
                  x:=pleft;
                  y:=ptop;
                  if strtobool(yemei[0]) then
                     begin
                       printpageheader;
                       y:=y+20;
                     end;
                  if strtobool(biaoti[8]) and strtobool(biaoti[0]) then printtitle ;//每页打印标题
                  if strtobool(liebaioti[0]) and (strtoArrange(mingxi[0])<>Vertical) and strtobool(liebaioti[7])  and not strtobool(liebaioti[8]) then printcolstitle   //每页打印列标题
                     else begin
                       Pen.Color:=strtoint(biankuang[0]);
                       Pen.Style:=strtopenStyle(biankuang[1]);
                       Pen.Width:=strtoint(biankuang[2]);
                       Polyline([point(x,y),point(pwidth+pleft,y)]);
                     end;
                end;
                 if strtobool(liebaioti[0]) and (strtoArrange(mingxi[0])<>Vertical)  and strtobool(liebaioti[8]) then previewcolstitle; //每个明晰打印列标题
              printDetail;
              Recordcount:=Recordcount+1;
              Pen.Color:=strtoint(hengxian[0]);
              Pen.Style:=strtopenStyle(hengxian[1]);
              Pen.Width:=strtoint(hengxian[2]);
              Polyline([point(x,y),point(pwidth+pleft,y)]);
              hang:=hang+1;
          end;
        Pen.Color:=strtoint(biankuang[0]);
        Pen.Style:=strtopenStyle(biankuang[1]);
        Pen.Width:=strtoint(biankuang[2]);
        Polyline([point(x,y),point(pwidth+pleft,y)]);
        if strtobool(mingxiwei[0]) then  printDetailfoot;
        if strtobool(yejiao[0]) then  printpagefooter;
        printer.EndDoc;
      end;   
    end;