Results 1 to 23 of 23

Thread: Print problem

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2001
    Posts
    88

    Print problem

    I have problem with method

    Printer.NewPage

    When I use it fist time in procedure it create new page but next time it just print text on the same page. First page is OK but on second page I have 5 (and more) pages one over other. What is the problem?

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Worked fine for me
    VB Code:
    1. Printer.Print "Attempt page 1"
    2. Printer.NewPage
    3. Printer.Print "Attempt page 2"
    4. Printer.EndDoc

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Mar 2001
    Posts
    88
    Well this is the code from my project, and it doesn't work. Can you tell me where is problem? I always get 2 page. First is great but second ((((

    Sorry for the format an comments in code but it's just Copy-Paste

    Dim startXL 'Pocetak x sa leve strane
    Dim startXR 'pocetak x sa desne strane
    Dim startY ' pocetak Y
    Dim Rb As Long ' redni broj linije koju stampa
    Dim r As Boolean ' da li stampa u desnoj koloni
    Dim NewDoc As Boolean 'da li je pocetak novog dokumenta

    NewDoc = True
    Printer.Font = "Tahoma"
    Printer.Orientation = 1
    Printer.PrintQuality = vbPRPQDraft
    Printer.FontSize = 7
    x = Printer.Width
    y = Printer.Height

    startXL = 100
    startXR = x / 2 + 100


    Set Base = OpenDatabase("h:\My Documents\Project\VB Project\MonSoft\base97.mdb")
    Set rc = Base.OpenRecordset("select * from istorija") ' where panelID = 4444")
    If rc.RecordCount = 0 Then MsgBox "Nema podataka za stampanje": Exit Sub
    rc.MoveLast
    rc.MoveFirst
    Firma = rc!Objekat


    startPage:
    If NewDoc = True Then
    Printer.FontSize = 20
    Printer.CurrentX = x / 2 - Printer.TextWidth(Firma) / 2
    Printer.CurrentY = 100
    Printer.Print Firma
    Printer.FontSize = 7
    Printer.Print vbCrLf
    Printer.CurrentX = startXL + 100
    Printer.Print "Pregled dogadjaja od: "
    Printer.CurrentX = startXL + 100
    Printer.Print "Do: "
    Printer.DrawWidth = 10
    Printer.Line (startXL, Printer.CurrentY + 5)-(x, Printer.CurrentY + 5)
    Printer.DrawWidth = 1
    Printer.CurrentY = Printer.CurrentY + 20
    startY = Printer.CurrentY
    NewDoc = False
    Else
    startY = 200
    End If


    groupHeader:
    Printer.CurrentY = startY

    If r = False Then
    Printer.CurrentX = startXL
    Else
    Printer.CurrentX = startXR
    End If

    cx = Printer.CurrentX
    cy = Printer.CurrentY + 20
    Printer.Print "Rb."

    Printer.CurrentX = cx + Printer.TextWidth("rb.") + 300
    cx = Printer.CurrentX
    Printer.CurrentY = cy
    Printer.Print "Datum"

    Printer.CurrentX = cx + Printer.TextWidth("datum") + 500
    Printer.CurrentY = cy
    cx = Printer.CurrentX
    Printer.Print "Vreme"

    Printer.CurrentX = cx + Printer.TextWidth("Vreme") + 350
    Printer.CurrentY = cy
    cx = Printer.CurrentX
    Printer.Print "Tip"

    Printer.CurrentX = cx + Printer.TextWidth("Tip") + 200
    Printer.CurrentY = cy
    Printer.Print "Dogadjaj"

    Printer.Line (startXL, Printer.CurrentY + 20)-(x, Printer.CurrentY + 20)


    ProgressBar1.Max = rc.RecordCount
    Do Until rc.EOF
    ProgressBar1.Value = rc.AbsolutePosition
    Rb = Rb + 1
    If r = False Then
    Printer.CurrentX = startXL
    Else
    Printer.CurrentX = startXR
    End If
    cx = Printer.CurrentX
    Printer.CurrentY = Printer.CurrentY + 20
    cy = Printer.CurrentY
    Printer.Print Rb

    Printer.CurrentX = cx + Printer.TextWidth("rb.") + 300
    Printer.CurrentY = cy
    cx = Printer.CurrentX
    Printer.Print rc!datum

    Printer.CurrentX = cx + Printer.TextWidth("datum") + 500
    cx = Printer.CurrentX
    Printer.CurrentY = cy
    Printer.Print rc!vreme

    Printer.CurrentX = cx + Printer.TextWidth("Vreme") + 350
    Printer.CurrentY = cy
    cx = Printer.CurrentX
    Printer.Print rc!tipdogadjaja

    Printer.CurrentX = cx + Printer.TextWidth("Tip") + 200
    Printer.CurrentY = cy
    Printer.Print rc!dogadjaj

    Printer.Line (startXL, Printer.CurrentY + 20)-(x, Printer.CurrentY + 20)

    rc.MoveNext
    If Printer.CurrentY > Printer.Height - 2000 Then
    If r = True Then
    Printer.CurrentX = 9000
    Printer.CurrentY = 15500
    Printer.Print "Strana: " & Printer.Page
    Printer.EndDoc
    r = False
    GoTo startPage
    Else
    r = True
    GoTo groupHeader
    End If
    Else
    End If
    Loop

    Printer.EndDoc

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Well for staters Printer.NewPage isn't used in the code you posted??????????????

    Try changing the top most Printer.EndDoc to Printer.NewPage, maybe. Since I can't run your code its hard to say.

  5. #5
    Addicted Member Sibby's Avatar
    Join Date
    Feb 2001
    Location
    Milwaukee, WI *The United States of America*
    Posts
    144
    i think it's your 1st "Printer.EndDoc" near the end or your code

    VB Code:
    1. If r = True Then
    2.      Printer.CurrentX = 9000
    3.      Printer.CurrentY = 15500
    4.      Printer.Print "Strana: " & Printer.Page
    5.      ' Printer.EndDoc   (remove this line)
    6.      r = False
    7.      GoTo startPage
    8. Else
    9.      r = True
    10.      GoTo groupHeader
    11. End If

    The ".EndDoc" should only come at the end of processing. It's telling your program...OK, I'm done talking to the printer, now release it and print. You should really only need one of these right at the end of your processing.

    I think that's your problem, try it out...hopefully you get the results you're looking for....
    If you can think it....you can code it....

  6. #6
    Hyperactive Member
    Join Date
    Jun 2000
    Posts
    350

    I'd go with that...

    I havn't looked at this carefully, I'm about to fall asleep it's 2315 here, but I think the enddoc's the problem. It literally means, the End of the Document...
    .

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Mar 2001
    Posts
    88
    I'm sorry but I put .EndDoc when I saw that .NewPage isn't working and forgot to change it back . I just want to see if I can do it that way (by the way it works fine just I have 5 print jobs with 1 page instead 1 with 5 page's on it) . Now I tried this code in New VB Project

    Printer.print "Me"
    printer.NewPage
    Printer.print "Test 1"
    printer.NewPage
    printer.print "Sample text"
    printer.NewPage
    printer.print "Another samle text"
    printer.EndDoc

    and I got same result. First page is OK but on secon page I have all three text one over another. What's wrong whit this code ???

  8. #8
    Addicted Member Sibby's Avatar
    Join Date
    Feb 2001
    Location
    Milwaukee, WI *The United States of America*
    Posts
    144

    well....

    The code you have there on that last post looks good. Unfortuantly I think you may have some sort of local printer compatability issue. Unless someone else sees something that I don't I think you're out of luck on this one.....

    If you can think it....you can code it....

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Mar 2001
    Posts
    88
    So what should do?? I tried this on HP DeskJet 640 and on 5D PDF Creator but it won't work

  10. #10
    Hyperactive Member
    Join Date
    Jun 2000
    Posts
    350

    Your code worked for me . . .

    I dumped your code

    VB Code:
    1. Printer.print "Me"
    2. printer.NewPage
    3. Printer.print "Test 1"
    4. printer.NewPage
    5. printer.print "Sample text"
    6. printer.NewPage
    7. printer.print "Another samle text"
    8. printer.EndDoc

    into a command button and it worked perfectly to my printer.

    I then printed to file and Distilled it, so you can see the evidence in the attachement.

    My printer is a Xerox DC432, using the PostScript driver.
    Attached Files Attached Files
    .

  11. #11

    Thread Starter
    Lively Member
    Join Date
    Mar 2001
    Posts
    88
    *(&^@#)@# @#(*%^ )(@#*^% _)$^@#!@$
    Thanx anyway

  12. #12
    Hyperactive Member
    Join Date
    Jun 2000
    Posts
    350
    Originally posted by vujke
    *(&^@#)@# @#(*%^ )(@#*^% _)$^@#!@$
    Well just to make you feel worse, I printed it with a PCL driver and that also worked fine!
    .

  13. #13

    Thread Starter
    Lively Member
    Join Date
    Mar 2001
    Posts
    88
    What should I do??? Should I reinstall Windows? I've tried this on WinME and Win2000.

  14. #14
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    What may be causing the problem is that you are moving the printer pointer position as you print (using CurrentX,Y) so I think even though you reset the position to a new page you are moving it back again with the CurrentX,Y code. Try running the code we posted and see if that works. If it does then its probably not a printer thing but a code thing and the difference in your code and ours is the Current X,Y.

    I've tried before to do like you are doing and make a 'Report' using the printer object and thats what happened to me anyway.

  15. #15
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    If yo ucan get the length of the page maybe you could increment any place where you Set the CurrentX or Y (CurrentX=1000 +PageLength) with the value plus the length of a page so then you'd be setting the height for the next page.

  16. #16
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    I modified your code to test it without the data:
    VB Code:
    1. Dim startXL 'Pocetak x sa leve strane
    2. Dim startXR 'pocetak x sa desne strane
    3. Dim startY ' pocetak Y
    4. Dim Rb As Long ' redni broj linije koju stampa
    5. Dim r As Boolean ' da li stampa u desnoj koloni
    6. Dim NewDoc As Boolean 'da li je pocetak novog dokumenta
    7.  
    8. Dim x As Long
    9. Dim y As Long
    10.  
    11. NewDoc = True
    12. Printer.Font = "Tahoma"
    13. Printer.Orientation = 1
    14. Printer.PrintQuality = vbPRPQDraft
    15. Printer.FontSize = 7
    16. x = Printer.Width
    17. y = Printer.Height
    18.  
    19. startXL = 100
    20. startXR = x / 2 + 100
    21.  
    22.  
    23. 'Set Base = OpenDatabase("h:\My Documents\Project\VB Project\MonSoft\base97.mdb")
    24. 'Set rc = Base.OpenRecordset("select * from istorija") ' where panelID = 4444")
    25. 'If rc.RecordCount = 0 Then MsgBox "Nema podataka za stampanje": Exit Sub
    26. 'rc.MoveLast
    27. 'rc.MoveFirst
    28. Dim Firma As String
    29. Firma = "My Heading" 'rc!Objekat
    30.  
    31.  
    32. startPage:
    33. If NewDoc = True Then
    34. Printer.FontSize = 20
    35. Printer.CurrentX = x / 2 - Printer.TextWidth(Firma) / 2
    36. Printer.CurrentY = 100
    37. Printer.Print Firma
    38. Printer.FontSize = 7
    39. Printer.Print vbCrLf
    40. Printer.CurrentX = startXL + 100
    41. Printer.Print "Pregled dogadjaja od: "
    42. Printer.CurrentX = startXL + 100
    43. Printer.Print "Do: "
    44. Printer.DrawWidth = 10
    45. Printer.Line (startXL, Printer.CurrentY + 5)-(x, Printer.CurrentY + 5)
    46. Printer.DrawWidth = 1
    47. Printer.CurrentY = Printer.CurrentY + 20
    48. startY = Printer.CurrentY
    49. NewDoc = False
    50. Else
    51. startY = 200
    52. End If
    53.  
    54.  
    55. groupHeader:
    56. Printer.CurrentY = startY
    57.  
    58. If r = False Then
    59. Printer.CurrentX = startXL
    60. Else
    61. Printer.CurrentX = startXR
    62. End If
    63.  
    64. cx = Printer.CurrentX
    65. cy = Printer.CurrentY + 20
    66. Printer.Print "Rb."
    67.  
    68. Printer.CurrentX = cx + Printer.TextWidth("rb.") + 300
    69. cx = Printer.CurrentX
    70. Printer.CurrentY = cy
    71. Printer.Print "Datum"
    72.  
    73. Printer.CurrentX = cx + Printer.TextWidth("datum") + 500
    74. Printer.CurrentY = cy
    75. cx = Printer.CurrentX
    76. Printer.Print "Vreme"
    77.  
    78. Printer.CurrentX = cx + Printer.TextWidth("Vreme") + 350
    79. Printer.CurrentY = cy
    80. cx = Printer.CurrentX
    81. Printer.Print "Tip"
    82.  
    83. Printer.CurrentX = cx + Printer.TextWidth("Tip") + 200
    84. Printer.CurrentY = cy
    85. Printer.Print "Dogadjaj"
    86.  
    87. Printer.Line (startXL, Printer.CurrentY + 20)-(x, Printer.CurrentY + 20)
    88.  
    89.  
    90. ProgressBar1.Max = 3 'rc.RecordCount
    91.  
    92. Dim cnt As Integer
    93. For cnt = 1 To 3
    94. 'Do Until rc.EOF
    95. ProgressBar1.Value = cnt 'rc.AbsolutePosition
    96. Rb = Rb + 1
    97. If r = False Then
    98. Printer.CurrentX = startXL
    99. Else
    100. Printer.CurrentX = startXR
    101. End If
    102. cx = Printer.CurrentX
    103. Printer.CurrentY = Printer.CurrentY + 20
    104. cy = Printer.CurrentY
    105. Printer.Print Rb
    106.  
    107. Printer.CurrentX = cx + Printer.TextWidth("rb.") + 300
    108. Printer.CurrentY = cy
    109. cx = Printer.CurrentX
    110. Printer.Print "datum " & cnt 'rc!datum
    111.  
    112. Printer.CurrentX = cx + Printer.TextWidth("datum") + 500
    113. cx = Printer.CurrentX
    114. Printer.CurrentY = cy
    115. Printer.Print "vreme " & cnt 'rc!vreme
    116.  
    117. Printer.CurrentX = cx + Printer.TextWidth("Vreme") + 350
    118. Printer.CurrentY = cy
    119. cx = Printer.CurrentX
    120. Printer.Print "tipdogadjaja " & cnt 'rc!tipdogadjaja
    121.  
    122. Printer.CurrentX = cx + Printer.TextWidth("Tip") + 200
    123. Printer.CurrentY = cy
    124. Printer.Print "dogadjaj " & cnt 'rc!dogadjaj
    125.  
    126. Printer.Line (startXL, Printer.CurrentY + 20)-(x, Printer.CurrentY + 20)
    127.  
    128. 'rc.MoveNext
    129. If Printer.CurrentY > Printer.Height - 2000 Then
    130. If r = True Then
    131. Printer.CurrentX = 9000
    132. Printer.CurrentY = 15500
    133. Printer.Print "Strana: " & Printer.Page
    134. Printer.NewPage
    135. r = False
    136. GoTo startPage
    137. Else
    138. r = True
    139. GoTo groupHeader
    140. End If
    141. Else
    142. End If
    143. Next cnt
    144. 'Loop
    145.  
    146. Printer.EndDoc

    But I am not sure what the report is supposed to look like.
    Right now I get the first page as just the headers and a second page with all the values under the header.

    So maybe I was wrong about adding the length of the page???

  17. #17
    Addicted Member Sibby's Avatar
    Join Date
    Feb 2001
    Location
    Milwaukee, WI *The United States of America*
    Posts
    144
    I wouldn't install your OS over this....Edneeis has a good point, if that doesn't work, I'd suggest looking toward something like Crystal Reports. But that's a whole nother animal altogether!
    If you can think it....you can code it....

  18. #18
    Hyperactive Member
    Join Date
    Jun 2000
    Posts
    350

    Hang on, guys....

    Vujke says the problem occurs with this simple code:

    VB Code:
    1. Printer.print "Me"
    2. printer.NewPage
    3. Printer.print "Test 1"
    4. printer.NewPage
    5. printer.print "Sample text"
    6. printer.NewPage
    7. printer.print "Another samle text"
    8. printer.EndDoc

    and I don't get the same symptoms in either PCL or PS.

    So I think vujke should print to file and let others try the print to say LPT: with a copy command from dos. Or if it's PCL which it seems to be, look at the pages in a PCL viewer.

    Or print to file and look at the file in a hex editor: look for formfeeds or showpages.



    Let's try and isolate one thing at time
    Last edited by Jim Brown; Sep 29th, 2001 at 11:33 PM.
    .

  19. #19

    Thread Starter
    Lively Member
    Join Date
    Mar 2001
    Posts
    88
    OK. What driver to use to print to file? What printer?

  20. #20
    Hyperactive Member
    Join Date
    Jun 2000
    Posts
    350
    I'd print to file with the printer & driver you're using already. Change the printer's port from LPT: or its ip address to FILE: by going into the printer's properties in Start/Printers.

    When you print, it'll prompt you for a file name. Zip the file up and post it here: I'll look at in a PCL Interpreter and print it out.

    Don't forget to change the printer port back again! I nearly always forget.
    .

  21. #21

    Thread Starter
    Lively Member
    Join Date
    Mar 2001
    Posts
    88
    Well here at home I don't have printer but I use 5D PDF Creator. I'll send You 3 files.
    HP 5L PCL print file
    5D PDF Creator print file and
    5D PDF Creator PDF file so You can see my result

    I don't have driver for HP DeskJet 640 so I can't send you his prn file

  22. #22

    Thread Starter
    Lively Member
    Join Date
    Mar 2001
    Posts
    88
    Where is file ??? I send it again
    Attached Files Attached Files

  23. #23
    Hyperactive Member
    Join Date
    Jun 2000
    Posts
    350
    Hi-

    I opened the PCL file in my PCL Interpreter, and yes, it only has 2 pages just like your PDF. That indicates to me that the PCL itself is being generated with 2 pages: so the problem originates in the driver almost certainly, not at the printer itself.

    I'm on leave from work, but I will be popping into the office tomorrow for a short while and I'll ask our PCL guru if there's anything in the PCL which looks unusual.

    Perhaps in the meanwhile you should look at the window which the driver gives you at print time, to see if there's a check-box or a radio-button you might have overlooke which could have a bearing on this?
    .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width