Hello all,
I'm looking for a compact way to print the contents of a web page. The idea is to automate some user enrollment tasks, part of which is to print some instructions for them. There will some customized info that I'll just bang out to a PrinterCanvas, but, some general stuff is lurking on a web site and can be loaded/printed from a web browser. I have or can find code to run IE and open the page, which is enough. However, have any of you used Automation to get that to happen and then print? It would be really nice to choose the printer and the number of copies while we're at it :) Have a good one, Bill -- Wilhelm K. Schwab, Ph.D. [hidden email] |
Bill,
I took a look at printing directly through Automation to print an IE document. Here's what I came up off the cuff: idispatch := IWebBrowser2 createObject: 'InternetExplorer.Application'. idispatch navigate: 'http://www.object-arts.com/Home.htm'. (Delay forSeconds: 4) wait. doc := idispatch document. doc parentWindow invoke: 'Print'. idispatch free This will bring up a print dialog box just as if the user had pressed File | Print. I stuck the hokey 4 second wait out there because if you don't have a valid document to get, the document call fails. I'm sure there's an event you could set up to notify when the page is loaded. It looks like this is only valid with IE5. (based on what I saw on one of the listed sites) I didn't have to generate any TypeLibrary stuff for IE, just used the IWebBrowser classes. Here are a couple links to MS sites that may help as well. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnie40/html/msdn_lassesen.asp http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnscrpt/html/DHTMLPRINT.asp Eric Bill Schwab wrote: > Hello all, > > I'm looking for a compact way to print the contents of a web page. The idea > is to automate some user enrollment tasks, part of which is to print some > instructions for them. There will some customized info that I'll just bang > out to a PrinterCanvas, but, some general stuff is lurking on a web site and > can be loaded/printed from a web browser. I have or can find code to run IE > and open the page, which is enough. However, have any of you used > Automation to get that to happen and then print? It would be really nice to > choose the printer and the number of copies while we're at it :) > > Have a good one, > > Bill > > -- > Wilhelm K. Schwab, Ph.D. > [hidden email] > > > |
In reply to this post by Bill Schwab-2
Hi, Bill
I use this package for userless printing to default printer. Maybe you take some ideas from there... -- Dmitry Zamotkin "Bill Schwab" <[hidden email]> wrote in message news:9rkg37$u1qbl$[hidden email]... > Hello all, > > I'm looking for a compact way to print the contents of a web page. The idea > is to automate some user enrollment tasks, part of which is to print some > instructions for them. There will some customized info that I'll just bang > out to a PrinterCanvas, but, some general stuff is lurking on a web site and > can be loaded/printed from a web browser. I have or can find code to run IE > and open the page, which is enough. However, have any of you used > Automation to get that to happen and then print? It would be really nice to > choose the printer and the number of copies while we're at it :) > > Have a good one, > > Bill > > -- > Wilhelm K. Schwab, Ph.D. > [hidden email] > > begin 666 IEPrinting.pac M?"!P86-K86=E('P-"G!A8VMA9V4@.CT@4&%C:V%G92!N86UE.B G2450<FEN M=&EN9R<N#0IP86-K86=E('!A>%9E<G-I;VXZ(# [#0H)8F%S:6-#;VUM96YT M.B G5')Y(&ET.@T*#0H)=7)L(#H]("<G:'1T<#HO+W=W=RYO8FIE8W0M87)T M<RYC;VTO2&]M92YH=&TG)RX)#0H):&]S=" Z/2!%>'!L;W)E<D-O;G1R;VQ3 M:71E('5R;#H@=7)L+@T*"6AO<W0@<')I;G0N)RX-"@T*<&%C:V%G92!B87-I M8U!A8VMA9V5697)S:6]N.B G)RX-"@T*(D%D9"!T:&4@<&%C:V%G92!S8W)I M<'1S(@T*#0HB061D('1H92!C;&%S<R!N86UE<RP@;&]O<V4@;65T:&]D(&YA M;65S+"!G;&]B86P@;F%M97,L(')E<V]U<F-E(&YA;65S(@T*<&%C:V%G92!C M;&%S<TYA;65S#0H)861D.B C17AP;&]R97)#;VYT<F]L4VET93L-"@EY;W5R M<V5L9BX-"@T*<&%C:V%G92!M971H;V1.86UE<PT*"6%D9#H@(TE796)"<F]W M<V5R,B M/B C:7-296%D>51O4')I;G0[#0H)861D.B C25=E8D)R;W=S97(R M("T^("-P<FEN=#L-"@EA9&0Z("-)5V5B0G)O=W-E<C(@+3X@(W!R:6YT4')E M=FEE=SL-"@EA9&0Z("-54DQ0<F5S96YT97(@+3X@(W!R:6YT.PT*"7EO=7)S M96QF+@T*#0IP86-K86=E(&=L;V)A;$YA;65S#0H)>6]U<G-E;&8N#0H-"G!A M8VMA9V4@<F5S;W5R8V5.86UE<PT*"7EO=7)S96QF+@T*#0HB0FEN87)Y($=L M;V)A;"!.86UE<R(-"G!A8VMA9V4@8FEN87)Y1VQO8F%L3F%M97,Z("A3970@ M;F5W#0H)>6]U<G-E;&8I+@T*(E)E<V]U<F-E($YA;65S(@T*<&%C:V%G92!A M;&Q297-O=7)C94YA;65S.B H4V5T(&YE=PT*"7EO=7)S96QF*2X-"@T*(D%D M9"!T:&4@<')E<F5Q=6ES:71E(&YA;65S(@T*<&%C:V%G92!S9710<F5R97%U M:7-I=&5S.B H261E;G1I='E3970@;F5W#0H)861D.B G06-T:79E6"!#;VYT M<F]L($AO<W1I;F<G.PT*"6%D9#H@)T1O;'!H:6XG.PT*"6%D9#H@)TEN=&5R M;F5T($5X<&QO<F5R)SL-"@EY;W5R<V5L9BDN#0H-"G!A8VMA9V4A#0H-"B)# M;&%S<R!$969I;FET:6]N<R(A#0H-"D%85F%L=65#;VYV97)T:6YG0V]N=')O M;%-I=&4@<W5B8VQA<W,Z("-%>'!L;W)E<D-O;G1R;VQ3:71E#0H):6YS=&%N M8V5687)I86)L94YA;65S.B G)PT*"6-L87-S5F%R:6%B;&5.86UE<SH@)R<- M"@EP;V]L1&EC=&EO;F%R:65S.B G)PT*"6-L87-S26YS=&%N8V5687)I86)L M94YA;65S.B G)R$-"B),;V]S92!-971H;V1S(B$-"@T*(4E796)"<F]W<V5R M,B!M971H;V1S1F]R(0T*#0II<U)E861Y5&]0<FEN= T*#0H)7B H<V5L9B!Q M=65R>5-T871U<U=".B!/3$5#341)1%]04DE.5"D@/2 H3TQ%0TU$1E]355!0 M3U)4140@*R!/3$5#341&7T5.04),140I#0H-"@T*(0T*#0IP<FEN= T*#0H) M<V5L9@T*"0EE>&5C5T(Z($],14--1$E$7U!224Y4#0H)"6-M9&5X96-O<'0Z M($],14--1$5814-/4%1?1$].5%!23TU05%5315(-"@D)<'9A26XZ(&YI; T* M"0EP=F%/=70Z(&YI;"$-"@T*<')I;G10<F5V:65W#0H-"@ES96QF#0H)"65X M96-70CH@3TQ%0TU$241?4%))3E104D562457#0H)"6-M9&5X96-O<'0Z($], M14--1$5814-/4%1?1$].5%!23TU05%5315(-"@D)<'9A26XZ(&YI; T*"0EP M=F%/=70Z(&YI; T*(2 A#0HA25=E8D)R;W=S97(R(&-A=&5G;W)I97-&;W(Z M("-I<U)E861Y5&]0<FEN="$J*F%U=&\@9V5N97)A=&5D*BHA;65T:&]D<R%P M<FEV871E(71E<W1I;F<A("$-"B%)5V5B0G)O=W-E<C(@8V%T96=O<FEE<T9O M<CH@(W!R:6YT(2HM=6YC;&%S<VEF:65D(7!U8FQI8R$@(0T*(4E796)"<F]W M<V5R,B!C871E9V]R:65S1F]R.B C<')I;G10<F5V:65W(2HM=6YC;&%S<VEF M:65D(7!U8FQI8R$@(0T*#0HA55),4')E<V5N=&5R(&UE=&AO9'-&;W(A#0H- M"G!R:6YT#0H-"@E>('-E;&8@=FEE=R!C;VYT<F]L1&ES<&%T8V@@<')I;G0A M("$-"B%54DQ0<F5S96YT97(@8V%T96=O<FEE<T9O<CH@(W!R:6YT(2HM=6YC M;&%S<VEF:65D(7!U8FQI8R$@(0T*#0HB16YD(&]F('!A8VMA9V4@9&5F:6YI M=&EO;B(A#0H-"@T*#0I%>'!L;W)E<D-O;G1R;VQ3:71E(&-O;6UE;G0Z("<G M(0T*#0I%>'!L;W)E<D-O;G1R;VQ3:71E(&=U:60Z("A'54E$(&9R;VU3=')I M;F<Z("=[.44V0D(V134M03<W,2TQ,40U+4)!.$,M,# P.$,W.#E!-#(T?2<I M(0T*#0HA17AP;&]R97)#;VYT<F]L4VET92!C871E9V]R:65S1F]R0VQA<W,A M56YC;&%S<VEF:65D(2 A#0HA17AP;&]R97)#;VYT<F]L4VET92!M971H;V1S M1F]R(0T*#0IP<FEN= T*#0H)6R!S96QF('=A:71&;W)0<FEN=%)E861Y.R!C M;VYT<F]L1&ES<&%T8V@@<')I;G0@72!F;W)K(0T*#0IP<FEN=%1I;65O=70- M"@T*"5X@-C P(0T*#0IW86ET1F]R4')I;G1296%D>0T*"7P@;65T:&]D16YT M97(@? T*#0H);65T:&]D16YT97(@.CT@5&EM95-T86UP(&-U<G)E;G0N#0H- M"@E;('-E;&8@8V]N=')O;$1I<W!A=&-H(&ES4F5A9'E4;U!R:6YT(%T@=VAI M;&5&86QS93H@6PT*"0E0<F]C97-S;W(@>6EE;&0N#0H)"51I;653=&%M<"!C M=7)R96YT("T@;65T:&]D16YT97(@/B!S96QF('!R:6YT5&EM96]U= T*"0D) M:694<G5E.B!;#0H)"0D)365S<V%G94)O>"!E<G)O<DUS9SH@)T-A;B=T('!R M:6YT("<L<V5L9B!V86QU92PG+B!4:6UE;W5T(&5X<&ER960N)RX-"@D)"0E0 M<F]C97-S;W(@86-T:79E4')O8V5S<R!S:'5T9&]W;BX-"@D)"5TN#0H)72XA M("$-"B%%>'!L;W)E<D-O;G1R;VQ3:71E(&-A=&5G;W)I97-&;W(Z("-P<FEN M="%O<&5R871I;VYS(7!R:6YT:6YG(7!U8FQI8R$@(0T*(45X<&QO<F5R0V]N M=')O;%-I=&4@8V%T96=O<FEE<T9O<CH@(W!R:6YT5&EM96]U="%C;VYS=&%N M=',A<')I=F%T92$@(0T*(45X<&QO<F5R0V]N=')O;%-I=&4@8V%T96=O<FEE M<T9O<CH@(W=A:71&;W)0<FEN=%)E861Y(7!R:79A=&4A=&5S=&EN9R$@(0T* M#0HA17AP;&]R97)#;VYT<F]L4VET92!C;&%S<R!M971H;V1S1F]R(0T*#0II M8V]N#0H)7B!)8V]N(&9R;VU)9#H@-#<@:6XZ(%-H96QL3&EB<F%R>2!D969A M=6QT(0T*#0IN97<-"@E>('-U<&5R(&YE=PT*"0EP<F]G260Z("=3:&5L;"Y% M>'!L;W)E<B<[#0H)"6-R96%T92$-"@T*=7)L.B!A4W1R:6YG#0H-"@E>('-E M;&8@;F5W#0H)"6UO9&5L.B!A4W1R:6YG(&%S5F%L=64[#0H)"7EO=7)S96QF M(2 A#0HA17AP;&]R97)#;VYT<F]L4VET92!C;&%S<R!C871E9V]R:65S1F]R M.B C:6-O;B$J+75N8VQA<W-I9FEE9"%P=6)L:6,A("$-"B%%>'!L;W)E<D-O M;G1R;VQ3:71E(&-L87-S(&-A=&5G;W)I97-&;W(Z("-N97<A;V)J96-T(&-R M96%T:6]N(7!U8FQI8R$@(0T*(45X<&QO<F5R0V]N=')O;%-I=&4@8VQA<W,@ M8V%T96=O<FEE<T9O<CH@(W5R;#HA;V)J96-T(&-R96%T:6]N(7!U8FQI8R$@ M(0T*#0H@#0HB0FEN87)Y($=L;V)A;',B(0T*#0HB4F5S;W5R8V5S(B$-"@T* ` end |
In reply to this post by Eric Winger-5
Eric,
I combined your sample with stuff from the simple web browser and have something that waits for the URL to be reached: | urls browser ready | ready := Semaphore new. browser := URLPresenter show. browser when:#NavigateComplete2:URL: send:#signal to:ready. [ #( '1.htm' '2.htm' ) do:[ :url | browser value:url. ready wait. browser view controlDispatch document parentWindow invoke:'Print'. ]. ] forkAt:Processor userBackgroundPriority. Forking it off of the UI thread is essential, at least on the aging (don't ask<g>) box in front of me. It even brings up the print dialog; the dangling issue is that it doesn't yet wait for the print dialog to close, so it makes a few clicking sounds and then finally waits to print the last document in the list. Simply getting the browser open to the correct pages without having to think about it is a big help, and perhaps the best thing to do is to simply open two of them. There's a #busy method in one of the browser control classes, so it might be possible to poll for the printing to be finished. However, for what I'm trying to do to be _really_ idiot proof, it should set the right number of copies to print, which might be asking too much. Thanks! Bill -- Wilhelm K. Schwab, Ph.D. [hidden email] (Keywords: Internet Explorer; Automation, printing) |
FWIW - I print from IE in VA Smalltalk, and the only way to effect things
like headers and footers on the page is to: 1) Read the registry and save prior values 2) Set these values in the Registry to what you want for this print job 3) Print 4) Reset the registry to the prior values. Last I looked (6-12 months), this was actually outlined as the way to do it on MSDN. Sigh! jlo "Bill Schwab" <[hidden email]> wrote in message news:9ruec4$vktgj$[hidden email]... > Eric, > > I combined your sample with stuff from the simple web browser and have > something that waits for the URL to be reached: > > | urls browser ready | > > ready := Semaphore new. > browser := URLPresenter show. > browser when:#NavigateComplete2:URL: send:#signal to:ready. > > [ > #( '1.htm' '2.htm' ) do:[ :url | > browser value:url. > ready wait. > browser view controlDispatch document parentWindow invoke:'Print'. > ]. > > ] forkAt:Processor userBackgroundPriority. > > Forking it off of the UI thread is essential, at least on the aging (don't > ask<g>) box in front of me. It even brings up the print dialog; the > dangling issue is that it doesn't yet wait for the print dialog to close, > it makes a few clicking sounds and then finally waits to print the last > document in the list. Simply getting the browser open to the correct pages > without having to think about it is a big help, and perhaps the best thing > to do is to simply open two of them. There's a #busy method in one of the > browser control classes, so it might be possible to poll for the printing to > be finished. However, for what I'm trying to do to be _really_ idiot proof, > it should set the right number of copies to print, which might be asking too > much. > > Thanks! > > Bill > > -- > Wilhelm K. Schwab, Ph.D. > [hidden email] > > (Keywords: Internet Explorer; Automation, printing) > > > |
Free forum by Nabble | Edit this page |