I would like to know how to print a PDF from a Windows service while specifying which printer to use.
I tried with PDFViewer, but apparently I have an error "Format string input invalid"
An idea, a procedure?
I try to open my pdf with Acrobat and it's ok. But, with PDFViewer, i have a error.
If I use PrintLargePdf => Error
If I use OpenPdfFile => Error
And always the same error : "Format invalid"
I have tested this issue at my end and found no problem. I have used the following code:
PdfViewer viewer = new PdfViewer();
System.Drawing.Printing.PrinterSettings pset = new System.Drawing.Printing.PrinterSettings();
pset.Copies = 1; //specify number of copies
pset.PrinterName = "HP Officejet 4300 series"; // name of default printer to be used
viewer.PrintDocumentWithSettings(pset); //pass printer settings object to the method
Kindly try this code snippet at your end. You can also use this code in the windows service and specify the printer name as well. If you still find any problem, please do let us know.
I'm sorry for the inconvenience. In fact, common.Path has nothing to do with the actual code; that is my custom method to resolve the path to the test files. You can specify the path as OpenPdfFile(@"c:\test").
Please try it like this. If problem still persists then please make make a sample windows project with your code and share with us, so that we could have a look and find the problem.
Please share your code with us and the detailed error message as well. Kindly, mention which version of Aspose.Pdf.Kit for .NET you're using? Are you using a 32-bit or 64-bit machine? Which OS are you using.
As a matter of fact, in order to diagnose the problem we need to create the scenario at our end and reproduce the problem, so that we'll be able to fix it.
We really appreciate your cooperation.
I provided a new project as an example the first use of specific components, but the problem still exists in this version.
Thank you very much for sharing the details. We'll look into the matter and update you the earliest possible.
We appreciate your patience.
I have again tested the issue at my end using the same specifications as yours and found no problem. Can you please try Aspose.Pdf.Kit 188.8.131.52 at your end? This is our latest version of Aspose.Pdf.Kit. I'm very sorry that you're having this problem. Nevertheless, if problem persists then, please do let us know, so that I'll be able to forward a request to our development team for further investigation.
We're sorry for the inconvenience.
L'exception System.FormatException n'a pas été gérée
Message="Le format de la chaîne d'entrée est incorrect."
à Aspose.Pdf.Kit.PdfViewer.OpenPdfFile(String filePath)
à WindowsApplication1.Form1.button2_Click(Object sender, EventArgs e) dans C:\Documents and Settings\Laurent Bensch\Mes documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Form1.cs:ligne 38
à System.Windows.Forms.Control.OnClick(EventArgs e)
à System.Windows.Forms.Button.OnClick(EventArgs e)
à System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
à System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
à System.Windows.Forms.Control.WndProc(Message& m)
à System.Windows.Forms.ButtonBase.WndProc(Message& m)
à System.Windows.Forms.Button.WndProc(Message& m)
à System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
à System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
à System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
à System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
à System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
à System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
à System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
à System.Windows.Forms.Application.Run(Form mainForm)
à WindowsApplication1.Program.Main() dans C:\Documents and Settings\Laurent Bensch\Mes documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Program.cs:ligne 17
à System.AppDomain._nExecuteAssembly(Assembly assembly, String args)
à System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String args)
à System.Threading.ThreadHelper.ThreadStart_Context(Object state)
à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
The 'French version' proved to be a valuable piece of information! In fact, I have reproduced the isse at my end by changing the culture info to French. I have logged this issue as PDFKITNET-9586 in our issue tracking system. Our team will be looking into the matter and you'll be updated via this forum as the issue is resolved.
Can you please share the sample project along with the PDF file you’re having problem with? We need to test the issue at our end.
We’re sorry for the inconvenience.
The issues you have found earlier (filed as PDFNEWNET-9586) have been fixed in Aspose.Pdf for .NET 7.8.0update.