We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Silent Printing


Hello !

I would like to know whether it is possible with your technology to print silently a pdf document in a WindowsForms application.
What I mean, is it there an object(like PdfViewer) to which I can pass the printer name and eventually the printer settings and then call a method like Print to send the document to the printer without making anything visible on the screen?

Thank you !
Ernest Morariu


3 Replies

GM Geetha M Syncfusion Team October 11, 2011 11:35 AM UTC

Hi Ernest,

Thank you for your interest in Syncfusion products.

Yes. It is possible to start silent printing with the help of Essential Pdf Viewer for Windows using the following code snippet:

PrintDialog dialog = new PrintDialog();
dialog.AllowPrintToFile = true;
dialog.AllowSomePages = true;
dialog.PrinterSettings.FromPage = 1;
dialog.PrinterSettings.ToPage = pdfViewer1.PageCount;
dialog.PrinterSettings.PrinterName = "HP LaserJet";
dialog.Document = pdfViewer1.PrintDocument;

However, the print support has been added recently and if you can create a direct trac incident we will update you with further details about the patch to be installed to make use of it.

Please let me know if you have any questions.

Regards,
Geetha



EM Ernest Morariu October 26, 2011 11:21 AM UTC


Hi Geetha!

Now I have your last pdf components 9.4.0.62 with the license.
My UserId is: ernest.morariu@yumez.eu

Getting back to the subject "Silent Printing", I tried the sample you provided with the setup, I mean the project named "SilentPrinting", but it doesn't work.

In the button1_Click() the last line

dialog.Document = viewer.PrintDocument;

raises a FormatException(having InnerException = null) with the message "Input string was not in the correct format" and with the following StackTrace:
at System.Number.ParseSingle(String value, NumberStyles options, NumberFormatInfo numfmt)
at System.Single.Parse(String s)
at Syncfusion.PdfViewer.Base.ImageRenderer.RenderAsImage()
at Syncfusion.Windows.Forms.PdfViewer.PdfDocumentView.OnPrintPage(Object sender, PrintPageEventArgs e)
at System.Drawing.Printing.PrintController.PrintLoop(PrintDocument document)
at System.Drawing.Printing.PrintController.Print(PrintDocument document)
at System.Drawing.Printing.PrintDocument.Print()
at Syncfusion.Windows.Forms.PdfViewer.PdfDocumentView.get_PrintDocument()
at EssentialPDFSamples.Form1.button1_Click(Object sender, EventArgs e) in C:\Users\ernest.HQ\AppData\Local\Syncfusion\EssentialStudio\9.4.0.62\Windows\Pdf Viewer.Windows\Samples\2.0\Print\Silent Printing\CS\Form1.cs:line 164
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at EssentialPDFSamples.Form1.Main() in C:\Users\ernest.HQ\AppData\Local\Syncfusion\EssentialStudio\9.4.0.62\Windows\Pdf Viewer.Windows\Samples\2.0\Print\Silent Printing\CS\Form1.cs:line 152
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()


Thank you !
Ernest





Thank you for your interest in Syncfusion products.

Yes. It is possible to start silent printing with the help of Essential Pdf Viewer for Windows using the following code snippet:

PrintDialog dialog = new PrintDialog();
dialog.AllowPrintToFile = true;
dialog.AllowSomePages = true;
dialog.PrinterSettings.FromPage = 1;
dialog.PrinterSettings.ToPage = pdfViewer1.PageCount;
dialog.PrinterSettings.PrinterName = "HP LaserJet";
dialog.Document = pdfViewer1.PrintDocument;

However, the print support has been added recently and if you can create a direct trac incident we will update you with further details about the patch to be installed to make use of it.

Please let me know if you have any questions.

Regards,
Geetha




GM Geetha M Syncfusion Team October 31, 2011 05:30 AM UTC

Hi Ernest,

Thank you for the details.

I was able to reproduce the problem. Could you please create a direct trac incident so that we can update you with further details regarding this issue?

Regards,
Geetha


Loader.
Live Chat Icon For mobile
Up arrow icon