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.

list of the following feature

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, 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", "demoKey");
  • string pdfFile = @"c:\test\test.pdf";
  • int pageNumber = 2;
  • Bitmap bitmap = pdfPrint.GetBitmapFromPdfPage(pdfFile, pageNumber);
  • var status = pdfPrint.SavePdfPageAsImage(pdfFile, @"c:\test\test.jpg", pdfPrint.GetNumberOfPages(pdfFile)); // save Last page as jpg
  • int fromPage = 3;
  • int toPage = 6;
  • status = pdfPrint.SavePdfPageAsImages(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.SavePdfPageAsImages(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);

Start doing stuff now! Try PDFPrinting.NET demo for free!