How to Print And Save a report to local folder

Hello Guys,

Has anybody came across a solution to Print/Directly save a report on Button Click.

Any previous solution or current method can help

Are you looking to print preview directly? Or you want to print it and then save it all in one button click? So the user would click the button, and what exactly do you want to happen?

I have created both a button click print preview and also a button click save file… but never both together. :slight_smile:

yes I want to Print it save and email the same to the customer.
Even if you have done the save separately could you share something which can help me here.

Here’s one I just found:

Do you use APR (Automatic Print Routing)? That will do exactly what you’re trying to do whenever you print the given report using the report style with APR setup. We use that for things like invoices, acknowledgements, and POs. You could just call that report and report style in your button click event and it would do whatever you setup in the print routing (email to customer).

Actually I am aware about Routing but as per my requirement I have to send the attachment along with the packslip to the customer in one single.

Now routing will send only the packslip to the customer and through customization/BPM i can send the attachments but I wan to push these two in one single email.

so what I thought of is I will save the Packslip first to a shared location.
So while emailing I can pick it up from the same location and also the attachmets from other location and send it. but I am not finding anything to save to a drive.

Ok. I thought you were just trying to save the PackSlip to the drive and then attach it.
I understand your requirement better now.

I have heard of people doing something like this.

This is roughly what you’ll have to do to retrieve the file and attach it to an email:

  //--------------------------------
  //    ATTACH ACKNOWLEDGMENT
  //---------------------------------
    Dictionary<string, Stream> attachments = new Dictionary<string, Stream>();
    int t = 0;
    int x = 1;
  
      var getFile = (from mmf in Db.SysRptLst
                 join st in Db.SysTask on new {mmf.Company, mmf.SysTaskNum} equals new {st.Company, st.SysTaskNum}
                 where st.TaskNote == taskNote
                 select mmf.RptData).FirstOrDefault();
    
      if (getFile != null)
      {        
        string strFile = Convert.ToBase64String(getFile);
  
        byte[] pdfBytes = System.Convert.FromBase64String(strFile);
        MemoryStream pdfFile = new MemoryStream(pdfBytes);
        attachments.Add("Order " + orderNum.ToString() + " Updated Ack.pdf", pdfFile);
      } 
    
  //--------------------------------
  //    SEND EMAIL WITH ATTACHMENT
  //---------------------------------      
    if (attachments.Count > 0)
    {
      mailer.Send(message, attachments);
    }
    else 
    {
      mailer.Send(message);
    }

You’ll have to play with the getFile command to look in a directory. I was hijacking the actual Epicor table that has the file during the creation of a report… and I had mixed results with it. But you could just as easily use a different strategy and choose to pull it from a shared directory. As you might imagine, there’s a bunch of code before that which generates the body of the email. If you need any of that, I can send that as well.