Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

creating a binary print file for archive reader

edited November 2003 in General
I am trying to take a previously archived file and create a binary print
file file using a different printer than the current windows default
printer or the printer that was used to create the archive.

This is the pseudo code I am using:

ppa.devicetype := 'PrinterFile';
ppa.archivefilename := 'c:\archived file';
ppa.textfilename := binary filetocreate;
ppa.showprintdialog := false;
ppa.printer.printername := "print driver to use";
ppa.print;
ppa.showprintdialog := true;


it creates the binary file but not with the selected printer

Help

Dennis McGuire
PCFS2000

Comments

  • edited November 2003
    Hi Dennis,

    When changing the printer setup in the archive reader, you need to use the
    TppArchiveReader.OnInitializePrinterSetup event to do so. This will ensure
    that the correct printer setup options will be used for every page in the
    archive.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited November 2003
    I tried your suggestion using

    procedure TBankoBicform.ppAInitializePrinterSetup(Sender: TObject);
    begin
    ppa.printersetup.printername := allglobal^.GLOBALopticalprinter;
    end;

    But it still doesn't work when you print to a file - seems to still go to
    current windows printer driver




  • edited November 2003
    Hi Dennis,

    When setting the printer name, you need to have the exact printer name used
    by the printer device for it to work. The best way to ensure you use the
    right name is to select the printer name from the
    Report.PrinterSetup.PrinterNames TStrings object.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited November 2003
    I do have the exact name - what should I try next?


  • edited December 2003
    Hi Dennis,

    When selecting a different printer using the PrinterNames property, does it
    still print to the default printer? How about when selecting a printer
    manually using the Object Inspector?

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited December 2003
    It seems to honor the printer selection when you are not printing to a file.

    If you print to a file it seems to allways use the default windows printer


  • edited December 2003
    Hi Dennis,

    Sorry for the delay in this response. After your first post, I failed to
    see that you were setting your Report.DeviceType to PrinterFile rather than
    Printer. PrinterFile is an TExtraDevices device that I assume tries to
    print a report to a .prn file. I am however not sure how this device
    selects the printer to use to create this file.

    To print to a .prn file using ReportBuilder, simply set your
    Report.DeviceType to Printer, then set the Report.PrinterSetup.FileName to
    the name of the file you would like to print to. Using the selected
    printer, ReportBuilder will then print to the file you define.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited December 2003
    Thanks a million

  • edited December 2003
    OK, Now I am using the following code. In doing so it does use the correct
    printer driver but instead of going to a file it actually prints

    ppa.devicetype := 'Printer';
    ppa.archivefilename := trim(globalpath) + 'Reports\' +
    sbadatamodule2.pastreportsfilename.value;
    ppa.PrinterSetup.FileName := filetocreate;
    ppa.showprintdialog := false;
    ppa.printer.printername := allglobal^.GLOBALopticalprinter;
    ppa.print;
    ppa.showprintdialog := true;

    Thanks in advance
    Dennis McGuire



  • edited December 2003
    Hi Dennis,

    Again I must apoligise for not realizing you were using an ArchiveReader
    rather than a Report object. When using the ppArchiveReader, you need to
    use the OnInitializePrinterSetup event to set any PrinterSetup properties.
    Move the "ppa.PrinterSetup.FileName := FileToCreate;" line inside this
    event and the problem should be fixed.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.