Skip to main content
Kofax

Print the current image displayed in the Validation module

11949

QAID # 11949 Published

Question / Problem:

How can I print the current image displayed in the Validation module?

Answer / Solution:

There is no direct API to print inside Kofax Capture. However, the file name of the currently displayed image is available for use in a Custom Panel. Below is sample code that can be used in a Custom Panel, to be executed by a button or some other control:

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using Kofax.AscentCaptureModule;
using System.Drawing;
using System.Drawing.Printing;
using System.IO;

namespace PrintPanel
{

    [Guid("9398F9B3-7E4C-4db4-9A3A-4B0FFB37E177")]
    [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
    public interface _PrintPage
    {

        [DispId(1)]
        Kofax.AscentCaptureModule.Application Application { set;}
        [DispId(2)]
        void ActionEvent(int EventNumber, object Argument, out int Cancel);

}
    [Guid("589588A7-E06A-4ab7-B859-17F661549169")]
    [ClassInterface(ClassInterfaceType.None)]
    [ProgId("PrintPanel.PrintPage")]
    public class PrintPage : UserControl, _PrintPage
    {

        private Button btnPrint;
        private Kofax.AscentCaptureModule.Application m_oMyApp;
        private Image photo;

public PrintPage()

{
    InitializeComponent();

}
public Kofax.AscentCaptureModule.Application Application
{

set {
        m_oMyApp = value;
    }

}
public void ActionEvent(int EventNumber, object Argument, out int Cancel)
{

    //We are not implementing any events for this panel.

Cancel = 0; }
private void InitializeComponent()
{

    this.btnPrint = new System.Windows.Forms.Button();
    this.SuspendLayout();

}
//
// btnPrint
//
this.btnPrint.Image = global::PrintPanel.Properties.Resources.Print;
this.btnPrint.ImageAlign = System.Drawing.ContentAlignment.TopCenter;
this.btnPrint.Location = new System.Drawing.Point(5, 12);
this.btnPrint.Name = "btnPrint";
this.btnPrint.Size = new System.Drawing.Size(71, 54);
this.btnPrint.TabIndex = 0;
this.btnPrint.Text = "Print Page";
this.btnPrint.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.btnPrint.UseVisualStyleBackColor = true;
this.btnPrint.Click += new System.EventHandler(this.btnPrint_Click);
//
// PrintPage
//
this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.Controls.Add(this.btnPrint);
this.Name = "PrintPage";
this.Size = new System.Drawing.Size(83, 78);
this.ResumeLayout(false);

private void btnPrint_Click(object sender, EventArgs e)
        {

            photo=Image.FromFile(m_oMyApp.ActiveBatch.get_ActivePage().FileName.ToString());
            PrintDocument printDoc = new PrintDocument();
            printDoc.PrintPage += new PrintPageEventHandler(printDoc_PrintPage);

            PrintPreviewDialog dlg = new PrintPreviewDialog();
            dlg.Document = printDoc;
            dlg.ShowDialog();

}
        void printDoc_PrintPage(object sender, PrintPageEventArgs e)
        {

            Point ulCorner = new Point(0, 0);

            e.Graphics.DrawImage(photo, ulCorner);
        }

} } 

Applies to:

Products Version
CAPTURE 10.0
  10.1
  10.2
  11.0
  • Was this article helpful?