I'm trying to print my photo through c#. My printer is EPSON L351. When printing through Windows picture viewer, the photo quality is quite high. But when I print the photo through c#, it just keep blurry. The photo has the size of 1286.76*1930.4. Click here to get the picture.
Here's my code. I don't know what wrong with it. Am I missing something to set up the printer?
private void button1_Click(object sender, EventArgs e)
{
this.printDocument1.PrinterSettings.PrinterName = "EPSON L350 Series";
PaperSize ps = new PaperSize("Custom Size 1", 400, 600);
this.printDocument1.DefaultPageSettings.PaperSize = ps;
this.printDocument1.DefaultPageSettings.PrinterResolution = this.printDocument1.PrinterSettings.PrinterResolutions[0];
this.printDocument1.DefaultPageSettings.Landscape = false;
this.printDocument1.DefaultPageSettings.Margins.Left = 0;
this.printDocument1.DefaultPageSettings.Margins.Top = 0;
this.printDocument1.DefaultPageSettings.Margins.Right = 0;
this.printDocument1.DefaultPageSettings.Margins.Bottom = 0;
this.printDocument1.Print();
}
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
try
{
printDocument1.DocumentName = "Bonnie";
Image newImage = Image.FromFile(@"C:\W (22).jpg");
e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
e.Graphics.CompositingQuality = CompositingQuality.HighQuality;
e.Graphics.DrawImage(newImage, 0, 0, 400, 600);
printDocument1.Dispose();
newImage.Dispose();
}
catch (Exception ex)
{
}
}
Hoping help from you!!!!