Problem printing images in VS-VIEW 8.0 (DrawPicture)

Posted by: hi_low8066 on 20 June 2019, 1:06 pm EST

    • Post Options:
    • Link

    Posted 20 June 2019, 1:06 pm EST

    Hello.

    It still uses VS-VIEW 8.0 for applications that run on VB 6.0.

    When trying to print an image with DrawPicture method along with text data on all pages, the preview is displayed correctly.

    However, when printing with a printer, the image may not be printed only on the first page.

    Why does this happen?

    Are there any measures?

    OS environment has been confirmed on Windows 7 (x64) and Windows 10 (x64).

    Sorry for the poor English.

  • Posted 23 June 2019, 8:23 pm EST

    Hi,

    Which build of VSView 8.0 are you currently working with? Can you please try using the latest build and see if that resolves the problem in your case? You can download the latest build from the following link:

    http://prerelease.componentone.com/activex/vsview/2017-t3/

    In case the problem persists, please share a small stripped down project demonstrating the behavior. I would like to investigate this further.

    Thanks,

    Pragati

  • Posted 24 June 2019, 7:00 pm EST

    Hello. Thank you for your reply.

    The problem is in VS-VIEW 8.0.20082.147 Japanese version.

    At first we tried with the latest version and it seemed to be fine.

    However, the problem arose in the same way.

    The procedure is unclear.

    After previewing, if you switch printers before printing, it may seem like a problem.

    It may or may not happen. It is not well understood.

    Help me.

    HIRO

  • Posted 24 June 2019, 7:48 pm EST

    Provides a source for testing.

    However, problems may not occur in your environment.

    The problem is that you can preview but not print.

    This problem is clearly happening.

    HIROvsview_test.zip

  • Posted 25 June 2019, 10:32 pm EST

    Hi Hiro,

    Thanks for sharing the project.

    I could replicate the issue at my end as well. I will escalate it to the developers and will let you know once there is any information from them.

    ~Pragati

  • Posted 26 June 2019, 8:17 am EST

    Thank you very much.

    I am waiting to be fixed.

    HIRO

  • Posted 26 June 2019, 3:34 pm EST

    Hiro,

    JFYI, the tracking ID of the issue is 386202.

    Thanks.

  • Posted 26 June 2019, 3:50 pm EST

    Thank you for your response.

    How long does it take to be fixed?

    Then can I use the modified version in Japan?

  • Posted 27 June 2019, 8:08 pm EST

    Hi Hiro,

    I am getting in touch with the developers for an ETA. Will let you know once have some information from their end.

    Thanks,

    Pragati

  • Posted 21 July 2019, 6:26 pm EST

    Hi Hiro,

    I discussed the case with the developer. As per him, the problem is due to the printer driver. We’ve tried several printers, both local and networked, Sharp printer and a couple of HP LaserJet printers. The HP LaserJet printers, local and network, all behave correctly, but the Sharp printer does not. One the Sharp printer, if any VSPrinter operation is done before DrawPicture of an EMF, the EMF does not appear. For example, if the loop adding text is done first, then NEITHER of the emf images appear in the output. This is related to how the printer driver handles nested emf - each page of VSPrinter output is an emf, so emf images are nested within the page.

    Without rewriting VSPrinter (which cannot be done as it is legacy) the only workaround we could find is to use bitmap images instead of emf images. Of course, the emf images scale better, which is probably why you are using them, however, it is possible to create the bitmaps at runtime from the original emf images. Consider the modified Form_Load and new EmfToBitmap function provided below:

    Private Sub Form_Load()
      Dim i As Integer
      Dim pic1 As stdpicture
      Dim pic2 As stdpicture
      Dim Width As Single
      Dim Height As Single
      Dim AsBmpOnly As Boolean
      
      Set pic1 = LoadPicture(App.Path & "\imagetest.emf")
      
      AsBmpOnly = True
      
      If AsBmpOnly Then
        Width = ScaleX(pic1.Width, vbHimetric, vbTwips)
        Height = ScaleY(pic1.Height, vbHimetric, vbTwips)
        
        ' Always use the original EMF image and not an image already
        ' converted to a bitmap.
        Set pic2 = EmfToBitmap(pic1, Width * 2, Height * 2)
        Set pic1 = EmfToBitmap(pic1, Width, Height)
      End If
      
      VSPrinter1.StartDoc
    
      For i = 1000 To 1500 Step 500
        VSPrinter1.CurrentX = 1000
        VSPrinter1.CurrentY = i
        VSPrinter1.FontSize = 20
        VSPrinter1.Text = CStr(i) + " Abcdefg1234567890#!"
      Next
      
      Call VSPrinter1.DrawPicture(pic1, 500, 5000)
      
      If AsBmpOnly Then
        ' BMP images can scale, but not as well.  Use default BMP size
        Call VSPrinter1.DrawPicture(pic2, 500, 8000)
      Else
        ' Emf images can scale directly using VSPrinter
        Call VSPrinter1.DrawPicture(pic2, 500, 8000, "200%", "200%", 11)
      End If
      
      VSPrinter1.EndDoc
    End Sub
    
    Public Function EmfToBitmap(emf As stdpicture, Width As Single, Height As Single) As stdpicture
        Dim picbox As PictureBox
        Dim pic As stdpicture
        Dim tmpSingle As Single
        Dim tmpFile As String
        tmpFile = Environ("TEMP") + "\tmpBitmapFile.bmp"
        Set picbox = Me.Controls.Add("vb.PictureBox", "tmpPicBox")
        With picbox
            Set .Picture = Nothing
            tmpSingle = .Width - .ScaleWidth
            .Visible = False
            .BackColor = vbWhite
            .AutoRedraw = True
            .AutoSize = True
            .Width = Width + tmpSingle
            .Height = Height + tmpSingle
            .ScaleLeft = 0
            .ScaleTop = 0
            .ScaleWidth = Width
            .ScaleHeight = Height
            .PaintPicture emf, 0, 0, Width, Height
            .Picture = .Image
            SavePicture .Picture, tmpFile
            .Picture = Nothing
            Set pic = LoadPicture(tmpFile)
            Kill tmpFile
        End With
        Me.Controls.Remove picbox
        Set EmfToBitmap = pic
    End Function
    

    I have also attached a modified project for your reference. This version converts the emf image to bitmaps at runtime. This is not as good as using the emf images due to scaling differences between screen and printer, but it provides a workaround for no images at all.

    Thanks,

    Pragati

    vsview_test_modified.zip

  • Posted 21 July 2019, 7:12 pm EST

    Thank you, Pragati.

    Thank you very much for investigating the cause.

    Does that mean that if you output an image before output such as text, you will not get any symptoms?

    If so I can handle it.

    In addition, I used EMF in the provided sample, but actually there was the same symptom in the GIF file. The symptom is only the first page.

  • Posted 23 July 2019, 8:03 pm EST

    >>Does that mean that if you output an image before output such as text, you will not get any symptoms?

    Yes, if any VSPrinter operation is done before DrawPicture of an EMF, the EMF does not appear on Sharp printer. Otherwise, it should.

    >>In addition, I used EMF in the provided sample, but actually there was the same symptom in the GIF file. The symptom is only the first page.

    I am confirming that from the developer. Will get back to you on this.

    Thanks.

  • Posted 23 July 2019, 8:21 pm EST

    Thank you for your response.

    I understood about EMF.

    Let’s fix it so that the image output is done first.

    Thank you very much.

    HIRO.

  • Posted 30 July 2019, 7:18 pm EST

    Hi Hiro,

    I discussed the case of GIF’s with the developer. As per him, it seems to be the same problem. VSPrint8 calls the system function PlayEnhMetaFile() to the printer DC (device context) and the DC which is supported by the printer driver needs to handle it.

    Thanks,

    Pragati

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels