Link to home
Start Free TrialLog in
Avatar of jeffmace
jeffmace

asked on

Print PDF/HTML page by hidden frame or no window at all????

Is there a way to print a PDF document without opening a window or even printing a page without seeing it on the screen if a user clicks a button.  Right now I am generating certificates in a PDF form.  I would like to know if there is a way that when a user clicks a button that says Print Certificate, that it can send the generated PDF straight to the printer without opening acrobat or seeing the window.

If all else fails maybe just have acrobat open and then close automatically.

Another working solution would be to be the same solution but not use the PDF and just print an HTML page, but we do not want to see the URL, Page, Date on the headers and footers of the printed page.

Now if those solutions are not possible, I really wouldn't mind if a user clicks on a button which opens a new window that displays, your page is now being sent to the printer and it would automatically make your page print or ask you to choose your printer.  I guess the page would be in a hidden frame or something.  This would work well, but I am not sure how to make it work.

I look forward to your help and suggestions.

Jeff
Avatar of devic
devic
Flag of Germany image

impossible, you can print only active window.
new window and in new window:
<body onload=window.print()>
>>If all else fails maybe just have acrobat open and then close automatically.
not possible once the acobat document is opened an instance of acrobat reader is initiated and that is a separate program that you cannot access

>>but we do not want to see the URL, Page, Date on the headers and footers of the printed page.
these are client side setting you cannot control them
jeff as has been stated in your CF posting of similar question

-printing is a client side process
      the user will always be prompted if they use a link, window.print(), or file|print to print a window's contents, the only exception is the print icon, but this prints to the systems default browser

jeff perhaps the best solution for this is to gather the info you want to print on the certificate, save the info to your db, then using crytal reports or access import the data into a preformated report/cr template print and mail the certs
open the page in a popoup that is sent to the background

<script>
function printCert(){
win=window.open("cert.pdf","","");
win.blur()
win.document.location="certificate.pdf"
win.blur
win.print()
win.close()
}
</script>
<form>
<input type='button' name='certificate' onclick='printCert()'>
</form>
sorry change win=window.open("cert.pdf","","") to win=window.open("","","")
win=window.open("","","height=100 width=100") is better. I have tested and it seems to work.
here is a test I ran

<script>
function printCert(){
win=window.open("","","width=10 height=10");
win.blur()
win.document.location="http://www.boston.com/globe/acrobat/today.pdf"
win.print()
win.close()
}
</script>

<form>
  <p><input type="button" value="certificate" onclick="printCert()"> </p>
</form>

Avatar of jeffmace
jeffmace

ASKER

GwynforWeb, this is pretty good.. What do you and everyone else think about loading an HTML page into a hidden frame and then printing the hidden frame.  That way the HTML page or even possilbly the PDF can be loaded inside that frame and then print it.  Just not sure how it would work.
I would use what you like the best.  The frameset .htm should be

<frameset rows="0,*">
  <frame name="hidden" scrolling="no" noresize src="http://www.boston.com/globe/acrobat/today.pdf">
  <frame name="main" scrolling="no">
</frameset>

and in main.htm have

<form>
<p><input type="button" value="certificate" onclick="top.hidden.print()"> </p>
</form>
ASKER CERTIFIED SOLUTION
Avatar of GwynforWeb
GwynforWeb
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
change  <frame name="main" scrolling="no">   to  <frame name="main" >
damn it shld be

<frame name="main" src="main.htm">
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
PS: You can ONLY remove headers and footers from html using an activeX like scriptX from http://www.meadroid.com/
mplungjan, this worked fine on a pc but didn't work on a Mac.  All I am really trying to do and I may not have explained this very well is:

1. Have a button/link that says 'Generate Certificate'
2. Have a window pop up that would probably be in some sort of framed situation.  One part of the frame can be the button that says "Print Certificate".  Somewhere on the page will be a hidden frame that has the certifcate loaded and can not be seen by the user.
3. I just can not have people see the certificate on the screen, it basically has to fool them to thinking it has gone directly to the printer. That is why i need it to be in a hidden frame or something.
4. After the user clicks the print button have it go to a page that says activity completed or click here to close window.
Yes you have explained. You are stretching the capabilities of the browsers
1. you cannot print without the print dialog unless you have the scriptX installed on a windows pc and use IE
2. in IE you can try onAfterPrint="location='Activitydone.html'"
3. most browsers suck on Mac
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Split: GwynforWeb {http:#10085492} & mplungjan {http:#10087296}

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jAy
EE Cleanup Volunteer