Application creation

<< Click to Display Table of Contents >>

Navigation:  Gnostice Document Studio .NET > Getting Started > Document Printing > WinForms >

Application creation

Steps to include basic printing functionality in WinForms application.

1.Open Visual Studio and create a new Windows Forms project.

2.Use either the GUI or the Package Manager Console and install the Gnostice.DocumentStudio.Printer NuGet package.

3.Build the application.

4.Adding the component to the toolbox

a.For Visual Studio 2017 and later: Nothing to be done, the control automatically appears on the Toolbox under Gnostice.Controls.WinForms.

b.For Visual Studio 2015 and earlier

i.In the toolbox, add a new tab titled Gnostice Document Studio .NET

ii.On this tab, add the Gnostice.DocumentStudio.Printer.dll assembly from the bin\debug or bin\release folder of your project. This will add a new DocumentPrinter component to the tab.

5.Drop the following components on the form.

Button

OpenFileDialog

Gnostice Document Studio .NET -> DocumentPrinter

6.Double-click the button and add the following code to print a document selected by the user.

 

 

    // Set up the open-file dialog
    openFileDialog1.FileName = "";
    // Set a filter for the file list
    openFileDialog1.Filter = "All files (*.*)|*.*";
    // Show the dialog
    if (openFileDialog1.ShowDialog() == DialogResult.OK)
    {
        // Set page scaling
        documentPrinter1.PageScaling = Gnostice.Core.Printer.PageScalingOptions.Fit;
        // Finally issue the print
        documentPrinter1.Print(openFileDialog1.FileName);

    }

 

 

7.Run the application.