So, I'm trying to print a QWebEngineView entirely, but give a Preview Dialog, such as QPrintPreviewDialog would be sufficient.
First try was something along these lines:
self.loader = QWebEngineView()
[...]
dialog = QPrintPreviewDialog()
dialog.paintRequested.connect(self.loader.page().print)
dialog.show()
self.loader is also used as the actual view rendered to screen. In this setup I get one page sent to the preview and that is the current view in the window. But not the entire document, which is what I want.
I can simply call self.loader.page().print(), which works (prints everything) but gives me no preview option.
I then tried to be smart by using
self.loader.page().runJavaScript("window.print();")
But that doesn't appear to trigger any reaction whatsoever.
So, how do I get an entire WebView printed with a preview dialog beforehand?
In this case PyQt5/PySide2 would be preferred, but I can understand a regular Qt Solution just fine too.
Related
So the console preview panel at the bottom of the page remembers how big you had it last time you previewed. Usually this is great! But somehow mine is currently maximized, so the only thing that shows up is the Page dropdown at the top of the page (and anything in the console, if I switch between pages and the pages have things that log on load). The rest is just white console. Any idea how to get back the default view where the console is 20% of the bottom of the page? There is no visible dragging bar frame thing anywhere.
I can change my preview to console=0 to be able to use it, but I'd like a way to restore the default position of the panel.
Normally you should be able to hover on the top border of the console panel and resize it as you wish. An icon will appear, similar as in the image below:
Nonetheless, if you are doing your previews on a mobile device such as a tablet, then such thing is not possible to do. Therefore; a hacky way to do it would be to put the following code on the onAttach event handler of the page that is loading:
var splitPanel = widget.root.getElement().parentElement
.parentElement.parentElement.parentElement
.parentElement.parentElement.children[0].children[3];
splitPanel.style.height = "75px";
Nota bene: this is intended to ONLY work in preview
A webpage has links to start a print job on it. Clicking the link initiates a new popup window and then immediately the print dialog is shown. The popup window is not rendered and if I click print, then a blank page is printed. It appears that the print dialog is blocking the popup from rendering the page first. If I cancel the print dialog the popup renders properly but now there is no print dialog.
The behavior is the same when using the CefSharp Winforms example.
Is this something I need to deal with? Can I dismiss the print dialog, let the page render and then call the dialog again?
The TargetURL of the popup is about:blank which does not give me much to go on that it is a print action. How does CefSharp tell you it has been asked to print something?
For people landing here from Google printing seems to be rather limited in CEF still and thus in CefSharp. See General Usage Printing and Silently Printing and also Kiosk Printing for example.
Also there is a PrintToPDF which I have not tried yet.
Looking at how Google Chrome does this it appears it renders the page to a PDF file and then shows this file in a popup/new tab. Of course they have then built their own silent printing as the next step.
Edit
Using cef_binary_3.3683.1920.g9f41a27_windows64_client with
No extra arguments
clicking exactly the same link
a popup window appears
the print window appears
the popup window navigates to display preview of what is to be printed
Print can be clicked to print the information viewed in the popup
Using CEFSharp Master WinForms version
No extra arguments (other than set by the example at startup)
clicking exactly the same link
a popup window appears
the print window appears
the popup window appears blocked and is blank.
Print can be clicked and it prints a beautiful white blank page.
AFTER print window closes the popup window navigates to the information to be printed.
I am writing a simple (ASP.NET) web application for the iPad. It is written and works well however one feature is it serving up PDF files (among others). To do this I used window.open to open the file.
When this is done in Safari, it works perfectly. You click the button, the file opens in a new tab; you can then close the tab to return to the previous web page.
However now running the application in fullscreen mode - i.e. with the appropriate "meta names" set and from a shortcut on the home screen - when you click the button to load the file, it loads fullscreen with no means to get back to the last page.
Because it is a file, not a webpage, I can't put a "Back" button on, and when you press the iPad button it simply closes the whole thing.
I know this has been asked before and I have read a number of similar questions - the closest of which was this:
https://stackoverflow.com/questions/9168236/web-app-hyperlinks
If at all possible, it would be far preferable (thanks to the control library I am using) that the button click is done with javascript - it is not easy to set the link href.
The upshot is I really I just want to create a new window from within a fullscreen iPad web application, or allow the "back" navigation somehow...
Is this possible?
Thanks!
Create an iframe on your page rather than using an window.open and set that as the target.
That way your pdf would open within your existing window.
Use some client side javascript like jQuery to style it like a dialog window.
This might have to be broken down a bit but what i want to do:
I have:
- A List of (sort of) greeting cards.
Each will be printed to a particular size (A4 folded down the longer edge)
I want to:
Generate a list of these cards in HTML with css that puts the tags in their place
which would be rotated 90°.
Ideally i'd want to print the list of cards without ever seeing their HTML.
And without print dialog, but would want a modal confirmation dialog after printing where user input confirms they printed correctly.
So my questions are:
Assuming divs for each card, do i just to rotate in the css and then add pagebreaks after each card to define a new page for printing?
I'm really having trouble with the css, do you recommend any good resources for this?
Do I need to specify page size or if the particular size paper is in the printer will the printer print proportionally?
How can I print without browser's print dialog This is answered
How can I catch when the printing job is finished?
Would I be better off with using some PDF library?
3. How can I print without browser's print dialog.
This is not possible. Any browser shouldn't allow this. All you can do is to open print dialog from Javascript but user has to confirm.
Of course you can generate PDF but this requires user to print this PDF manully (clicking print button).
When i use flexprintjob in Flex,it always popup a printing dialog which is printing driver.How can i skip this dialog and print directly?
I think it is not possible with any web tech.
please refer the FlexPrintJob. The FlexPrintJob class causes the operating system to display a Print dialog box. You cannot print without some user action. which is given as a note.