Assign paper source in script

nsinsi
edited 9:24PM in FastReport 4.0
Is it possible to assign the paper tray source in the OnBeforePrint event in the report script ?
I know it is possible to assign paper source in the page setup option but I have 3 paper bins and i have to print copies to specific bins

Comments

  • edited April 2013
    nsi wrote: »
    Is it possible to assign the paper tray source in the OnBeforePrint event in the report script ?
    I know it is possible to assign paper source in the page setup option but I have 3 paper bins and i have to print copies to specific bins

    Hi,

    I try to solve the same problem but with a different approach. I set the printer params (including tray) before calling the prepare method but fast report ignores them.
    The following snippet works perfectly for freereport and other report engines.
    procedure LoadCurrentPrinterSettings(AStream: TStream);
    var
      Device, Driver, Port: array[0..80] of char;
      DevMode: THandle;
      pDevmode: PDeviceMode;
    begin
      Printer.GetPrinter(Device, Driver, Port, DevMode);
      if Devmode <> 0 then
      begin
        {lock it to get pointer to DEVMODE record}
        pDevMode := GlobalLock(Devmode);
        if pDevmode <> nil then
          try
            // read the printer settings from the stream
            AStream.Read(pDevmode^, sizeof(TDevicemode));
          finally
            {unlock devmode handle.}
            GlobalUnlock(Devmode);
          end;
      end;
    end;
    

    After the printer has been setup is use the following code to run the report
    Report.PrintOptions.Printer := ReportPrinter;
      Report.PrepareReport;
    

    Can anyone from the fast report team tell us how to change the printer tray?

    Thanks
  • edited 9:24PM
    I need support on this as well. Hoping for a fast answer >
  • edited 9:24PM
    ASG2013 wrote: »
    I need support on this as well. Hoping for a fast answer >

    HELLOW....

    TEST THIS SOLUTION .
    ME MY WORKS

    REGARDS..
    for n := 0 to fr.PagesCount - 1 do
      begin
        if (uppercase(fr.Pages[n].ClassName) = 'TFRXREPORTPAGE') then
        begin
          TfrxReportPage(fr.Pages[n]).duplex := fr.pRintoptions.duplex;
          TfrxReportPage(fr.Pages[n]).Bin := FConfig_impresora.bandejafr;
          TfrxReportPage(fr.Pages[n]).BinOtherPages := TfrxReportPage(fr.Pages[n]).Bin;
        end;
      end;
    
    function TFConfig_Impresora.Bandejafr: Integer;
    begin
      // result := cbbandejas.itemindex;
    
      result := DMBIN_AUTO;
      case CBBandejas.ItemIndex of
        0:
          result := DMBIN_AUTO;
        1:
          result := DMBIN_UPPER;
        2:
          result := DMBIN_MIDDLE;
        3:
          result := DMBIN_LOWER;
        4:
          result := DMBIN_TRACTOR;
        5:
          result := DMBIN_MANUAL;
        6:
          result := DMBIN_ENVELOPE;
        7:
          result := DMBIN_ENVMANUAL;
        8:
          result := DMBIN_SMALLFMT;
        9:
          result := DMBIN_LARGEFMT;
        10:
          result := DMBIN_LARGECAPACITY;
        11:
          result := DMBIN_CASSETTE;
        12:
          result := DMBIN_FIRST;
        13:
          result := DMBIN_LAST;
      end;
    
  • edited 9:24PM
    But where to use it?
    OnBeforPrint
    Before PrepareReport
    .
    .
    .
    etc

Leave a Comment