troubleshooting Question

BLURRY TEXT - WINDOW FORMS - PANEL - VB.net

Avatar of Kevin Terry
Kevin TerryFlag for United States of America asked on
Visual Basic.NET
4 Comments1 Solution13 ViewsLast Modified:
I know this topic has MANY questions/answers but I am still drawing blanks. Running Windows 10, Visual Studio 2019. I have created a Windows Forms App (.NET Framework). Target is .NET Framework 4.7.2. I have a Form created with a Panel on the form. The Panel is sized to 384x576 which is approximate 4" x 6". That is the exact size I have my page size set to. When I print preview (via code) it looks clear, but when it prints to my laser printer, some of the text is blurred. The text is a Label. My apologies up front, almost 80% of the code has been pieced together from "MANY" websites, so if you see any specific part of my code that looks like your code, sorry I am not giving proper credits in the footnotes.

Here is some of my code:

PRINT BUTTON code:

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
   Dim myprintdialog As New PrintDialog memoryimage = New System.Drawing.Bitmap(Panel1.Width, Panel1.Height)
   Panel1.DrawToBitmap(memoryimage, Panel1.ClientRectangle)

       If myprintdialog.ShowDialog = DialogResult.OK Then
           Dim value As System.Drawing.Printing.PrinterSettings
           value = myprintdialog.PrinterSettings
           myprintdialog.Document = PrintDocument1
           PrintDocument1.PrintController = New StandardPrintController()
           Panel1.BackColor = Color.White
           PrintDocument1.Print()
       End If
End Sub

Private Sub PrintPage(sender As Object, e As System.Drawing.Printing.PrintPageEventArgs) Handles
     PrintDocument1.PrintPage
    e.Graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality
    e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic
    e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality
    e.Graphics.DrawImage(memoryimage, 0, 0)
End Sub


and added an app.manifest

   <?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
  <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
    <requestedExecutionLevel level="asInvoker" uiAccess="false" />
  </requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
</application>
</compatibility>
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
  <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
</windowsSettings>
</application>

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros