Viscomsoft .NET PDF Viewer SDK

PDFDocument.print2printer Method

 

Print the PDF document to specific Printer without display print dialog

 Visual Basic

Public Sub print2printer(strPrinterName as String, iPrinterTrayIndex as Integer)  

 
 C#

public void print2printer(string strPrinterName int iPrinterTrayIndex)

 

Parameter

strPrinterName - the string of printer name.
iPrinterTrayIndex - the index of paper source. the first index is zero.
You may use getPaperSourceCountByPrinter() and getPaperSourceNameByPrinter(), to get total count of paper source for specific index and get the name of paper source.

Namespace: Viscomsoft.PDFViewer

No Return Value

Example

   

[C# Syntax] 
using Viscomsoft.PDFViewer;

public partial class Form1 : Form
{

  public PDFView _pdfViewer;
  _pdfViewer = new PDFView();
  _pdfViewer.Canvas.Parent = this;
  _pdfViewer.Canvas.Location = new Point(0, 24);

  private void Form1_Load(object sender, EventArgs e)
  {
    resizeCanvas();

    PDFDocument doc = new PDFDocument();
    if (doc.open("c:\\yourfile.pdf"))
    {
      _pdfViewer.Document = doc;
      _pdfViewer.gotoPage(1);
      _pdfViewer.Document.print2printer("Microsoft Print to PDF",0);
    
    }
  }
 

  private void resizeCanvas()
  {
  _pdfViewer.Canvas.Size = new Size(this.ClientSize.Width, this.ClientSize.Height - 24);
  }
}


 

   

[Visual Basic Syntax] 
Imports Viscomsoft.PDFViewer

Public Class Form1
 

Private Sub resizeCanvas()

  _pdfviewer.Canvas.Size = New Size(Me.ClientSize.Width, Me.ClientSize.Height - 24)

End Sub

Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

  _pdfviewer.Canvas.Parent = Me

  _pdfviewer.Canvas.Location = New Point(0, 24)

  resizeCanvas()

  Dim doc As New PDFDocument

  If doc.open("c:\temp\yourfile.pdf") Then

  _pdfviewer.Document = doc

  _pdfviewer.gotoPage(1)
  _pdfViewer.Document.print2printer "Microsoft Print to PDF",0
  End If

End Sub


End Class