在Web Service中怎样将一个Grid中的内容直接输出到打印机上,而不是将整个Html页面输出到打印机。我用的是Delphi6 + Web Snap + IIS,希望高手关注解决一下,万分感谢。

解决方案 »

  1.   

    Printer.Canvas.Assign(dbgrid1.Canvas);
    试试,
    有个问题,你的webservice还有form?
      

  2.   

    我用的是EWF,不知道有对这个熟悉的高手吗
      

  3.   

    with Printer, DbGrid1.Canvas do
          begin
            Bits := FormImage.Handle;
            GetDIBSizes(Bits, InfoSize, ImageSize);
            Info := AllocMem(InfoSize);
            try
              Image := AllocMem(ImageSize);
              try
                GetDIB(Bits, 0, Info^, Image^);
                with Info^.bmiHeader do
                begin
                  DIBWidth := biWidth;
                  DIBHeight := biHeight;
                end;
                case PrintScale of
                  poProportional:
                    begin
                      PrintWidth := MulDiv(DIBWidth, GetDeviceCaps(Handle,
                        LOGPIXELSX), PixelsPerInch);
                      PrintHeight := MulDiv(DIBHeight, GetDeviceCaps(Handle,
                        LOGPIXELSY), PixelsPerInch);
                    end;
                  poPrintToFit:
                    begin
                      PrintWidth := MulDiv(DIBWidth, PageHeight, DIBHeight);
                      if PrintWidth < PageWidth then
                        PrintHeight := PageHeight
                      else
                      begin
                        PrintWidth := PageWidth;
                        PrintHeight := MulDiv(DIBHeight, PageWidth, DIBWidth);
                      end;
                    end;
                else
                  PrintWidth := DIBWidth;
                  PrintHeight := DIBHeight;
                end;
                StretchDIBits(Canvas.Handle, 0, 0, PrintWidth, PrintHeight, 0, 0,
                  DIBWidth, DIBHeight, Image, Info^, DIB_RGB_COLORS, SRCCOPY);
              finally
                FreeMem(Image, ImageSize);
              end;
            finally
              FreeMem(Info, InfoSize);
            end;
          end;
    参考Form.Print方法
      

  4.   

    可是EWF的dbGrid中没有Canvas这个属性,怎么办