Closed binodmahto closed 7 years ago
Actually I have winodws 7 on my local box and When I use PdfiumViewer to print a document through WCF application (hosted through IIS 7.5 locally) under impersonation, things works fine. But the same application when I deployed in Window Server 2012 R2 (which has IIS 8.5), it doesn't work.
:(
boiling down further on this issue I figured out it's not an issue of PdfiumViewer because finally printing is done through Microsoft library(System.Drawing.Printing.PrintDocument). So the issue here is with Impersonation, which I'm doing to access the network printer to print. If i change the application pool identity to run under a domain user (who has the access to printer) then it works fine. If i try to do the same thing using impersonation through code and let the application runs with app pool identity 'LocalService' then printing fails.
Since I don't see this is an issue with pdfiumviewer I'm closing my issue raised here.
I'm trying to print a pdf through c# wcf application using below code. Since WCF application hosted in IIS and runs under system user LOCALSYSTEM (identity in application pool) so I'm doing the impersonation programmatically before calling below code to print.
This works perfectly when WCF Application hosted in IIS 7.5 with Windows 7 OS but it fails when the WCF application hosted in IIS 8.5 with Windows Server 2012 R2 OS. Basically in this case document goes to the print queue but it doesn't show the size of the document and may be because of that it is unable to print.
here is the code:
var printerSettings = new PrinterSettings { PrinterName = printerNetworkPath, PrintFileName = fileName, PrintRange = PrintRange.AllPages, }; printerSettings.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0); using (var document = PdfiumViewer.PdfDocument.Load(filePath)) { using (var printDocument = document.CreatePrintDocument()) { printDocument.DocumentName = fileName; printDocument.PrinterSettings = printerSettings; printDocument.PrintController = new StandardPrintController(); printDocument.Print(); } }
Below attach file shows the print queue after sending the document to printer through above code.What could be the issue??
Note: I'm using PdfiumViewer with version 2.12.0 and pdfium.dll 64 bit.