PRINTING FEATURES

Here you can take a quick look at the most important features of PDFPrinting.NET. For a more detailed overview take a look at the quick start guide or the reference documentation.


  • Print PDF files from any .NET application
  • Built in font-rendering engine
  • Handles any PDF compression and encryption
  • Full control over margins and scaling
  • Advanced rasterization engine for image printing
  • Works perfectly on any kind of printer
  • Reduced spool size and faster spooling
  • Adheres strictly to pdf specification
  • Standalone solution without outside dependencies

LIST OF FEATURES


SIMPLE SILENT PRINTING OF PDF FILES

Silent printing enables you to print out documents in the background without user intervention. The below code sample will print out the PDF document to your default printer with default settings.

var pdfPrint = new PdfPrint("demoCompany", "demoKey");
string pdfFile = @"c:\test\test.pdf";
int numberOfPages = pdfPrint.GetNumberOfPages(pdfFile);
var status = pdfPrint.Print(pdfFile);
if (status == PdfPrint.Status.OK) { // check the result status of the Print method
     // your code here
}
// if you have pdf document in byte array that is also supported
byte[] pdfContent = YourCustomMethodWhichReturnsPdfDocumentAsByteArray();
status = pdfPrint.Print(pdfFile)

CONVERT PDF DOCUMENTS INTO IMAGES

You can convert any PDF document to the following image formats: TIFF, JPG/JPEG, BMP, PNG, GIF. You can convert just one page, a range of pages or all pages from the PDF document. You can convert a PDF document to a multi-page TIFF file.

var pdfPrint = new PdfPrint("demoCompany", var pdfPrint = new PdfPrint("demoCompany", "demoKey");
string pdfFile = @"c:\test\test.pdf";
int pageNumber = 2;
Bitmap bitmap = pdfPrint.GetBitmapFromPdfPage(pdfFile, pageNumber);
// save Last page as jpg
var status = pdfPrint.SavePdfPageAsImage(pdfFile, @"c:\test\test.jpg", pdfPrint.GetNumberOfPages(pdfFile));
int fromPage = 3;
int toPage = 6;
status = pdfPrint.SavePdfPagesAsImages(pdfFile, @"c:\test\newtest.jpg", fromPage, toPage);
status = pdfPrint.SavePdfPagesAsMultiPageTiff(pdfFile, @"c:\test\newtest.tiff", fromPage, toPage);
// if you have pdf document in byte array that is also supported
byte[] pdfContent = YourCustomMethodWhichReturnsPdfDocumentAsByteArray();
Bitmap bitmap2 = pdfPrint.GetBitmapFromPdfPage(pdfContent, pageNumber);
var status = pdfPrint.SavePdfPageAsImage(pdfContent,
        @"c:\test\test.jpg", pdfPrint.GetNumberOfPages(pdfContent)); // save Last page as jpg
status = pdfPrint.SavePdfPagesAsImages(pdfContent, @"c:\test\newtest.jpg", fromPage, toPage);
status = pdfPrint.SavePdfPagesAsMultiPageTiff(pdfContent, @"c:\test\newtest.tiff", fromPage, toPage);

WORKING WITH PASSWORD PROTECTED PDF DOCUMENTS

The following sample demonstrates how to check if the document is password protected. After that, it checks the password if it is valid and prints the document out.

var pdfPrint = new PdfPrint("demoCompany", "demoKey");
string pdfFile = @"c:\test\test.pdf";
if (!pdfPrint.IsSupportedFile(pdfFile)) ;
        return;//invalid pdf document
if (!pdfPrint.IsPasswordProtected(pdfFile))
        if (!pdfPrint.IsValidPassword(pdfFile, password))

return;//invalid password
status = pdfPrint.Print(pdfFile, password);
// if you have pdf document in byte array that is also supported
byte[] pdfContent = YourCustomMethodWhichReturnsPdfDocumentAsByteArray();
if (!pdfPrint.IsSupportedFile(pdfContent))
        return;//invalid pdf document
if (!pdfPrint.IsValidPassword(pdfContent, password))
        return;//invalid password
status = pdfPrint.Print(pdfContent, password);

CUSTOM PRINT PROPERTIES

Set page range, landscape, copies, resolution, scaling, print in color, paper size, source tray, collate, printer name or duplex. The below sample code demonstrates how to set those settings manually through your code.

var pdfPrint = new PdfPrint("demoCompany", "demoKey");
string pdfFile = @"c:\test\test.pdf";
pdfPrint.Collate = true;
pdfPrint.Copies = 2;
pdfPrint.DuplexType = System.Drawing.Printing.Duplex.Simplex;
pdfPrint.IsLandscape = true;
pdfPrint.PrintInColor = true;
pdfPrint.Pages = "2-6";
// pdfPrint.PaperSize = see our demo application source for example
// pdfPrint.PaperSource = see our demo application source for example
pdfPrint.PrinterName = "Your printer name";
// pdfPrint.PrinterResolution = see our demo application source for example
pdfPrint.RangeType = PdfPrint.RangeTypes.JustEven;
pdfPrint.Scale = PdfPrint.ScaleTypes.FitToMargins
var status = pdfPrint.Print(pdfFile);

SILENT PRINTING WITH ALREADY INSTALLED ADOBE READER

In case you would like to print using Adobe Reader for some specific document where our rendering doesn't meet your needs. The below sample code will invoke Adobe Reader in the background without being visible and print out the document.

var pdfPrint = new PdfPrint("demoCompany", "demoKey");
string pdfFile = @"c:\test\test.pdf";
var status =pdfPrint.PrintWithAdobe(pdfFile);
PrinterSettings printerSettings = YourCustomMethodWhichReturnsPrinterSettings();
status = pdfPrint.PrintWithAdobe(pdfFile, printerSettings);

USING PRINTERSETTINGS IN PRINTING

In case you decide to allow the end user to set the desired printer and print settings you can easily show a print dialog following the below sample.

var pdfPrint = new PdfPrint("demoCompany", "demoKey");
string pdfFile = @"c:\test\test.pdf";
PrinterSettings printerSettings = YourCustomMethodWhichReturnsPrinterSettings();
var status =pdfPrint.Print(pdfFile, printerSettings);
// if you have pdf document in byte array that is also supported
byte[] pdfContent = YourCustomMethodWhichReturnsPdfDocumentAsByteArray();
status = pdfPrint.Print(pdfContent, printerSettings);
// if you have pdf document in byte array that is also supported
pdfPrint.SettingDialog = true;//it will show printer dialog
status = pdfPrint.Print(pdfFile);

SIMPLE SILENT PRINTING OF PDF FILES

Silent printing enables you to print out documents in the background without user intervention. The below code sample will print out the PDF document to your default printer with default settings.

var pdfPrint = new PdfPrint("demoCompany", "demoKey");
string pdfFile = @"c:\test\test.pdf";
int numberOfPages = pdfPrint.GetNumberOfPages(pdfFile);
var status = pdfPrint.Print(pdfFile);
if (status == PdfPrint.Status.OK) { // check the result status of the Print method
     // your code here
}
// if you have pdf document in byte array that is also supported
byte[] pdfContent = YourCustomMethodWhichReturnsPdfDocumentAsByteArray();
status = pdfPrint.Print(pdfFile)

CONVERT PDF DOCUMENTS INTO IMAGES

You can convert any PDF document to the following image formats: TIFF, JPG/JPEG, BMP, PNG, GIF. You can convert just one page, a range of pages or all pages from the PDF document. You can convert a PDF document to a multi-page TIFF file.

var pdfPrint = new PdfPrint("demoCompany", var pdfPrint = new PdfPrint("demoCompany", "demoKey");
string pdfFile = @"c:\test\test.pdf";
int pageNumber = 2;
Bitmap bitmap = pdfPrint.GetBitmapFromPdfPage(pdfFile, pageNumber);
// save Last page as jpg
var status = pdfPrint.SavePdfPageAsImage(pdfFile, @"c:\test\test.jpg", pdfPrint.GetNumberOfPages(pdfFile));
int fromPage = 3;
int toPage = 6;
status = pdfPrint.SavePdfPagesAsImages(pdfFile, @"c:\test\newtest.jpg", fromPage, toPage);
status = pdfPrint.SavePdfPagesAsMultiPageTiff(pdfFile, @"c:\test\newtest.tiff", fromPage, toPage);
// if you have pdf document in byte array that is also supported
byte[] pdfContent = YourCustomMethodWhichReturnsPdfDocumentAsByteArray();
Bitmap bitmap2 = pdfPrint.GetBitmapFromPdfPage(pdfContent, pageNumber);
var status = pdfPrint.SavePdfPageAsImage(pdfContent,
        @"c:\test\test.jpg", pdfPrint.GetNumberOfPages(pdfContent)); // save Last page as jpg
status = pdfPrint.SavePdfPagesAsImages(pdfContent, @"c:\test\newtest.jpg", fromPage, toPage);
status = pdfPrint.SavePdfPagesAsMultiPageTiff(pdfContent, @"c:\test\newtest.tiff", fromPage, toPage);

WORKING WITH PASSWORD PROTECTED PDF DOCUMENTS

The following sample demonstrates how to check if the document is password protected. After that, it checks the password if it is valid and prints the document out.

var pdfPrint = new PdfPrint("demoCompany", "demoKey");
string pdfFile = @"c:\test\test.pdf";
if (!pdfPrint.IsSupportedFile(pdfFile)) ;
        return;//invalid pdf document
if (!pdfPrint.IsPasswordProtected(pdfFile))
        if (!pdfPrint.IsValidPassword(pdfFile, password))

return;//invalid password
status = pdfPrint.Print(pdfFile, password);
// if you have pdf document in byte array that is also supported
byte[] pdfContent = YourCustomMethodWhichReturnsPdfDocumentAsByteArray();
if (!pdfPrint.IsSupportedFile(pdfContent))
        return;//invalid pdf document
if (!pdfPrint.IsValidPassword(pdfContent, password))
        return;//invalid password
status = pdfPrint.Print(pdfContent, password);

CUSTOM PRINT PROPERTIES

Set page range, landscape, copies, resolution, scaling, print in color, paper size, source tray, collate, printer name or duplex. The below sample code demonstrates how to set those settings manually through your code.

var pdfPrint = new PdfPrint("demoCompany", "demoKey");
string pdfFile = @"c:\test\test.pdf";
pdfPrint.Collate = true;
pdfPrint.Copies = 2;
pdfPrint.DuplexType = System.Drawing.Printing.Duplex.Simplex;
pdfPrint.IsLandscape = true;
pdfPrint.PrintInColor = true;
pdfPrint.Pages = "2-6";
// pdfPrint.PaperSize = see our demo application source for example
// pdfPrint.PaperSource = see our demo application source for example
pdfPrint.PrinterName = "Your printer name";
// pdfPrint.PrinterResolution = see our demo application source for example
pdfPrint.RangeType = PdfPrint.RangeTypes.JustEven;
pdfPrint.Scale = PdfPrint.ScaleTypes.FitToMargins
var status = pdfPrint.Print(pdfFile);

SILENT PRINTING WITH ALREADY INSTALLED ADOBE READER

In case you would like to print using Adobe Reader for some specific document where our rendering doesn't meet your needs. The below sample code will invoke Adobe Reader in the background without being visible and print out the document.

var pdfPrint = new PdfPrint("demoCompany", "demoKey");
string pdfFile = @"c:\test\test.pdf";
var status =pdfPrint.PrintWithAdobe(pdfFile);
PrinterSettings printerSettings = YourCustomMethodWhichReturnsPrinterSettings();
status = pdfPrint.PrintWithAdobe(pdfFile, printerSettings);
Settings iconUsing PrinterSettings in Printing

USING PRINTERSETTINGS IN PRINTING

In case you decide to allow the end user to set the desired printer and print settings you can easily show a print dialog following the below sample.

var pdfPrint = new PdfPrint("demoCompany", "demoKey");
string pdfFile = @"c:\test\test.pdf";
PrinterSettings printerSettings = YourCustomMethodWhichReturnsPrinterSettings();
var status =pdfPrint.Print(pdfFile, printerSettings);
// if you have pdf document in byte array that is also supported
byte[] pdfContent = YourCustomMethodWhichReturnsPdfDocumentAsByteArray();
status = pdfPrint.Print(pdfContent, printerSettings);
// if you have pdf document in byte array that is also supported
pdfPrint.SettingDialog = true;//it will show printer dialog
status = pdfPrint.Print(pdfFile);