Q: Can I use PDFNet SDK (http://www.pdftron.com/pdfnet) to force a pdf
to print silently to a specified printer by name (e.g.
"CheckPrinterABC", and not just the default printer)?
We need to print checks to a special check printer (and can not allow
the user to select which installed printer to use from a windows print
dialog).
----------
A: You can use PDFNet SDK to print silently to a specified printer by
name.
As a starting sample you may want to take a look at PDFPrint sample:
http://www.pdftron.com/pdfnet/samplecode.html#PDFPrint
If you are developing under .NET (C#, VB, ...) to suppress the print
status dialog box, you can instantiate StandardPrintController instead
of PrintControllerWithStatusDialog (which is the default):
PrintDocument printer = new PrintDocument();
Use:
printer.PrintController = New StandardPrintController
as opposed to
printer.PrinterController = New PrintControllerWithStatusDialog
which is the default settings.
To select a given printer just specify its name. For example
printer.DocumentName = _distQueueID;
PrinterSettings settings = new PrinterSettings();
settings.PrinterName = _destination;
if (settings.IsValid)
{
// Open the PDF document.
_pdfdoc = new PDFDoc(_pathToDoc);
_pdfdoc.InitSecurityHandler();
// Start printing from the first page
_pageitr = _pdfdoc.PageBegin();
// Create PDF rasterizer object - PDFDraw _pdfdraw = new PDFDraw();
printer.PrinterSettings = settings;
// Set the PrintPage delegate which will be invoked to print each
page
printer.PrintPage += new PrintPageEventHandler(PrintPage);
// Start printing
printer.Print();
// Close the file
_pdfdoc.Close();
}
If you are developing using C/C++ you can swap the following two lines
to print to a specific printer:
pd.hDC = ::GetDefaultPrinterDC();
// pd.hDC = CreateDC("winspool", "\\\\pdftron\\HLPJ9300", 0, 0);