There is web page, that has the "Print" button. I load it using DCEF3. If user clicks the button, the Printer selection dialog is shown. I want to disable printing once and for all.
I have been trying to pass command line parameters using the example.
So, I tried the following:
--disable-print-preview
--kiosk
--kiosk-printing
But none of them did the trick. Am I missing something?
CEF3 doesn't support "silent" printing, that is, printing without a printer selection dialog.
All you can do is :
Print to a temporal PDF file and then print the PDF file.
Take a snapshot from the browser and print the bitmap.
Modify the CEF3 libraries to hide the printer selection dialog.
These functions are much easier to use with CEF4Delphi or OldCEF4Delphi. To print in a PDF file all you have to do is call TChromium.PrintToPDF and to take a snapshot you need to call TChromium.TakeSnapshot
Not all the Chromium flags or command line switches are supported by CEF3. --kiosk and --kiosk-printing are not supported as you can see here.
You may even have to modify the JavaScript code in that web page to replace the "print" button function with a custom JavaScript extension registered with CEF3. That extension would send a message to the main browser process to print using your custom function.
Related
I have pdf file which I need to print.
I use PrintingService for blazor, but it call dialog for printing. How I can not show this or post confirm answer programly?
I can print out using the "window.print" command with javascript, but when I run my web application with webview, this command does not work. I searched for a long time and learned that javascript functions such as print or file are not allowed in webview applications, so I started to search for an alternative way, for example, adding an android button to the field I want to print out. . When I click on this button, I want to be able to output the div whose id I specified and its contents, of course, the css & styles applied to those divs should also appear in the output.
I am updating an old application, and have been asked to change the old Print routine (which just invoked the print command via javascript, and printed out the html), to one that prints out a pdf (the theory being that we then have more control of the pdf / how it looks etc across all printers.)
Using the Rotativa library, I can generate my pdf's, either on the fly or to a file.
After doing some reading, it appears impossible to stream a pdf from memory, and it has to be created as a file first, sent to the browser, and then deleted.)
the last line of my controller is;
return File(#"D:\Development\Source\Workspaces\ConsumerCreditLicenseSystem\Code\ConsumerCreditSystem\CCLSystem\_Idd\1.pdf", "application/pdf");
What I am strugglign with is getting that page to invoke the Print Dialog. If I send it to a new view with javascript to do this, then I am back to square one as the page is html not my pdf. Is there any way I can mark that my pdf is for printing, or combine it with some html so I can have the old faithful of
window.print();
in the document?
A PDF is not a webpage; it's a binary. When you send the PDF as a response to the user, you have no control over what happens on their end. If their browser is capable of viewing a PDF in place, it will display it; otherwise, it will prompt the user to download it. Either way, it will be up to the user whether they want to print it or not, and it will also be up to them to go back or whatever. You cannot redirect the user automatically at this point.
A slightly better option would be to redirect the user to another page, with a link to a view that will send the PDF down to them. Then, you can do things like force the PDF to download (so it's not rendered inside the same tab/window, effectively taking the user away from your site), or force the link to open in a new tab or window. However, you still will not be able to prompt the user to print.
I have an app written in Lua with wxLua. While this app is running, I want to be able to send a (large) string to an external program so the user can view the string, search it, etc.
This external program can be notepad, notepad++, etc, or even a browser window, as long as the user can view and search the text.
I can open open an editor using
local handle = io.popen("notepad", "w") -- for example
but then
handle:write (myString)
doesn't show anything in the editor. And notepad++ doesn't even open a new window if I already have it running.
I can launch a browser using
wx.wxLaunchDefaultBrowser ("http://stackoverflow.com")
but I don't know how to pass the (100-200kb) string to the browser window.
Any help is very much appreciated, thank you!
Stomp
Print out text or HTML file and then open it in browser with wx.wxLaunchDefaultBrowser ("file://path/to/file") or use os.execute to run external editor with same file as argument.
See Oleg's post for the best solution, IMO.
Another solution would be to place your text on the clipboard, so the user could paste it wherever they like.
As for injecting text into apps that are already open, that's non-trivial and beyond the scope of what you can do with wxLua. You'd need to use COM interfaces or traverse the apps' control structures using Win32 API calls or something equally hairy and often app-specific.
I have a simple C# utility that invokes PDFSharp to send a PDF file to a printer. However, it seems to behave inconsistently on a Windows 7 machine. Here's the code
PdfFilePrinter.AdobeReaderPath = "C:\\Program Files\\Adobe\\Reader 10.0\\Reader\\AcroRd32.exe";
PdfFilePrinter printer = new PdfFilePrinter(fileToPrint, printerName);
try
{
printer.Print();
When testing I launch the utility from the command line several times in a row processing a bunch of PDF files one file at a time. During some of these runs, a small Adobe window pops up. I don't have a link to what it looks like but it's a window with standard Adobe Reader X menus, a "Open a recent file" list on bottom left and "Acrobat.com services" on bottom right. Unless I manually close this window, printer.Print(); will never complete, which is a problem since I need to batch process hundreds of files at a time.
When this happens seems to be random. Sometimes it happens when the 1st test file is being processed and sometimes it's the 5th or the 7th.
How can I either ensure that this window does not appear or suppress it automatically if it does?
Any chance your printer supports PDF natively? If so, you could just send it directly to the printer either via LPR/RAW 9100 or through a Windows print queue: How to send raw data to a printer