Click to See Complete Forum and Search --> : How to print a file on C:\
Dr. Possible
08-13-2003, 02:37 PM
Hello,
I was wondering if anyone could help me print a file on the C drive when a hyperlink is clicked.
I have a Word document called "C:\Test.doc" and I am able to open it in Internet Explorer when I click on a link, but I was wondering if I could print it also.
For instance, maybe open it up real quick, print it, and then close it again. Or if it's possible, just print it without opening it. Also, if I could skip the Print Common Dialog box, it would be even better. :D
So if anyone could give me some code to print this, I would be very greatful.
Thanks,
Matt.
Khalid Ali
08-13-2003, 05:29 PM
1. if you are on your own machine then you'll be able to do this,from the internet you will not be able to do this anyway.
2. The document must be open in a window or frame to be printed.
megavogel
08-14-2003, 06:22 AM
Dear ...
Printing is in fact an easy to do thing but keep in minde, that if you use another window (ie, nc, ...) you need to be able to address that window for printing. In a matter of compatibility you need to define that all users are using the same platform (operating system). You also need to make sure, that the browser you are using does support to display the documents you wanna print (plug-in). If you do not have display in browser support, you will get the normal download (save,open) dialoge and printing is not possible. In fact I was thinking to implement such a thing for MAC users to be able just to print a standard html output. But haven't found a solution for that platform. Windows users have no problem with printing but MAC?? I still wonder if there is one!
Hope my post did ******** some issues :)
Regards
Dan
Dr. Possible
08-14-2003, 06:42 AM
Thanks for the input, both of you.
It's true that I am using the latest MS Internet Explorer and that I have the corret plug-ins for the documents I am trying to open (I.E.: .doc, .ppt, .xls, .pdf all open inside the IE browser).
Also, I am using MS Windows and the files are going to be on an accessable local network drive (I.E.: not on the Web). I just use "C:\Test.doc" as an example file because if I can get it to work with that, I'll be able to do it on the network drive also.
I can make MS Internet Explorer access the documents via text hyperlink. Now I need to be able to print them.
Can anybody please post some example code that shows how to do this? I have no experience with JavaScript what-so-ever, though I believe I know where to place the head and body code when I get it.
Basically I need the code to Open, Print, and Close a document as quick as is reasonably possible.
I would appreciate any healp I can get on this topic.
Thanks-a-million,
Matthew.
megavogel
08-14-2003, 06:48 AM
Okey...
Give me a few minutes and I post an example for you!
Dan
Dr. Possible
08-14-2003, 06:50 AM
Thank you megavogel,
I await with bated breath, LOL
Matthew
Charles
08-14-2003, 06:52 AM
Originally posted by Dr. Possible
I await with bated breath, As do I. I do not believe that you can do this with JavaScript, you'll have to use some MSIE specific scriptig.
Dr. Possible
08-14-2003, 06:56 AM
JavaScript, MSIE specific scripting. LOL! Whatever it takes, I dont' mind. As long as I can get it to work.
Matthew
megavogel
08-14-2003, 08:41 AM
HI it's me again.
And the post prior is absolutly right. I tried now everything
possible with JavaScript / VBScript in it's standard functions.
The only way to make it possible is to use IE specific code
that loads an object representing Word.Basic . There you
get functions available like PrintFile() and so on. But to
do that I had not enough time. I am sure if you look
thru some VB ASP Sources you will find a script doing that
job for you.
In javascript I found out that only the current window
is printed. Even I tried to reference different frames
and call form frame1 to print frame2. It always ended up
in printing the frame I called the function.
But here another idea. Why you don't open a window with
the necessary menu's where a print button is included and
the user can descide if he wanna print that window or not.
Otherwise let them open word as an application and they
are able to manage the document as usualy within the
application.
I am sorry, that this is as much as possible by technology
and my time was spent to just make sure it is not possible
with javascript.
Hope that you get some solution or ideas working.
Regards
Dan
Khalid Ali
08-14-2003, 08:45 AM
the most possible solution will be to opena document prgamatically using
window.open()
and in child windows onload event call printing command
window.print()
this will bringup the print dialogue..and thats about it..it is as far as you can go with JavaScript.
You can print frames or windows whichever you like.
Dr. Possible
08-14-2003, 08:48 AM
Dan,
I really do appreciate your effort. You went way above the call of duty in this case.
I guess I will gave to just accept the possibility that printing a document can't be done in JavaScript.
In any case, thank you so much for trying.
Sincerely,
Matthew
megavogel
08-14-2003, 08:53 AM
HI there
here are the files I tried out all elements.
you will get it running copy the hole bunch
into C:\temp
start the local file test.html to beginn.
Regards
Dan
Dr. Possible
08-14-2003, 08:53 AM
Khalid,
That is another interesting alternitave: opening it in the same window and then printing it.
But do you think there is a way to go right back to the previous page?
Also, if I were to use the window.open() and window.print() commands, where would I put them... err, could you give me an example?
Thanks,
Matt
megavogel
08-14-2003, 08:56 AM
HI Mat..
You have to know, that if you open a word document within
a new window, you will lose the state and everything referenced to the window. Because word viewer is taking
over and the window is not existing at all. You can make
sure that this is true. Open a window from another window,
load the word document as the url and then try to close
that window with a link from the window you just opened
the document. As far as you don't display any other content
than HTML you are not able to close it from another windows
even this one is the opener the the main of it's child window.
Dan
Dr. Possible
08-14-2003, 09:00 AM
Dan,
That stuff sent is, to me, really amazing!
I had no idea you could do that with the frame loading the file, but the rest of the window not changing.
I will try to look at the source and check out how it works.
Thanks allot,
Matthew
megavogel
08-14-2003, 09:08 AM
Mat...
No problems... any time !
Cheers
Dan