Help for Printer.PaintPicture 
Author Message
 Help for Printer.PaintPicture

I am having a problem with PaintPicture Method on the printer object.

I copied a picture into a PictureBox during development so that it is part
of the project. Then as part of the program I use the PaintPicture Method to
print out that picture on to each page. Not on my computer, but on other
computers the picture will not print on all of the pages. It seems to be
random. Everything from missing 1 or 2 every 100 pages to 1 or 2 every 10
pages. I don't know what is going on. I have never had it happen on my
system, just on others systems.

I have also tried to copy the picture into a StdPicture object with similar
results.

If anyone has any suggestion how I might Diagnosis this I would greatly
appreciate it, or if there is a better way to print pictures that would be
great.

Thanks

Mel



Thu, 31 Mar 2005 06:35:02 GMT  
 Help for Printer.PaintPicture
Post some of your code.

Mike

Quote:

> I am having a problem with PaintPicture Method on the printer object.

> I copied a picture into a PictureBox during development so that it is part
> of the project. Then as part of the program I use the PaintPicture Method to
> print out that picture on to each page. Not on my computer, but on other
> computers the picture will not print on all of the pages. It seems to be
> random. Everything from missing 1 or 2 every 100 pages to 1 or 2 every 10
> pages. I don't know what is going on. I have never had it happen on my
> system, just on others systems.

> I have also tried to copy the picture into a StdPicture object with similar
> results.

> If anyone has any suggestion how I might Diagnosis this I would greatly
> appreciate it, or if there is a better way to print pictures that would be
> great.

> Thanks

> Mel



Fri, 01 Apr 2005 02:40:52 GMT  
 Help for Printer.PaintPicture
  I am not quite sure that I know that part of the code to send. I will
explain a little first. I am using a telnet session to get the data. When I
am sure that I have received the whole line of data (strData) I call
PrintPage.  I parse through the line(strData) and in put each value it to
the sPrint array. Then I print the picture and the data.

I have a form dlgPrintPos that has textboxes for the X, Y and FontSizes for
all the print fields. They are the control arrays txtXPos, txtYPos, and
txtSize.

-----------------------------------------
Option Explicit
...
Dim stdpic As New StdPicture
Dim x1 As Long
Dim y1 As Long
-----------------------------------------
Private Sub Form_Load()
...
Set stdpic = Image1.Picture
...
End Sub
-----------------------------------------
Private Sub Command1_Click()
  Command1.Enabled = False
  x1 = dlgPrintPos.txtXpos(20).Text
  y1 = dlgPrintPos.txtYpos(20).Text
  Winsock1.RemoteHost = dlgOptions.txtOpt(1).Text
  Winsock1.Connect
End Sub
-----------------------------------------

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
    ...
'       I have the whole line in strData now print the page.

        PrintPage strData
        Printer.NewPage

'       Now send to get the next line.

        strSend = Chr(13)
        Winsock1.SendData strSend
   ...
End Sub
-----------------------------------------
Private Sub PrintPage(strData As String)
  On Error GoTo error_handle
  ...
  Dim icnt As Integer
  Dim sPrint(1 To 19)
  Dim iWidth As Integer
  Dim ierr As Integer
  ...
  Printer.PaintPicture stdpic, x1, y1
'  Printer.PaintPicture Image1.Picture, dlgPrintPos.txtXpos(20).Text,
dlgPrintPos.txtYpos(20).Text
  For icnt = 1 To 18
    Printer.FontSize = dlgPrintPos.txtSize(icnt).Text
    Select Case icnt
      Case 10, 16, 17, 18
        iWidth = Printer.TextWidth(sPrint(icnt))
      Case 8, 9
        iWidth = Printer.TextWidth(sPrint(icnt)) / 2
        iWidth = CInt(dlgPrintPos.txtXpos(icnt).Text) / 2 + iWidth
      Case Else
        iWidth = 0
    End Select
    Printer.CurrentX = CInt(dlgPrintPos.txtXpos(icnt).Text) - iWidth
    Printer.CurrentY = dlgPrintPos.txtYpos(icnt).Text
    Printer.Print sPrint(icnt)
  Next icnt
-----------------------------------------

Like I said before the Picture doesn't always print but I get the rest of
the data. With the line that is commented out I would sometimes receive a
mismatch type error, but I have not received that error with the code as it
is now.

I hope that I have included enough of the code. Let me know if you have any
thoughts about what could be going on.

Thanks for your response.

Mel


Post some of your code.

Mike


Quote:
> I am having a problem with PaintPicture Method on the printer object.

> I copied a picture into a PictureBox during development so that it is part
> of the project. Then as part of the program I use the PaintPicture Method
to
> print out that picture on to each page. Not on my computer, but on other
> computers the picture will not print on all of the pages. It seems to be
> random. Everything from missing 1 or 2 every 100 pages to 1 or 2 every 10
> pages. I don't know what is going on. I have never had it happen on my
> system, just on others systems.

> I have also tried to copy the picture into a StdPicture object with
similar
> results.

> If anyone has any suggestion how I might Diagnosis this I would greatly
> appreciate it, or if there is a better way to print pictures that would be
> great.

> Thanks

> Mel



Sat, 02 Apr 2005 21:11:25 GMT  
 Help for Printer.PaintPicture
Firstly, I would suggest that throughout your program you use the appropriate convert function when reading the data that the user has entered into the various TextBoxes, rather than relying on VB doing it for you. For example, since the variable x1 happens to be a Long then you should use:

x1 = cLng(dlgPrintPos.txtXpos(20).Text)

rather than:

x1 = dlgPrintPos.txtXpos(20).Text

That, though, is not likely to be the cause of your problem.

You don't say what ScaleMode you are using for the Printer object and you haven't said what values are typically entered into the various Text Boxes. Maybe the values are sometimes such that the picture is positioned off the page, although from looking at your code I suspect that such an error would cause the same fault to appear on all pages. It is worth looking at, though. Try adding some temporary code to dump an incrementing page number and the values of x1 and y1 into a ListBox and follow that by dumping the values of Printer.CurrentX and Printer.CurrentY into the same ListBox just before the Printer.Print statement in your 1 to 18 loop, followed by inserting an empty string into the ListBox when the loop terminates. That, at least, would allow you to inspect the finished printed pages and compare the results with the ListBox values for each specific page, which might be a help.

Also, you don't say whether you are printing the text items below (or above) the printed picture or whether you are printing them transparently on top of part or all of the picture. If you are doing the latter then you will, of course, need to set Printer.FontTransparent to True, otherwise the white background of each line of text will overwrite parts of the picture, causing all or part of it to "disappear". In fact, whatever you are doing, it might be wise to set FontTransparent to True so that you can more easily see what is happening. Don't rely on the fact that the FontTransparent property is supposed to default to True, because there is a little bug in VB that causes it to fail to do that on some systems. In fact, FontTransparent problem, even when you "fix" it, can often raise its ugly head again immediately after a Printer.NewPage. You can fix the FontTransparent problem by "toggling" it. You need to do this at the start of your printing and immediately after every Printer.NewPage:

Printer.FontTransparent = False
Printer.Print
Printer.FontTransparent = True

The Printer.Print statement in between the two FontTransparent settings is important, and the "fix" will not work without it.

Another thing you can try (although I am just guessing) is to insert a couple of DoEvents around a short pause immediately after the Printer.NewPage statement and possibly another one immediately after the Printer.PaintPicture statement. A total pause of about half a second should be plenty and it won't unduly affect the print time for each page. Although this shouldn't really have any effect on the PaintPicture stuff, I have heard of problems with other (mostly video graphic stuff) where faults such as this can occur because of certain events being queued in the system or being dealt with separately by the hardware. If this is a printer driver problem then such action might just fix it, although I must admit that I am clutching at straws here :-)

I don't know whether any of this helps you, but if it doesn't then post again with some more details.

Mike

Quote:

>   I am not quite sure that I know that part of the code to send. I will
> explain a little first. I am using a telnet session to get the data. When I
> am sure that I have received the whole line of data (strData) I call
> PrintPage.  I parse through the line(strData) and in put each value it to
> the sPrint array. Then I print the picture and the data.

> I have a form dlgPrintPos that has textboxes for the X, Y and FontSizes for
> all the print fields. They are the control arrays txtXPos, txtYPos, and
> txtSize.

> -----------------------------------------
> Option Explicit
> ...
> Dim stdpic As New StdPicture
> Dim x1 As Long
> Dim y1 As Long
> -----------------------------------------
> Private Sub Form_Load()
> ...
> Set stdpic = Image1.Picture
> ...
> End Sub
> -----------------------------------------
> Private Sub Command1_Click()
>   Command1.Enabled = False
>   x1 = dlgPrintPos.txtXpos(20).Text
>   y1 = dlgPrintPos.txtYpos(20).Text
>   Winsock1.RemoteHost = dlgOptions.txtOpt(1).Text
>   Winsock1.Connect
> End Sub
> -----------------------------------------

> Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
>     ...
> '       I have the whole line in strData now print the page.

>         PrintPage strData
>         Printer.NewPage

> '       Now send to get the next line.

>         strSend = Chr(13)
>         Winsock1.SendData strSend
>    ...
> End Sub
> -----------------------------------------
> Private Sub PrintPage(strData As String)
>   On Error GoTo error_handle
>   ...
>   Dim icnt As Integer
>   Dim sPrint(1 To 19)
>   Dim iWidth As Integer
>   Dim ierr As Integer
>   ...
>   Printer.PaintPicture stdpic, x1, y1
> '  Printer.PaintPicture Image1.Picture, dlgPrintPos.txtXpos(20).Text,
> dlgPrintPos.txtYpos(20).Text
>   For icnt = 1 To 18
>     Printer.FontSize = dlgPrintPos.txtSize(icnt).Text
>     Select Case icnt
>       Case 10, 16, 17, 18
>         iWidth = Printer.TextWidth(sPrint(icnt))
>       Case 8, 9
>         iWidth = Printer.TextWidth(sPrint(icnt)) / 2
>         iWidth = CInt(dlgPrintPos.txtXpos(icnt).Text) / 2 + iWidth
>       Case Else
>         iWidth = 0
>     End Select
>     Printer.CurrentX = CInt(dlgPrintPos.txtXpos(icnt).Text) - iWidth
>     Printer.CurrentY = dlgPrintPos.txtYpos(icnt).Text
>     Printer.Print sPrint(icnt)
>   Next icnt
> -----------------------------------------

> Like I said before the Picture doesn't always print but I get the rest of
> the data. With the line that is commented out I would sometimes receive a
> mismatch type error, but I have not received that error with the code as it
> is now.

> I hope that I have included enough of the code. Let me know if you have any
> thoughts about what could be going on.

> Thanks for your response.

> Mel



> Post some of your code.

> Mike



> > I am having a problem with PaintPicture Method on the printer object.

> > I copied a picture into a PictureBox during development so that it is part
> > of the project. Then as part of the program I use the PaintPicture Method
> to
> > print out that picture on to each page. Not on my computer, but on other
> > computers the picture will not print on all of the pages. It seems to be
> > random. Everything from missing 1 or 2 every 100 pages to 1 or 2 every 10
> > pages. I don't know what is going on. I have never had it happen on my
> > system, just on others systems.

> > I have also tried to copy the picture into a StdPicture object with
> similar
> > results.

> > If anyone has any suggestion how I might Diagnosis this I would greatly
> > appreciate it, or if there is a better way to print pictures that would be
> > great.

> > Thanks

> > Mel



Sat, 02 Apr 2005 22:12:55 GMT  
 Help for Printer.PaintPicture

Quote:
>'  Printer.PaintPicture Image1.Picture, dlgPrintPos.txtXpos(20).Text,
>dlgPrintPos.txtYpos(20).Text

This is a Variant holding a String :-

    dlgPrintPos.txtXpos(20).Text

x1, y1  require Single Precision variables

Coercion can take place - but I would not fancy trusting users to
enter valid numbers.

On Tue, 15 Oct 2002 13:11:25 GMT, "Mel Durfey"

Quote:

>  I am not quite sure that I know that part of the code to send. I will
>explain a little first. I am using a telnet session to get the data. When I
>am sure that I have received the whole line of data (strData) I call
>PrintPage.  I parse through the line(strData) and in put each value it to
>the sPrint array. Then I print the picture and the data.

>I have a form dlgPrintPos that has textboxes for the X, Y and FontSizes for
>all the print fields. They are the control arrays txtXPos, txtYPos, and
>txtSize.

>-----------------------------------------
>Option Explicit
>...
>Dim stdpic As New StdPicture
>Dim x1 As Long
>Dim y1 As Long
>-----------------------------------------
>Private Sub Form_Load()
>...
>Set stdpic = Image1.Picture
>...
>End Sub
>-----------------------------------------
>Private Sub Command1_Click()
>  Command1.Enabled = False
>  x1 = dlgPrintPos.txtXpos(20).Text
>  y1 = dlgPrintPos.txtYpos(20).Text
>  Winsock1.RemoteHost = dlgOptions.txtOpt(1).Text
>  Winsock1.Connect
>End Sub
>-----------------------------------------

>Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
>    ...
>'       I have the whole line in strData now print the page.

>        PrintPage strData
>        Printer.NewPage

>'       Now send to get the next line.

>        strSend = Chr(13)
>        Winsock1.SendData strSend
>   ...
>End Sub
>-----------------------------------------
>Private Sub PrintPage(strData As String)
>  On Error GoTo error_handle
>  ...
>  Dim icnt As Integer
>  Dim sPrint(1 To 19)
>  Dim iWidth As Integer
>  Dim ierr As Integer
>  ...
>  Printer.PaintPicture stdpic, x1, y1
>'  Printer.PaintPicture Image1.Picture, dlgPrintPos.txtXpos(20).Text,
>dlgPrintPos.txtYpos(20).Text
>  For icnt = 1 To 18
>    Printer.FontSize = dlgPrintPos.txtSize(icnt).Text
>    Select Case icnt
>      Case 10, 16, 17, 18
>        iWidth = Printer.TextWidth(sPrint(icnt))
>      Case 8, 9
>        iWidth = Printer.TextWidth(sPrint(icnt)) / 2
>        iWidth = CInt(dlgPrintPos.txtXpos(icnt).Text) / 2 + iWidth
>      Case Else
>        iWidth = 0
>    End Select
>    Printer.CurrentX = CInt(dlgPrintPos.txtXpos(icnt).Text) - iWidth
>    Printer.CurrentY = dlgPrintPos.txtYpos(icnt).Text
>    Printer.Print sPrint(icnt)
>  Next icnt
>-----------------------------------------

>Like I said before the Picture doesn't always print but I get the rest of
>the data. With the line that is commented out I would sometimes receive a
>mismatch type error, but I have not received that error with the code as it
>is now.

>I hope that I have included enough of the code. Let me know if you have any
>thoughts about what could be going on.

>Thanks for your response.

>Mel



>Post some of your code.

>Mike



>> I am having a problem with PaintPicture Method on the printer object.

>> I copied a picture into a PictureBox during development so that it is part
>> of the project. Then as part of the program I use the PaintPicture Method
>to
>> print out that picture on to each page. Not on my computer, but on other
>> computers the picture will not print on all of the pages. It seems to be
>> random. Everything from missing 1 or 2 every 100 pages to 1 or 2 every 10
>> pages. I don't know what is going on. I have never had it happen on my
>> system, just on others systems.

>> I have also tried to copy the picture into a StdPicture object with
>similar
>> results.

>> If anyone has any suggestion how I might Diagnosis this I would greatly
>> appreciate it, or if there is a better way to print pictures that would be
>> great.

>> Thanks

>> Mel



Sun, 03 Apr 2005 13:35:12 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Printer.Paintpicture and Picturebox.paintpicture

2. Printer.PaintPicture : Need Help !!!!!!

3. PaintPicture - quality of compression for printer and Imagebox

4. Printer.Paintpicture problem

5. Problems with Paintpicture & Printer object in VB416

6. Printer.PaintPicture Problem

7. Printer.PaintPicture No Picture on Print out

8. printer.paintpicture

9. Printer.PaintPicture

10. Error 481 - Invalid Picture / Printer.PaintPicture.

11. PaintPicture - compress quality for printer and Image

12. Error 481 - Invalid Picture / Printer.PaintPicture.

 

 
Powered by phpBB® Forum Software