好像ReportBuilder 中的控件有屬性可設置。

解决方案 »

  1.   

    打印到屏幕÷文件÷打印机同样的原理,只是输出对象不同!
    部分代码(自己再整理一下):uses Printers, PrnPage;
    var FileNameToPrintTo : Pointer;{$IFNDEF WIN32}
     const MAX_PATH = 144;
    {$ENDIF}
    procedure TForm1.Button1Click(Sender: TObject);
    var
      lpPrnFile : pChar;
    begin
      GetMem(lpPrnFile, MAX_PATH +1);
      
      try
        StrPCopy(lpPrnFile, 'C:\Download\TestIt.Prn');
        FileNameToPrintTo := @lpPrnFile^;
        
        with Printer do begin 
          BeginDoc;
          Canvas.TextOut(10, 10, 'Test');
          EndDoc;
        end;
       
        FileNameToPrintTo := nil;  finally
        FreeMem(lpPrnFile, MAX_PATH +1);
      end;
    end;
      

  2.   

    露了lpszOutput := FileNameToPrintTo;
      

  3.   

    涉及更改VCL源文件Printers.pas,请三思,
    或者把该源文件拷出来,自己改一下!
      

  4.   

    请看英文提示:
    To do this you simply need to change the initialization of the
    DocInfo structure in TPrinter from:  lpszOutput := nil; to: lpszOutput := 'C:\SomePath\SomeFileName';You can make a permanent change to TPrinter, but for the ultimate in
    flexibility, you can create an interface unit to make the filename
    easy to change from your application.{  Note:  Modifications to the VCL are made at the developers risk and 
    any effects caused by modifications are not the responsibility of 
    Borland International. }
    The safest way to make changes to the VCL is to create a new directory
    called "patched", and copy the Printers.Pas unit to the new directory,
    then make your changes (with comments) to the copied file. The you
    must add the path to your patched directory to the beginning of your
    library path, then restart Delphi/C++ Builder, and rebuild your
    project after making the following changes. Note that the library path
    setting can be found off the main menu of:Delphi 1 : Options...  Environment... Library
    Delphi 2 : Tools... Options... Library
    Delphi 3 :  Tools... Environment Options... Library
    C++ Builder : Options...  Environment... LibraryInstructions for the patch:1)  Create a new unit in the patched directory called "PrnPage.pas"
    and include the following code in the unit:unit PrnPage;interfacevar FileNameToPrintTo : Pointer;implementationbegin
      FileNameToPrintTo := nil;
    end.2) Now open the Printers.Pas file in your patched directory.
    Search for the line that reads "uses Consts;" (or in Delphi 16 it will
    read "uses WinProcs, Consts;");and add the PrnPage unit to the uses clause:uses Consts, PrnPage;3) Now search for line that reads "lpszOutput := nil;"and change it to read: lpszOutput := FileNameToPrintTo;4) Save your changes, and restart Delphi / C++ Builder.5) To test your changes, try the following code. Note: Be sure to use
    the "Build All" option when compiling your project for the first time.uses Printers, PrnPage;{$IFNDEF WIN32}
     const MAX_PATH = 144;
    {$ENDIF}procedure TForm1.Button1Click(Sender: TObject);
    var
      lpPrnFile : pChar;
    begin
      GetMem(lpPrnFile, MAX_PATH +1);
      
      try
        StrPCopy(lpPrnFile, 'C:\Download\TestIt.Prn');
        FileNameToPrintTo := @lpPrnFile^;
        
        with Printer do begin 
          BeginDoc;
          Canvas.TextOut(10, 10, 'Test');
          EndDoc;
        end;
       
        FileNameToPrintTo := nil;  finally
        FreeMem(lpPrnFile, MAX_PATH +1);
      end;
    end;