[C#, physical printer]How to print to a physical printer?

If you are a C/C++/C# developer and have any questions about using our products from your application here is the place to post them.
Post Reply
pmeems
Posts: 11
Joined: Mon Jul 23 2007
Location: The Netherlands

[C#, physical printer]How to print to a physical printer?

Post by pmeems » Thu Aug 02 2007

I create several pdf's using Amyuni and some of those pdf's needs to be physical printed. In the feature list of PDF Converter it says Amyuni can print to a physical printer.
I'm looking for some C# code which is doing this, can anybody provide me with some?

Thanks in advanced.

Paul
The Netherlands

M Johnson
Posts: 3
Joined: Fri Aug 03 2007

Post by M Johnson » Thu Aug 16 2007

I have been able to print a pdf by using the following code.

But have been unable to get the printer dialog to show so my users can change printers.

public override void PrintPDF()
{
// get default printer values;
PrintDocument objPrintDocDefault = new PrintDocument();
string strDefaultPrinter = objPrintDocDefault.PrinterSettings.PrinterName;

CDIntf.PDFDocumentControl pdfDocNet2 = new CDIntf.PDFDocumentControl();
pdfDocNet2.SetLicenseKey(Declarations.LicensedTo, Declarations.ActivationCode);

// file to open for printing
pdfDocNet2.Open(m_parentForm.DecompressedPath + @"\Final.pdf", "");

// Print the pdf
pdfDocNet2.Print(strDefaultPrinter, 1, 2, 1);
}

Does anyone know how to get the printer dialog to show?

David
Amyuni Team
Posts: 89
Joined: Mon Dec 18 2006

Post by David » Mon Aug 20 2007

Hello

1) Below is a sample code snippet to print using the Print() method of the PDF Converter

CDIntf.PDFDocumentControl PDF1 = new CDIntf.PDFDocumentControl();

PDF1.Open("c:\\temp\\PreAppend.pdf","");

//PDF1.Print(PrinterName, Startpage, EndPage, copies);
//Leaving printername as blank prints to the systems default printer

PDF1.Print("", 1, 5, 1);

2) To have the users select a printer from a list of printers you will need to use the Windows PrinterSettings.InstalledPrinters Property.

You can find a good example of this at the following link: http://msdn2.microsoft.com/en-us/librar ... S.80).aspx

Hope that helps

Post Reply