Print Hyperlink

G

Guest

I want to link to a word/pdf document and automatically have it print.

In a folder you'd do this by right clicking the file and then selecting
print. Is there a way to do this so I create a hyperlink that says:
"Print Resume" and my one-page-really cool resume that makes me sound like I
know more than I do prints out on my future boss' printer?

This one's a tough one. I'll be impressed if anyone's done it before with
just a hyperlink. Maybe with Java?

Help needed. Thanks again.

-Jacob
 
S

Steve Easton

I don't think it can be done, because to print a PDF file it must be opened in
Acrobat and then the print button on the Acrobat toolbar must be clicked.


--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
........................with a computer
 
P

p c

Besides the technical difficulties, most people, including your
potential boss, would find it annoying.

...PC
 
G

Guest

You know that's twice I've been told about the annoying factor. I simply
don't believe it exists.

But ya'all are great for listening. I'll keep asking around online.
Someone has to have a button on some website that says 'print'

-Jacob
 
G

Guest

I think it can be done Steve. It's just a matter of tellings windows that it
can print the document the same way it prints it within a folder. Right
Click -> Print.

Whether anyone has already figured this out or not yet is a different story.
I might just be stubborn enough to do it.

Thanks for the time though

-Jacob
 
S

Steve Easton

In -line

Jacob_F_Roecker said:
I think it can be done Steve. It's just a matter of tellings windows that it
can print the document the same way it prints it within a folder. Right
Click -> Print.

And therin lies the problem. You can't launch a system command from a web page
due to security restrictions.
Printing a web page that's displayed in a browser, and printing a .pdf file
that lives on a server, are two entirely different / unrelated operations.


When the browser sees the .pdf file extension, it knows that the file has to be
opened in Acrobat.
The only way to print a .pdf file is by clicking the print icon in Acrobat.

View the following registry keys:

HKEY_CLASSES_ROOT\.pdf
HKEY_CLASSES_ROOT\.pdf\OpenWithList
HKEY_CLASSES_ROOT\.pdf\OpenWithList\AcroRd32.exe

When the system sees the .pdf extension it checks the registry for instructions
on what to do. The entries in the registry tell the system to open the file in
Adobe Acrobat Reader.

You can not circumvent that from a browser / web page, nor can you print a .pdf
file without first opening it in Adobe.
It simply can not be done because that's the way Adobe is written and how it
programs the OS when it is installed.

Whether anyone has already figured this out or not yet is a different story.
I might just be stubborn enough to do it.

You might be able to write a program using visual studio, that could be
downloaded and installed on a computer, that would automatically print a .pdf
file,
but you would have to convince people to download and install it.

It would have to be written to open the file in a hidden adobe window, and then
you would have to figure out how to fire the print command,
which could be done using an API call to an either AcroRd32.exe or an associated
adobe .dll file.

Unfortunately the API calls for Adobe are not published anywhere.

Here's an example of an API call written in Visual Studio to open a file in
notepad:

First you need a module to call the windows shell:

Option Explicit

Public Declare Function ShellExecute Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpszOp As _
String, ByVal lpszFile As String, ByVal lpszParams As String, _
ByVal lpszDir As String, ByVal FsShowCmd As Long) As Long

Then you need another module to handle any possible errors:

Option Explicit
Public Declare Function GetDesktopWindow Lib "user32" () As Long
Const SW_SHOWNORMAL = 1
Const SE_ERR_FNF = 2&
Const SE_ERR_PNF = 3&
Const SE_ERR_ACCESSDENIED = 5&
Const SE_ERR_OOM = 8&
Const SE_ERR_DLLNOtfOUND = 32&
Const SE_ERR_SHARE = 26&
Const SE_ERR_ASSOCINCOMPLETE = 27&
Const SE_ERR_DDETIMEOUT = 28&
Const SE_ERR_DDEFAIL = 29&
Const SE_ERR_DDEBUSY = 30&
Const SE_ERR_NOASSOC = 31&
Const ERROR_BAD_FORMAT = 11&


Then you need to fire a command to call a function:

Private Sub Command1_Click() 'open notepad file button
Dim r As Long, Msg As String
r = StartDoc("mynotepadfile.txt")
If r <= 32 Then
'There was an error
Select Case r
Case SE_ERR_FNF
Msg = "File not found"
Case SE_ERR_PNF
Msg = "Path not found"
Case SE_ERR_ACCESSDENIED
Msg = "Access denied"
Case SE_ERR_OOM
Msg = "Out of memory"
Case SE_ERR_DLLNOtfOUND
Msg = "DLL not found"
Case SE_ERR_SHARE
Msg = "A sharing violation occurred"
Case SE_ERR_ASSOCINCOMPLETE
Msg = "Incomplete or invalid file association"
Case SE_ERR_DDETIMEOUT
Msg = "DDE Time out"
Case SE_ERR_DDEFAIL
Msg = "DDE transaction failed"
Case SE_ERR_DDEBUSY
Msg = "DDE busy"
Case SE_ERR_NOASSOC
Msg = "No association for file extension"
Case ERROR_BAD_FORMAT
Msg = "Invalid EXE file or error in EXE image"
Case Else
Msg = "Unknown Error"
End Select
MsgBox Msg

End If

End Sub



Then you need the actual function which calls the shell32.dll module posted
above:

Public Function StartDoc(DocName As String) As Long
Dim Scr_hDC As Long
Scr_hDC = GetDesktopWindow()
StartDoc = ShellExecute(Me.hwnd, "open", "NOTEPAD.EXE", "",
"C:/path/to/file", 10)

End Function


And then this all has to be compiled in to an .exe file to be downloaded and
installed by the user.


I wish you luck.

--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
........................with a computer
 
A

Andrew Murray

Having a button that says "print"? Your original post stated you wanted it
to open a PDF file and printt "automatically" which is a different issue.

Do you mean something like this

<input type="button" value="Print" onclick="print.this();"> this is used if
you want to print a html page.

It won't work for PDF. To print a PDF, use the Print command within Adobe
Acrobat/Acrobat Reader.
 
B

Brian Mailman

I'd find it kind of invasive if I opened an email and my printer started
going.... and I'm sure spammers would love to know the technique as well.

Then again, that would be using a printer as a fax and there's laws....

B/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top