Dev Direct Solution Center

For more information and to buy this product...

Print PDF unattended

  For a copy of the sample project please click here to download and install the product evaluation.

Introduction

Hi, we offer a .NET component (32-bit and 64-bit support) that allows you to print PDF documents to any printer. Customers that already use our component for this purpose include Xerox, PitneyBowes and Microsoft. You will be using the standard .NET PrintDocument class so you will be able to customize anything including creating 2-up, stamp notices, etc. In the PrintPage handler you will simply be telling the PDF document to print to the System.Drawing.Graphics object that wraps the printer.

Detail

Typical PDF print code

c#
FileStream file;
Document document;
int pageIndex;

// call this method to open the PDF document
void open( string path )
{
   file = new FileStream(path, FileMode.Open, FileAccess.Read);
   document = new Document( file );
}

// call this method to start printing
void print()
{
   if ( null == document ) return;

   pageIndex = 0;

   PrintDocument printDocument = new PrintDocument();
   printDocument.DocumentName = document.Title;
   
   printDocument.PrintPage += new PrintPageEventHandler( printPage );
   printDocument.Print();
}

// this eventhandler is invoked by .NET as long
// as we tell that there are more pages
// note that you can easily implement printing a
// selection of pages
void printPage( object sender, PrintPageEventArgs e )
{
   e.Graphics.PageUnit = GraphicsUnit.Point;
   
   Page page = document.Pages[ pageIndex++ ];
      
   // this will send all graphical instructions on the
   // PDF page to the printer
   page.Draw(e.Graphics);

   e.HasMorePages = pageIndex < document.Pages.Count;
}

// clean up resources
void close()
{
   if ( null != file ) file.Close();
}
Visit TallComponents BV for more information and more samples.