Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing a .pdf file

Status
Not open for further replies.

cooldisk2005

Technical User
Aug 3, 2005
119
US
Hi All,
Does anyone know how to print a .pdf file automatically using javascript behind a link that is attached to a .pdf file?

Can anyone help me?

Any help is appreciated.

Thanks,
 
You can't control the client's printer. That's a security issue. What would happen if some site you went to could print pages and pages without your permission?

Lee
 
When you say that the link is "attached to" a PDF file, do you mean that you have an HTML page with a link that points to a PDF file, or do you mean you have a PDF file with a link embedded in it?

Given that both are possible, and both HTML pages and PDF files can have scripting embedded in them, you should probably clarify this point.

Dan


[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Yes I have an HTML page with my pdf file attached to a link.

This is what I want.

When a visitor comes to my page and sees the link to the pdf file that reads: Print this pdf file, I would like when the user clicks the link, it will automatically print for him.

I hope this helps. Sorry for not clarifying enough.
 
Probably the best way is to use window.print(). Here are 2 different ways you might use this:
Code:
<a href="javascript:window.print()">Click to print</a>
<input type="button" value="Click to print" onclick="window.print()">
Hope that's what you were thinking of.

Cheers,
Jeff

[tt]Jeff's Page [/tt][tt]@[/tt][tt] Code Couch
[/tt]

What is Javascript? faq216-6094
 
You can embed an Acrobat JavaScript in the PDF document to do this. Ask the question in the Acrobat forum.

Acrobat has its own JavaScript engine and DOM. You can embed JavaScripts in the PDF and attach them to various events, such as "document load". Silent printing to the default printer is possible.

Saying it a different way: we're not talking about HTML or Browser JavaScript.

Thomas D. Greer
 
BabyJeffy,
Yes I knew that one, but I wanted to see if it was possible to print the .pdf file I had attached to the link automatically, instead of opening the .pdf file and printing it, but this will definitely work.

Thank you so much and have a great day!!!
 
Thanks Thomas for jarring my memory. I forgot all about that!!!!, and I have actually done it before, but it has been so long ago, and I'm getting so old at 39yrs of age:):):)

I will try that out as well.

Thanks so much
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top