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

Re: Re: PrinterDevice always nil!

edited October 2005 in General
Dear Nico,


Yes, of course. It was just a mistake im my newly setup news-client.



Thank you for your advice but we seem to be missing something.
TppReport doesnt seem to have the property ScreenDevice.
I tried to use Viewer.ScreenDevice instead but this doesnt seem
to have any effect.

The code runs without errors but the report ignores my PageList settings
and still prints ALL PAGES...

Through testing I discovered the following (for me odd) habit:
Why is Report.Publisher READONLY but ScreenDevice.Publisher
READ/WRITE?

Please assist again.
Best regards,
Harald

P.S.: since this code runs in a custom previewPlugin I?m using "Self.Report"
instead of the calling TppReport-component (reference checked and ok)

here?s my current code:
--- CODE START -------------------------------------------------------
//creating print device
oPrnDev := TppPrinterDevice.Create(nil);

try
//assign custom publisher
oPrnDev.Publisher := Self.Report.Publisher;

//assign current page to print
iCurrentPage := Self.Viewer.AbsolutePageNo;
ppTextToPageList(IntToStr(iCurrentPage), oPrnDev.PageList, True);

//Self.Report.ScreenDevice.Publisher := nil; //<---- NOT
POSSIBLE!
Self.Viewer.ScreenDevice.Publisher := nil; //doenst seem to
have any effect...

//Print
//Self.Report.Print;
//wheres the difference?
Self.Report.PrintToDevices;

finally
Self.Viewer.ScreenDevice.Publisher := Self.Report.Publisher;
oPrnDev.Free;
end;

--- CODE END -------------------------------------------------------

Comments

  • edited October 2005
    Hi Harald,

    Sorry, I didn't give you all the information you needed. If you are using a
    page list you need to set the device.PageSetting to psPageList. Also the
    ScreenDevice is part of the Viewer object, not the Report, my mistake. The
    following code worked correctly for me when I tested it.

    procedure TMyPreviewPlugin.CustomButtonClickEvent(Sender: TObject);
    var
    lPrinterDevice: TppPrinterDevice;
    liCurrentPage: Integer;
    begin

    lPrinterDevice := TppPrinterDevice.Create(nil);

    try
    liCurrentPage := Viewer.AbsolutePageNo;

    //Connect Printer Device
    lPrinterDevice.Publisher := Report.Publisher;

    lPrinterDevice.PageSetting := psPageList;
    ppTextToPageList(IntToStr(liCurrentPage), lPrinterDevice.PageList,
    True);

    Report.ShowPrintDialog := False;

    //Disconnect Screen Device
    Viewer.ScreenDevice.Publisher := nil;

    Report.PrintToDevices;

    finally
    lPrinterDevice.Free;
    Viewer.ScreenDevice.Publisher := Report.Publisher;
    end;

    end;

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited October 2005
    hi nico,

    setting the device´s PageSetting to psPageList finally produced the
    desired result.
    thanks to you my custom preview-class is working perfectly now!

    besides,
    one issue I discovered is when adding a PrintToPDF-Button to my preview
    was that the report run through the code without problems but didn´t
    create a pdf-file until I added ppPDFDevice to my uses list which I
    found rather odd.

    maybe for future RB releases its worth thinking about
    raising an exception or posting an error message in that case.

    thank you very much for your help!
    best regards,
    harald

    -----------------------------------------------------------------------

  • edited October 2005
    Hi Harald,


    Thanks for the suggestion. This was a design decision we made when creating
    the PDF Device in order to completely separate the device from the report,
    unless the user needed it. It was a toss-up between convenience and
    performance. Performance ultimately won out.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

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