Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


printing without formfeed

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,40986
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> printing without formfeed
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1] 2   next >   >>
Login
Message << Older Topic   Newer Topic >>
 printing without formfeed - 12/14/2006 4:45:06 AM   
  KALEL

 

Posts: 12
Score: 0
Joined: 12/14/2006
From: Germany, NRW
Status: offline
hello

I'm using the aktiv-x from (http://www.aboutvb.de/vbs/artikel/vbsprinterobj.htm)

it works. :)

my problem is, that after printing there comes a form feed.
is there a possibility to print without formfeed?

in my app i can't print directly, but i can use vbs.
i must print incoming data (ca 5 lines) every some minutes.
in my printer i want to use continuous paper for printing

_____________________________

mfg
KalEL
-----------------------------
sorry my bad english :(
 
 
Post #: 1
 
 RE: printing without formfeed - 12/14/2006 4:47:02 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
I would suspect that the issue is with the ActiveX component itself. Not with VBScript.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to KALEL)
 
 
Post #: 2
 
 RE: printing without formfeed - 12/14/2006 4:56:03 AM   
  KALEL

 

Posts: 12
Score: 0
Joined: 12/14/2006
From: Germany, NRW
Status: offline
Yes
i thing it is so.
but what can i do to avoid this?

is there anybody who have a list of the printer objects?
or, perhaps, can i find this in the vb.net express edition help?



_____________________________

mfg
KalEL
-----------------------------
sorry my bad english :(

(in reply to ebgreen)
 
 
Post #: 3
 
 RE: printing without formfeed - 12/14/2006 5:01:09 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
quote:

but what can i do to avoid this?

You would have to take it up with the author of the ActiveX component.

quote:

is there anybody who have a list of the printer objects?

You can get a list of the printers installed on the machine via WMI, but I'm not sure that is what you are asking for.

quote:

or, perhaps, can i find this in the vb.net express edition help?

If you want to do this in VB.Net instead of VBScript (the two are not the same at all) then you are probably right.

You may try posting your question in German. I believe one of our best members also speaks German.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to KALEL)
 
 
Post #: 4
 
 RE: printing without formfeed - 12/14/2006 5:45:13 AM   
  ehvbs

 

Posts: 2114
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi KALEL,

from the example the author of the component provided I guess you use "[Printer].EndDoc"
after "[Printer].PrintText"ing your 5 lines. If so, postpone the "[Printer].EndDoc" to the (logical)
end of your script. If my assumption is wrong, please post your code.

P.S.
I did't read ebgreen's message, otherwise I'd be too embarrassed/flattered/proud to answer.

(in reply to ebgreen)
 
 
Post #: 5
 
 RE: printing without formfeed - 12/14/2006 6:05:00 AM   
  KALEL

 

Posts: 12
Score: 0
Joined: 12/14/2006
From: Germany, NRW
Status: offline
quote:

.... but I'm not sure that is what you are asking for.
that is not what i meen.

example

      
i meen .currentx, .printtext etc. this are objects of the printer-object. or not?
i thing, there are a lot of more objects inside. but i don't know what.
i'm not very goog in vbs.

quote:

If you want to do this in VB.Net instead of VBScript .................

no. i can't do it in vb.net.

this i find at aboutvb
quote:

In einer Eigenschaft wird die VB-Printers-Sammlung zur Verfügung gestellt, über die alle installierten Drucker ermittelt werden können. In einer zweiten Eigenschaft wird das Printer-Objekt selbst bereitgestellt. Sie können über diese Objekt-Referenz nahezu alles machen, was Sie mit dem Printer-Objekt in VB machen können (soweit der Sprachumfang von VBScript dies ermöglicht) - schließlich ist es ja das originale VB-Printer-Objekt

so i thing that i can find it in the doku of vb.

quote:

You may try posting your question in German.

 great. normaly this were better for me. ;)
but i thing here are more user who speeks english. and additional i learn a lite bit more english.

(in reply to ebgreen)
 
 
Post #: 6
 
 RE: printing without formfeed - 12/14/2006 6:25:17 AM   
  ehvbs

 

Posts: 2114
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi KALEL,

what happens if you remove the ".EndDoc"?

(in reply to KALEL)
 
 
Post #: 7
 
 RE: printing without formfeed - 12/14/2006 6:50:43 AM   
  KALEL

 

Posts: 12
Score: 0
Joined: 12/14/2006
From: Germany, NRW
Status: offline
this i have tasted before i write here.

but the result is the same. :(

EDIT:
i don't must use THIS aktive-x to print iff there is an other possibilty to print.
i have search the internet but this is onlyest what i can find.

< Message edited by KALEL -- 12/14/2006 6:56:39 AM >

(in reply to ehvbs)
 
 
Post #: 8
 
 RE: printing without formfeed - 12/14/2006 7:09:37 AM   
  ehvbs

 

Posts: 2114
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi KALEL,

I admit, I can't test this ActiveX component, but:

    (1) just printing 5 lines can't force the printer to do a formfeed

    (2) the Printer object should do a formfeed when it is destructed -
          either explicitly or when it goes out of scope.

    (3) If you run your (modified) example:

               Set PrinterObj = CreateObject("avbScriptPrinter.PrinterObj")
               Set Printer = PrinterObj.Printer
               With Printer
                    .ScaleMode = 7 ' Zentimeter
                    .CurrentX = 5
                    .CurrentY = 10
                    PrinterObj.PrintText "Hallo!"
            '       .EndDoc       '  disabled
               End With
               MsgBox "Wait a bit!"
               Set Printer = Nothing                     '  <----- Expect formfeed
               Set PrinterObj = Nothing
        
         you should get a formfeed, because of the destruction of those objects.

(in reply to KALEL)
 
 
Post #: 9
 
 RE: printing without formfeed - 12/14/2006 7:29:15 AM   
  KALEL

 

Posts: 12
Score: 0
Joined: 12/14/2006
From: Germany, NRW
Status: offline
i have test your code

the print will activated after i pressed the ok button from the messagebox with a formfeed.


when i enable the line .enddoc in your code, then printing starts directly and don''t wait for ok of the message box.
with formfeed

i think that is not a good sign :(

(in reply to ehvbs)
 
 
Post #: 10
 
 RE: printing without formfeed - 12/14/2006 7:38:39 AM   
  ehvbs

 

Posts: 2114
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi KALEL,

don't despair. What kind of application do you use? How do you call the
VBScript program that does the printing?

(in reply to KALEL)
 
 
Post #: 11
 
 RE: printing without formfeed - 12/14/2006 8:05:34 AM   
  KALEL

 

Posts: 12
Score: 0
Joined: 12/14/2006
From: Germany, NRW
Status: offline
at this time i test it without the extern app.
i start the vbs under winxp.

later the script will run under siemens - protool. this is an software for visualisation industriel prozesses.
but this is not the problem.
in protool i can use the intern vbs or i can start an extern program.

ok. printing with an other extern program for printing is a possibility, but it's not nice.

(in reply to ehvbs)
 
 
Post #: 12
 
 RE: printing without formfeed - 12/14/2006 8:31:00 AM   
  ehvbs

 

Posts: 2114
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi KALEL,

regrettably I'm not familiar with protool. So take my speculations with a grain
of salt:

To avoid the the formfeed caused by the destruction of the printer object(s),
you'll have to Dim them as global variables at the main/highest level of your
code. Then you can use them during the whole session/run to print those
five lines every minute. As long as you don't destroy them explicitly with
     Set oPrinter = Nothing
they live happily and won't feel obliged to send a last formfeed to the printer.

If you are familiar with client side scripting: think of a .HTML page with script
code loaded into the browser. The variables you put at the main level

    Dim goPopup : Set goPopup = window.createPopup()

Or

    var goPopup = window.createPopup();

will stay around to be used in callback/event/timer Subs/Functions until you
close the document.  (I'm sure, TNO could provide further/more lucid
explanations.) Come to think of it - you should be able to test the validity
of my assumptions with an .hta or .html script - give me a moment(*)


Footnote
(*) 'moment' - programmer's speak for 'just to long'

(in reply to KALEL)
 
 
Post #: 13
 
 RE: printing without formfeed - 12/14/2006 8:48:57 AM   
  KALEL

 

Posts: 12
Score: 0
Joined: 12/14/2006
From: Germany, NRW
Status: offline
now i'm not sitting at the pc with the printer.
i will test it tomorrow.

when i understand it right, i must run the script in an endless loop.
this is not goog for my app. the wsh will use many resources.


(in reply to ehvbs)
 
 
Post #: 14
 
 RE: printing without formfeed - 12/14/2006 9:01:53 AM   
  ehvbs

 

Posts: 2114
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi KALEL,

I post the code now


      

but let's talk about it tomorrow.

Until then - and good luck!

ehvbs

(in reply to KALEL)
 
 
Post #: 15
 
 RE: printing without formfeed - 12/15/2006 7:03:40 AM   
  KALEL

 

Posts: 12
Score: 0
Joined: 12/14/2006
From: Germany, NRW
Status: offline
i'm not sure what you want to say me with this html.

but i have test it.
in the htm i can see 2 buttons. print and reload.
when i press the print-b. i get a normaly print with formfeed.
when i press reload nothing will happen.

mfg

(in reply to ehvbs)
 
 
Post #: 16
 
 RE: printing without formfeed - 12/16/2006 7:58:23 AM   
  ehvbs

 

Posts: 2114
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi KALEL,

thank you for testing my script even before I could explain it! I really feel
that's a sign of confidence from your side.

There are three aspects that need further elaboration.

The first concerns how to use the script as it is. It doesn't really matter
whether you saved the code as .HTML (as I assume) or as .HTA (as I intended,
because .HTAs avoid security issues .HTMLs are prone to rise - e.g. silently
not creating ActiveX components). As you obviously could load the script and
use the printer, we are in business/luck.

To be absolutly sure: If you press the "Print" button once, you should get
either

   immediate output of two lines of text on a lineprinter
   no visible reaction on a page printer

but no formfeed whatsoever. Pressing the button again should add text to the
same page, but definitely no formfeed. As soon as you close the document, a
formfeed should be sent. My prediction is based on this law about the behaviour
of a decent printer object:

   A formfeed should be sent, if and only if
     (a) the user asks for it (.EndPage, .EndDoc, printer control code)
     (b) the printer object is destructed
     (c) the - suitably defined - page is full

Your "when i press the print-b. i get a normaly print with formfeed." can
be understood as "each time the button is pressed/text is printed there immediately
follows a formfeed". If that's the case, my prediction is falsified.

To come to second aspect: How the script works (or should work). Let's tackle the
4 points raised (a, b, c, formfeed on each button press) in order:

The script handles (a) in a cavalier way: There is no button/Sub to send
.EndPage or .EndDoc to the printer, so we can be sure, that no formfeed
is caused by (a).

The (b) case is handled in the script by declaring the variables used to
hold the objects at the global (out of Functions or Subs) level of the
script:

    ' Global vars
    Dim PrinterObj
    Dim Printer

and intializing them with:

    Set PrinterObj = CreateObject( "avbScriptPrinter.PrinterObj" )
    Set Printer = PrinterObj.Printer

This way they will 'live' as long as the script stays in memory, the
browser will destruct them just before he?/she?/it? terminates. Each time
the

    Sub PrintIt()
       With Printer
           .ScaleMode = 7 ' Zentimeter
           .CurrentX  = 5
           .CurrentY  = 10
         PrinterObj.PrintText "Hallo!"
           .CurrentX  = 5
         PrinterObj.PrintText "Ist da jemand?"
       End With
    End Sub

is called, it will use the same objects. Contrast this with a Sub like
this:

    Sub PrintIt_destructive()
       Dim PrinterObjLocal : Set PrinterObjLocal = CreateObject( "avbScriptPrinter.PrinterObj" )
       Dim PrinterLocal    : Set PrinterLocal    = PrinterObjLocal.Printer
       With PrinterLocal
           .ScaleMode = 7 ' Zentimeter
           .CurrentX  = 5
           .CurrentY  = 10
         PrinterObjLocal.PrintText "Hallo!"
           .CurrentX  = 5
         PrinterObjLocal.PrintText "Ist da jemand?"
       End With
    End Sub

Those local objects will go out of scope and be destroyed at the end of (each
call of) the Sub. Such a Sub should lead to the behaviour you complained
about in your first posting: Just printing same text will cause a formfeed
(by destruction).

At a first glance (c) can be done with in a short way like a: As long as
you don't press the Print button as often as to fill a whole page there
shouldn't be any formfeed from the script.

But if my prediction is wrong (each press causes output and formfeed; the fourth
case at last) than we at least know: The Sub PrintIt() must be the culprit, it
must - somehow - 'flood the page'.

While setting .CurrentX = 5 looks innocent enough, setting the .ScaleMode
(to the same value) each time you print a line, may cause a very dump printer
driver to give up on this page and start a new one with a (presumably) new
.ScaleMode. But shouldn't that cause a page break before the text is printed on
the new page? I do think so.

Next suspect: Setting .CurrentY = 10.

   Hey - shouldn't that cause each print to start at a top margin of 10 cm?
   Hey - aren't you using a lineprinter ("in my printer i want to use continuous
         paper for printing")?
   Hey - how could this poor beast move up to 10 cm if the last print caused
         it to move to 10 + LineHeight + LineHight cm?
         [ I know my old NEC C 90 from the last century could do that - if
           programmed in a very special way; and there were many older Brothers and
           cousins of him which couldn't
         ]
         The hypothesis, that your printer/printer driver/activex componentent
         will 'keep it simple' and just issue a formfeed if you try to print
         to a position above/smaller than the one you used before, looks very
         plausible.


Let's take revenge on the problem by keeping it simple too. If you use .CurrentY
in your current protool hosted script, take/comment it out and test. If there
are no more nasty formfeeds and the perforation between sheets is correctly
skipped - problem solved. (Feel free to skim the rest of this posting.)

If page margins are not kept, you'll have to

   increment .CurrentY in your (equivalent of) PrintIt()
   
   issue a .EndPage and set .CurrentX to TopMargin before .CurrentY grows greater
   than BottomMargin
  
Feel free to ask here, if you need help with that (post your code).

And what if I'm wrong again? Don't setting .CurrentY to the same value before the
print still doesn't get rid of the formfeeds? Then all I can say (without further
discussion/looking at your code) is:

   (1) Make sure your (equivalent of) PrintIt() doesn't look like PrintIt_destructive()
      
   (2) Consider whether protool & your protool code are comparable to IE/MSHTA &
       the script I posted; if not: would you say that protool is more akin to a web
       server: calling a server side script (with complete load/unload cycle) each
       time a request is made?
      
   (3) In the later case: Is there something like Global.asa in protool? If yes, try
       to move the top level/init code and the global variables to this file. If no,
       I'm just running out of ideas.
      
But I'm not allowed to run out of aspects. The third one isn't done with yet. It has
to do with all the "Class cFakePrinter" code and the "CreateObject" action, which I
simplified in the above citation. As I don't like to write/post code that can't be
tested immediately and I'm not allowed to install to the ActiveX printer (not only
printers have to obey laws!), I had to fake (or mock - that's the term to google
for) the behaviour of the objects I wanted to use. For this I created a - in this
case trivial - class and used a structly localized "On Error Resume next"

    ' initialized with dirty trick
    On Error Resume Next
    Set PrinterObj = CreateObject( "avbScriptPrinter.PrinterObj" )
    On Error Goto 0
    If IsEmpty( PrinterObj ) Then Set PrinterObj = New cFakePrinter
    Set Printer = PrinterObj.Printer

to assign a my cFakePrinter object to the vaiable PrinterObj if the CreateObject()
call should fail. After that all my code used the fake.

This aspect of the script is the most uninteresting for you, KALEL. It's proven
that your script's call to CreateObject( "avbScriptPrinter.PrinterObj" ) succeded
and that your code used that PrinterObj - alas to produce formfeeds. So you could
delete all this fake code to make the script more easy to understand; perhaps more
easy to enhance, if you think of using it for testing out of protool.

But other interested people without the component would need the simulated object
to get a complete run (and some MsgBoxes) from the script. I once used this technique
to fake and test all the interaction between a professional Document Management
System and my script. Doing this from the documentation only was hard work, that I
can tell you. But when the script was installed at the first customer's side, it
ran (and did what it should do) without any further editing. Ok, by now you have
perceived that I'm proud of this fake. So rest assured: if you feel the need to
do something similiar and can't work from this simple example, just ask and you'll
get a posting longer than this.
 

(in reply to KALEL)
 
 
Post #: 17
 
 RE: printing without formfeed - 12/17/2006 3:43:34 AM   
  KALEL

 

Posts: 12
Score: 0
Joined: 12/14/2006
From: Germany, NRW
Status: offline
hi,

oooha, what a long replay.
i need some time to understand it all.

but i have make some test.

to make sure that my printer (for testing here i have only an inkjet) can print lines without formfeed
i write a litle prog

      
the printer do what i want
i get a formfeed only when i press f9 or when the side is at the end.

results of your html-code
1. i press only reload. nothing will happen
2. i press print one or more. nothing will happen at the printer,
  but in my printer spooler i can see a job. the status of the spooler in the register 'sides' is n/v.
   (i  call this result 1)

  when i now press reload or close the html the print-job will started
  the status of the spooler in the register 'sides' is 1.
   (i  call this result 2)
  i get the two lines only one times.
  i meen, when i press print 3 times before i don't get 6 lines.


this script i test too. i run it under winxp as a normal vbscript.

      

the results when i press
0. i get result 1. when i leave the script i get result 2. i get 1 line hello.
  when i press 0, don't leave the script, press 0 and then leave the script, i get 2 lines hello.

1.  just like 0

2.  i get result 2. when i press first 1 and then 2 i get 2 lines hello

3. just like 2

4. just like 2

5. i get an vbs-error. this method will not supported.

mfg
kalel

(in reply to ehvbs)
 
 
Post #: 18
 
 RE: printing without formfeed - 12/17/2006 4:10:12 AM   
  ehvbs

 

Posts: 2114
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi KALEL,

I'll need some time to work thru you code/descriptions too. Just a few
quick remarks:

Your:

  (1) when i now press reload or close the html the print-job will started
  (2) the status of the spooler in the register 'sides' is 1.
      (i  call this result 2)
  (3) i get the two lines only one times.
  (3) i meen, when i press print 3 times before i don't get 6 lines.
 
means to me:

  (1) closing/reloading the .HTML will destruct your printer objects
      that will send an EndDoc to printer
  (2) now the spooler sends the complete job
  (3) you don't get 3 pages for three button presses. Note the difference
      to your first discription of the problem. I believe: Your inkjet
      behaves as/is a page printer, able to move back to the top of the
      page. Printing three times the same text at the same position will
      look like printing once (perhaps a little bit bolder). To make sure,
      whether or not the setting of .CurrentY is involved in your problem,
      you'll have to test with the lineprinter.
     
Sorry about the .EndPage; it just dropped in my brain, because I thought
"There must be a difference between ending a page and ending the whole
document/job". You'll have to search in he documentation/code of the
ActiveX component for the correct method to invoke "new page please"

ehvbs

(Schönen Sonntag!)
 

(in reply to KALEL)
 
 
Post #: 19
 
 RE: printing without formfeed - 12/17/2006 4:25:02 AM   
  KALEL

 

Posts: 12
Score: 0
Joined: 12/14/2006
From: Germany, NRW
Status: offline
quote:

ORIGINAL: ehvbs
(3) you don't get 3 pages for three button presses. Note the difference
to your first discription of the problem. I believe: Your inkjet
behaves as/is a page printer, able to move back to the top of the
page.

yes i have test this
printing 1 job and printing 10 jobs (pressing 10 times print and then reload).
i'm sure, that the print comes 1 times, not 10 at the same positon.

mfg
kalel

quote:

ehvbs
(Schönen Sonntag!)

dir auch.
und vielen dank für die intensive hilfe.

< Message edited by KALEL -- 12/17/2006 4:34:54 AM >

(in reply to ehvbs)
 
 
Post #: 20
 
 
Page:   [1] 2   next >   >>
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> printing without formfeed Page: [1] 2   next >   >>
Jump to: