PdfDocumentSource allows you to print a PDF document programmatically. It provides support for printing using the Print method of the C1DocumentSource abstract class. The Print method has two overloads, Print (PrinterSettings printerSettings) and Print (C1PrintOptions options). So, you can add the method using C1PdfDocumentSource to print a document without even the need of a viewer.
The following sections explain how the Print method can be used. The code snippets in this topic use the Print (C1PrintOptions options) method overload.
C# |
Copy Code
|
---|---|
using C1.Win.C1Document;
|
C# |
Copy Code
|
---|---|
c1PdfDocumentSource1.LoadFromFile(@"..\..\DefaultDocument.pdf");
|
C# |
Copy Code
|
---|---|
private void btnPrint_Click(object sender, EventArgs e) { if (printDialog1.ShowDialog(this) != DialogResult.OK) return; try { C1PrintOptions po = new C1PrintOptions(); po.PrinterSettings = printDialog1.PrinterSettings; //Print PDF c1PdfDocumentSource1.Print(po); MessageBox.Show(this, "Document was successfully printed.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } |