Hi.
Can i print PDF files from Windows Service with Aspose ?
I need to be able to control tray’s aswell as color options.
I have tried using the following code.
PdfViewer p = new PdfViewer();
p.BindPdf(this.FileName);
System.Drawing.Printing.PrinterSettings ps = p.GetDefaultPrinterSettings();
System.Drawing.Printing.PageSettings pgs = p.GetDefaultPageSettings();
ps.Copies = this.Copies;
pgs.Color = this.printColor;
ps.DefaultPageSettings.Color = this.printColor;
pgs.Margins = new System.Drawing.Printing.Margins(0, 0, 0, 0);
ps.PrinterName = this.PrinterName;
p.PrinterJobName = this.PrintName;
p.PrintDocumentWithSettings(pgs, ps);
This code only works aslong as my user is logged into the server with desktop. As soon i log out and the service should print by it self(its setup to run under my account).
I get the following error.
System.Drawing.Printing.InvalidPrinterException: Settings to access printer ‘\optdc02\HP LJ300-400 color MFP M375-M475 PCL 6’ are not valid.
at System.Drawing.Printing.PrinterSettings.GetHdevmodeInternal(String printer)
at System.Drawing.Printing.PrinterSettings.CreateDeviceContext(PageSettings pageSettings)
at System.Drawing.Printing.PageSettings.get_HardMarginX()
at Aspose.Pdf.Facades.PdfViewer.(PageSettings pageSettings, Single& x, Single& y)
at Aspose.Pdf.Facades.PdfViewer.PrintDocumentWithSettings(PageSettings pageSettings, PrinterSettings printerSettings)
at OptimateDistributionEngine.PDFPrinter.print()
So is there anyway to print PDF from a windows service using Aspose ?