This is a migrated thread and some comments may be shown as answers.

Capture Print Event

1 Answer 141 Views
PDFViewer
This is a migrated thread and some comments may be shown as answers.
Benedikt
Top achievements
Rank 3
Iron
Iron
Iron
Benedikt asked on 30 Mar 2020, 09:10 AM

Hi guys,

 

I'm trying to capture the print event of a RadPDFViewer to not only print the PDF but also save it to a predifined location everytime it is printed.

Ithought about the Click event in the toolbar, but I also need to capture it if printed from contextmenu.

 

I have read something about inherit the print command, but I haven't gotten how to do that.

 

Greetings,

Benedikt

1 Answer, 1 is accepted

Sort by
0
Accepted
Dimitar
Telerik team
answered on 30 Mar 2020, 12:51 PM

Hi Benedikt,

Yes creating a custom command is suitable for this case. Here is an example that shows how you can implement that: 

public partial class MainWindow : Window
{      
    public MainWindow()
    {
        InitializeComponent();
        this.pdfViewer.CommandDescriptors = new CustomCommandDescriptors(this.pdfViewer);
    }
}
public class MyPrintPdfDocumentCommand : PrintPdfDocumentCommand
{
    public MyPrintPdfDocumentCommand(FixedDocumentViewerBase fixedDocumentViewerBase) : base(fixedDocumentViewerBase)
    {
    }
    public override void Execute(object parameter)
    {
        //save or perform other action
        base.Execute(parameter);
    }
}
public class CustomCommandDescriptors : DefaultCommandDescriptors
{
    private readonly CommandDescriptor printCommandDescriptor;

    public new CommandDescriptor PrintCommandDescriptor
    {
        get
        {
            return this.printCommandDescriptor;
        }
    }

    public CustomCommandDescriptors(FixedDocumentViewerBase fixedDocumentViewerBase)   : base(fixedDocumentViewerBase)
    {
        this.printCommandDescriptor = new CommandDescriptor(new MyPrintPdfDocumentCommand(fixedDocumentViewerBase));
    }
}

I hope this helps. Should you have any other questions do not hesitate to ask.

Regards,
Dimitar
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
PDFViewer
Asked by
Benedikt
Top achievements
Rank 3
Iron
Iron
Iron
Answers by
Dimitar
Telerik team
Share this question
or