using PdfDocument = Spire.Pdf.PdfDocument; static void Main(string[] args) { PdfDocument doc = new PdfDocument(); doc.LoadFromFile("SampleDocument.pdf"); //Use the default printer to print all the pages //doc.PrintDocument.Print(); //Set the printer and select the pages you want to print PrintDialog dialogPrint = new PrintDialog(); dialogPrint.AllowPrintToFile = true; dialogPrint.AllowSomePages = true; dialogPrint.PrinterSettings.MinimumPage = 1; dialogPrint.PrinterSettings.MaximumPage = doc.Pages.Count; dialogPrint.PrinterSettings.FromPage = 1; dialogPrint.PrinterSettings.ToPage = doc.Pages.Count; if (dialogPrint.ShowDialog() == DialogResult.OK) { //Set the pagenumber which you choose as the start page to print doc.PrintFromPage = dialogPrint.PrinterSettings.FromPage; //Set the pagenumber which you choose as the final page to print doc.PrintToPage = dialogPrint.PrinterSettings.ToPage; //Set the name of the printer which is to print the PDF doc.PrinterName = dialogPrint.PrinterSettings.PrinterName; PrintDocument printDoc = doc.PrintDocument; dialogPrint.Document = printDoc; printDoc.Print(); } }
Process p = new Process( ); p.StartInfo = new ProcessStartInfo( ) { CreateNoWindow = true, Verb = "print", FileName = path //put the correct path here }; p.Start( );
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)