Printing pdf without opening - pdf

I want to open a PDF-print dialog (not regular browser dialog) without visually opening the document so that I can print a pdf without having the header and footer information from a regular webpage print.
I know this is possible, because I have seen it in the past on a postal service website for printing postage labels, but cannot remember where.
As far as I know, printing it from an iframe doesnt work, as it only opens regular browser print dialog and gives me ugly page and url information:
frames['name'].focus();
frames['name'].print();

I found this:
http://www.fpdf.org/en/script/script36.php
I embedded that in an invisible iframe. It prints onload, and the PDF stays invisible.

Related

Disallow users to download, save or print document shown in an iframe

I'm showing pdf document in an iframe. The pdf resides in the same domain. I don't want to allow users to download, save or print the document.
I've removed Print and Download option from the top toolbar by applying CSS but still user can save or print the document on right click. I tried disabling right click using below code but it's not working on the iframe.
document.addEventListener('contextmenu', event => event.preventDefault());
Is there any way to disallow users to download, save or print document shown in an iframe? Any help will be appreciated.

MVC print PDF without displaying in view with print dialog

I have an MVC app where the intention is for the the user to click Print, and in the subsequent print dialog, verify the target printer, number of copies, etc, and click Print. I'm rendering the PDF document and returning the document thusly:
return File(printJob.Bytes, "application/pdf");
This displays the document quite nicely in the browser. In both Chrome and Edge, when the user clicks Print, they get a preview of the page in the print dialog. So the user experience is they click Print, see a preview, click print, see a preview again and then click print. Does anyone know if it's possible to render the PDF document without displaying it in the browser and instead just present the user with the print dialog box?
Thx in advance!
When you return the PDF from your website, the browser is then acting as a PDF viewer instead of a web browser, so you need to get the PDF to request the print dialog on open, not the website.
You can achieve this by adding the document javascript this.print(true) into the PDF that you are generating.
You can test this in Adobe Acrobat by going to Javascript -> Edit All Javascripts and just pasting this.print(true) at the top outside of any named function.
Tested and working on Chrome, as soon as you open the PDF it displays the print dialog.
Acrobat Javascript Reference is here, the reference to the print function is on page 179.

Safari do not print Check Form properly where as Chrome does

When I print any Check Form, it opens as a PDF in the browser. It prints OK from Chrome but when I print it using Safari on MAC, it prints the same Check Form into two pages.
However, when I select the PDF or click on Check Form PDF and then print the Check Form using Safari, then it prints on single page, same like it prints from Chrome.
Any idea if there is any settings needs to be done in Safari for printing. Please suggest.
For printing always use PDF format if precise format matching is required:
On the workstation where it prints correctly, open the PDF and go into the print page setup then take note of all page settings, paper size, margins etc.. ask your technician to access page setup if you can't:
Be wary of any settings in page setup that attempts to resize the PDF before sending it to the printer:
Configure page setup (sometimes called print option) on Safari browser and macOS to match those that print successfully.
Links below are good starting points but actual configuration is dependent on OS and browser version. It's also out of scope of StackOverflow because it isn't a programming question. If you need help on configuring printers in Safari/MacOS and don't have a technician to do it, it would be better you ask on another stackexchange site, perhaps SuperUser would be the most appropriate:
https://support.apple.com/kb/ph25622?locale=en_US
https://support.apple.com/kb/PH21472?locale=en_US

Is it possible to have a hyperlink open in a new tab that is inside a pdf that is inside of a frame in classic asp?

I Have a classic asp site i am working on. The page has two frames one directly below the other. A Customer has to be able to view a pdf to continue onto the next page. To get to the next page they have to click on a hyper link inside of the pdf that is being viewed. If they cannot see the pdf then they have to download adobe reader which i have included a link to in the top frame.(The top frame has some text and the link) now the bottom frame(contains the pdf) this works fine except when i click the link that is in the pdf the page then opens in that same bottom frame that contained the pdf. It needs to be target _blank. Or whatever you would call it to basically either over ride the two frames and just open in the browser or open in a new tab or window which i cant get either to do. This problem is in IE and Firefox but in chrome it over rides the two frames and opens correctly. Is there any way to get this to occur in IE and Firefox?
I've found this resource about your issue:
http://forums.adobe.com/thread/853394
They say there's no target attribute to set. But they think (and i also think) that if you place a :
javascript:window.open('http://yoururl.com');
it should work, always if you can accept the security alert message (Abobe PDF is trying to execute a script... blah blah)
If your continue reading carefully it seems they solved the problem using Adobe scripting inside inDesign
Hope this helps...

Embedded PDF prints off-center

<embed width="100%" height="100%" src="filename.pdf" type="application/pdf">
I can embed a PDF file into a web page using the simple code above. But when I go to print the web page (using CTRL+P), only half the PDF appears on the print preview as it has been off-centred. The same happens on this web page: http://pdfobject.com/examples/simplest-full-window.html.
Here is an example of a 'Print Version' web page where the embedded PDF centres when it is printed (CTRL+P): http://www.bbc.co.uk/food/recipes/our_paella_92328.pdf. This example is also responsive, which is useful as the print appearance remains consistent no matter the size of the browser window.
Firstly how do I centre the embedded PDF upon printing? Secondly, how do I make the embedded PDF responsive?
When you want to print an embedded PDF, you must use the print command from the PDF plugin, not the print command from the web browser.
In the first example the Javascript code loads the PDF plugin and replaces the HTML document with the PDF document. If you hit CTRL+P then the print dialog from Internet Explorer is shown. If you click into the PDF plugin then press CTRL+P, then the print dialog from Adobe PDF plugin is shown.
In second example you open directly the PDF file. In this case the PDF plugin is loaded and activated automatically. No need to click in it. Pressing CTRL+P brings its own print dialog.