I'm a newbie with JavaScript and I was looking for a method to print a pdf document with a button click without any dialog window opening or not make the user able to change the print settings, I want to print it with a fixed printer, number of pages and format.
I already tried Print.js but it still opens a dialog window and the user can change the settings in it.
The browser does not allow it to print automatically without the user being able to choose the settings to print. This would be extremely problematic as someone can print endless pages without the users permission
Related
I can see a pdf.js document in a digital viewer. Is it possible to print it without seeing a print button or the hotkey?
If I print with the browser function of printing, its just that one page, that I see.
I need it without the whole border stuff, just like the pdf and every page, not just what I see.
If I could have access to the original pdf somehow, this would be fine too.
Extension in FFox enabled right click again and then I could print the iframe to pdf
Currently, I'm developing an Firefox extension app. It will open a html file in a new popup window. When the poup window opened, it shows the title as format: "moz-extensions://", does anyone know how can I remove the prefix, the "moz-extension://"?
Thank you very much!
Answer
According to this bug report you can't currently do anything about it. It is present to prevent spoofing/phishing attacks against the user (acting like the popup is part of a UI).
Statement (Quote):
We've been trying to make it clear that when something happens, the
reason for it is clear to the end user. The ability to create a popup
with no URL bar means that there could be absolutely no info to the
user.
Custom Solution
If you want to have a popup with a custom title you would be better off creating your own HTML/CSS solution!
I needed to Hide the 'Open in New Window' button from the google viewer while i open my page using Iframe. (Button as extreme right side on top)
for ex.
https://docs.google.com/gview?url=http://infolab.stanford.edu/pub/papers/google.pdf&embedded=true
actualy I dont want user to download the actual pdf file.
Isthere any way to acheive this?
Many Thanks in advance
If that's the sample URL that you're opening from YOUR site in iframe (in other words, if you're framing a page from external site), there is NO way to do what you want. It will NOT be possible to access that frame's content from your page (security issues).
Google controls the content on their site, and there's nothing you can do beyond hosting your PDF's somewhere else and controlling the file-download (you still won't be able to show PDF content and prevent the user from copying it to their disk).
I wonder what your concern/reason is for preventing the user from saving the file to their disk...
It's very simple! just click on OPEN IN NEW WINDOW and in the new windows click on file and click of "prevent viewers from downloading". You must logged on your google account.
Copy and paste this line of code into your address bar and hit enter:
javascript:function a() {document.getElementById('openInViewerButtonIcon').style.display = 'none';} a();
It hides the button via JavaScript, setting the display css attribute to none. You could try to load the page in a Frame, making it possible to inject your on javascript.
I have a requirement where I need to print a specific word document when I click on a button in IE8/IE9. I tried to find a way using ExecWB and other methods but could not achieve my goal. Couple of constraints I have are as follows.
The word document is availble through URL and this URL is from a different site than the page where I am clicking the button to print (XSS considerations ?)
I need to directly print using default printer without popping up the print dialog.
Is this possible in anyway?
Impossible from within the context of HTML page, without a custom browser extension. Word document must open before it's printed (maybe not visually presented to the user upon opening, but MS Word or some other application that is capable of opening word docs must be installed on the client system. There is Office extension for IE, which can be used to open the document, but the user has to click on the print button to invoke the dialog. There's nothing that you can do from within javascript to accomplish that. I'm sure you could, if you wrote your own IE extension/plugin, but unless your users are corporate that must install it, nobody else will.
I hope I'm not lying to you.
I have this script on my html page:
<script language='javascript'>parent.resizeTo(550,510);</script>
I'd like to add to it so it positions the window in the middle of the screen. Also, I want to remove the address and tool bars (I've managed to hide the scrollbars by using body{overflow:hidden;}).
I know how to do this using JS upon opening a new window from the browser but this needs to work from clicking a link on a PDF.
Does anyone have any suggestions? Thank you!
You can't remove address bars, etc. from the user's browser window (even if the user is only you) unless you create a new window object. And the trend is toward removing more and more of your ability to "customize" such popup windows, for security reasons.
This is actually a feature, not a bug. Think about it.
If you're opening a browser window from a separate application, the page starts off its life with a completely-decorated browser window. There's no way to make those decorations go away after the page is loaded.
While I seriously doubt the justification of your desires the way to do it is to somehow open a window. That means that your pdf links to a page that as its action will open a window with an url that has the actual content. The pdf links to a page that is basically a redirector. You give the final URL as a parameter and launch it. Of course you need to disable the popup blocker for this to work, but you should not even consider doing this on a public (no browser control) website anyway. You also might want to add to the redirector page a button that the user can click to open the page if it was blocked by the popup blocker.