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>
384x576 is very low resolution when printers normally have resolutions of 400 to 1200 DPI. In order to blow up that low resolution text to a size where it can be printed, it is being aliased and anti-aliased without mercy by Windows.
What you can do about it: Try different printface sizes, perhaps?