Determining when a report has been printed

Discussions relating to Jiwa 7 plugin development, and the Jiwa 7 API.

Determining when a report has been printed

Postby DannyC » Thu Dec 18, 2025 1:12 pm

Not sure if this should go in the Crystal Reports forum?

I've got a report ran from the menu.
When it's displaying on the screen in Print Preview, I need to write a plugin to intercept when it gets physically printed.

It's a report that shows open sales orders ready for picking in a format specific to this client. It's basically just consolidating the pickable lines by PartNo summing the Qty required.

When they print the report they also want Delivery Dockets printed for the orders using the InvoiceHistoryIDs which aren't displayed in the report but are available in the report source data.

I'm stumped on knowing how to start and what event(s) to hook into, getting the InvoiceHistoryID out of the report source, then printing the delivery dockets direct to the same printer that this report is going to.
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31

Re: Determining when a report has been printed

Postby DannyC » Thu Dec 18, 2025 2:39 pm

Just further to this, I've found the business logic JiwaFinancials.Jiwa.JiwaApplication.JiwaPrintReport.JiwaPrintReport.
I'm going to try hooking into the event AfterPrintOutputControllerPrintReport.

From there I should be able to determine the report properties to ensure I am only dealing with the report I need, not just any random report.

I'll see how far I progress and maybe post a half-arsed plugin here for some feedback.

EDIT:
So this is what I have so far. When I print, nothing happens. Well, I get my harcopy output but the event isn't firing my code.
Code: Select all
#region "BusinessLogicPlugin"
public class BusinessLogicPlugin : System.MarshalByRefObject, JiwaFinancials.Jiwa.JiwaApplication.IJiwaBusinessLogicPlugin
{

    public override object InitializeLifetimeService()
    {
        // returning null here will prevent the lease manager
        // from deleting the Object.
        return null;
    }

    public void Setup(JiwaFinancials.Jiwa.JiwaApplication.IJiwaBusinessLogic JiwaBusinessLogic, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
    {
      if (JiwaBusinessLogic is JiwaFinancials.Jiwa.JiwaApplication.JiwaPrintReport.JiwaPrintReport)
      {
         JiwaFinancials.Jiwa.JiwaApplication.JiwaPrintReport.JiwaPrintReport reportPrint = (JiwaFinancials.Jiwa.JiwaApplication.JiwaPrintReport.JiwaPrintReport)JiwaBusinessLogic;
         reportPrint.AfterPrintOutputControllerPrintReport += InterceptReportPrinting;
         
      }
    }
   
   private void InterceptReportPrinting(ref JiwaFinancials.Jiwa.JiwaApplication.JiwaPrintReport.JiwaPrintReport jiwaPrintReport, ref JiwaFinancials.Jiwa.JiwaApplication.PrintGroup.Maintenance.LogicalPrinter printer, ref int copies, ref CrystalDecisions.ReportAppServer.Controllers.PrintReportOptions PrintReportOptions)
   {
      System.Diagnostics.Debugger.Launch();
      MessageBox.Show(jiwaPrintReport.Report.FileName);
   }
}
#endregion
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31

Re: Determining when a report has been printed

Postby Mike.Sheen » Thu Dec 18, 2025 4:57 pm

DannyC wrote: the event isn't firing my code.


How is the actual print triggered?

Is it from the Crystal Reports report viewer toolbar?
CrystalReportsToolbar.png
CrystalReportsToolbar.png (26.19 KiB) Viewed 9097 times


Because that won't raise the AfterPrintOutputControllerPrintReport event -that's part of the Crystal Reports Viewer control and that's it's own thing.

If that is how you are triggering the print, then you would need to jump through some hoops like we do for exporting using the export tool - we basically hide the toolbar button and add our own, and tell the toolbar to invoke our own method instead of the standard one.

High degree of difficulty.

If it is not from the Crystal Reports Viewer control toolbar, then where?
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807

Re: Determining when a report has been printed

Postby DannyC » Thu Dec 18, 2025 5:37 pm

Is it from the Crystal Reports report viewer toolbar?


yes
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 1 guest