logo       

Re: How to print a word document automatically from a web browser: msg#00102

windows.devel.dotnet.web

Subject: Re: How to print a word document automatically from a web browser

Thank you very much!!

It works very well!!

Massimo.

> -----Original Message-----
> From: Discussion of building .NET applications targeted for the Web
> [mailto:DOTNET-WEB@xxxxxxxxxxxxxxxxxxx] On Behalf Of Rajasekhara,
> Chidananda (Cognizant)
> Sent: Friday, 21 January, 2005 05:09 AM
> To: DOTNET-WEB@xxxxxxxxxxxxxxxxxxx
> Subject: Re: [DOTNET-WEB] How to print a word document automatically
from
> a web browser
>
> You can use the web browser control to print the word document:
> Sample code snippet given here (not complete for validations) - you
can
> open a blank aspx page passing the required params (either through
> session or other ways) and call printFiles() method onload of the aspx
> page (<body onload=printFiles()). This works.
>
> Note that this works on activex object of internet explorer. If the
> activex is enabled, you wouldn't even get the print dialog.
>
> Hope this helps!
>
> >>
> <script language=javascript>
> <!--
> var sFiles = new Array(<%=sFileList%>);
> var iPrintIndex = 0;
> function printFiles()
> {
>
> if(iPrintIndex < sFiles.length)
>
> {
>
> if(IsActiveXEnabled())
> {
>
>
> printFile(sFiles[iPrintIndex],"Window" + iPrintIndex);
> }
> else
> {
>
> alert("activex not
> enabled");
> window.close();
> }
> }
> else
> {
> window.close();
> }
> }
>
>
> function printFile(fileUrl,winName)
> {
>
>
>
>
newWindow=window.open('',winName,'toolbar=no,scrollbars=no,width=200,hei
> ght=150') ;
> newWindow.document.open("text/html",
> "replace");
>
>
>
> newWindow.document.writeln("<HTML><HEAD><link rel=alternate
media=print
> href='" + fileUrl + "'>");
> newWindow.document.writeln("<OBJECT
> ID=\"x\" WIDTH=0 HEIGHT=0
> CLASSID=\"CLSID:8856F961-340A-11D0-A96B-00C04FD705A2\"></OBJECT>");
> newWindow.document.writeln("<script
> language=javascript>");
>
> newWindow.document.writeln("function
> printDocs(){");
>
>
> newWindow.document.writeln("x.ExecWB(6,true);");
>
newWindow.document.writeln("x.outerHTML
> = '';}");
>
>
>
> newWindow.document.writeln("setTimeout('close()',15000);");
>
>
> newWindow.document.writeln("</script></HEAD>");
>
>
> newWindow.document.writeln("<body><form>");
>
>
> newWindow.document.writeln("</form></BODY></HTML>");
> newWindow.printDocs();
>
> iPrintIndex++;
> setTimeout('printFiles()',15000);
>
> }
>
>
>
> function IsActiveXEnabled()
> {
> try
> {
> var ieApp = new
> ActiveXObject("InternetExplorer.Application");
> }catch(err)
> {
> return false;
> }
> return true;
> }
>
>
>
>
>
> //-->
> </script>
>
> >>
> -----Original Message-----
> From: Discussion of building .NET applications targeted for the Web
> [mailto:DOTNET-WEB@xxxxxxxxxxxxxxxxxxx] On Behalf Of SMART -
Castellacci
> Massimo
> Sent: Thursday, January 20, 2005 11:22 PM
> To: DOTNET-WEB@xxxxxxxxxxxxxxxxxxx
> Subject: Re: [DOTNET-WEB] How to print a word document automatically
> from a web browser
>
> The question is right and it will be an installation requisite.
>
> But i am testing the application on my PC, and I expressly activated
the
> macros. In fact if I open the document directly from disk, word prints
> the document automatically.
>
> I think it's a security constraint from Internet Expolorer.
>
> Thanks.
>
> Massimo.
>
> > -----Original Message-----
> > From: Discussion of building .NET applications targeted for the Web
>
> > [mailto:DOTNET-WEB@xxxxxxxxxxxxxxxxxxx] On Behalf Of Stoyan Damov
> > Sent: Thursday, 20 January, 2005 06:28 PM
> > To: DOTNET-WEB@xxxxxxxxxxxxxxxxxxx
> > Subject: Re: [DOTNET-WEB] How to print a word document automatically
> from
> > a web browser
> >
>
> > This might sound very dumb to you, but are you sure that the client
>
> > computer's Word application allows macros?
> >
>
> > Cheers,
> > Stoyan
> >
>
> > On Thu, 20 Jan 2005 18:17:20 +0100, SMART - Castellacci Massimo
>
> > <m.castellacci@xxxxxxxxxxxxx> wrote:
> > > Hi to all,
> > >
> > > A web application must load a word document from the server, send
it
> to
> > > the client browser and print it automatically when it appears.
> > >
> > > I am not able to print the word document automatically. I inserted
a
>
> > > word macro inside the document on Document_Open event with a
> PrintOut
> > > command. If I open the document directly from the server,
>
> > > double-clicking it, the document is opened and printed
> automatically,
> > > but the same doesn't happen when the document is open from the
> browser.
> > >
> > > Any suggestions?
> > >
> > > Thank you very much.
> > >
> > > Massimo.
> > >
> > > ===================================
> > > This list is hosted by DevelopMentor(r) http://www.develop.com
> > >
> > > View archives and manage your subscription(s) at
> > http://discuss.develop.com
> > >
> >
>
> >
>
> > --
> > Cheers,
> >
>
> > Stoyan
> >
>
> > ===================================
> > This list is hosted by DevelopMentor(r) http://www.develop.com
> >
>
> > View archives and manage your subscription(s) at
>
> > http://discuss.develop.com
>
> ===================================
> This list is hosted by DevelopMentor(r) http://www.develop.com
>
> View archives and manage your subscription(s) at
> http://discuss.develop.com
>
> This e-mail and any files transmitted with it are for the sole use of
the
> intended recipient(s) and may contain confidential and privileged
> information.
> If you are not the intended recipient, please contact the sender by
reply
> e-mail and destroy all copies of the original message.
>
> Any unauthorised review, use, disclosure, dissemination, forwarding,
> printing or copying of this email or any action taken in reliance on
this
> e-mail is strictly
>
> prohibited and may be unlawful.
>
> ===================================
> This list is hosted by DevelopMentor(r) http://www.develop.com
>
> View archives and manage your subscription(s) at
> http://discuss.develop.com

===================================
This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise