Search code examples
asp.net-mvc-3pdfaspose

Printing PDF from browser using Aspose.NET


I want to force a PDF to print from browser by clicking a link. It says here that embedding javascript using a PDF toolkit can make this possible, so would anyone know if/how this can be done with Aspose?


Solution

  • Found the answer, brilliantly simple and works a treat! (You can also use a stream instead of a path name in OpenPdfFile)

    //create PdfViewer object
    PdfViewer viewer = new PdfViewer();
    //open input PDF file
    viewer.OpenPdfFile(@"c:\input.pdf");
    //print PDF document
    viewer.PrintDocument();
    //close PDF file
    viewer.ClosePdfFile();