chromelyapps / Chromely

Build Cross Platform HTML Desktop Apps on .NET using native GUI, HTML5, JavaScript, CSS, Owin, AspNetCore (MVC, RazorPages, Blazor)
MIT License
2.98k stars 279 forks source link

Print file directly #301

Closed redaxol closed 3 years ago

redaxol commented 3 years ago

how to print a pdf file directly to default printer without showing print dialog or option like kiosk

mattkol commented 3 years ago

@redaxol

You can do most custom tasks in the Controllers for C# and for JavaScript in html or js files but actual printing to printer itself is not supported. You need to look into other projects for that.

Note: This is still in reference to printing silently. CEF/CefGlue exposes PrintToPDF, Print. These will be exposed to make them obvious.

redaxol commented 3 years ago

Is that there are lightweight alternatives of Chromely in .net that support this feature ?

mattkol commented 3 years ago

@redaxol

Is that there are lightweight alternatives of Chromely in .net that support this feature ?

My statement was a bit misleading. I just updated that.

This is what I meant: https://github.com/chromelyapps/Chromely/issues/303.

So what you intend to do will will be done in this method:

       class PrintToPdfCallback : CefPdfPrintCallback
        {
            protected override void OnPdfPrintFinished(string path, bool ok)
            {
                if (ok)
                {
                    // Do the printer work here.
                    // Or other tasks.
                }
            }

            public void Dispose()
            {
            }
        }

We can look into feature exposing printing to PDF.