J'essaie d'imprimer mon formulaire en utilisant GDI, mais quand je l'imprime, la qualité de l'impression n'est pas très bonne (ne pas savoir si Image obtient un alias?), la taille de la forme est 700x700, il y a aussi un paramètre force compris -raster op code-, voici le code ... am utilisecomment améliorer la qualité de l'impression lorsque j'imprime Win Form en C#
private void printDocument1_PrintPage(object sender, PrintPageEventArgs e)
{
Graphics g1 = this.CreateGraphics();
System.Drawing.Image MyImage = new Bitmap(this.ClientRectangle.Width, this.ClientRectangle.Height, g1);
Graphics g2 = Graphics.FromImage(MyImage);
IntPtr dc1 = g1.GetHdc();
IntPtr dc2 = g2.GetHdc();
BitBlt(dc2, 0, 0, this.ClientRectangle.Width, this.ClientRectangle.Height, dc1, 0, 0, 13369376);
g1.ReleaseHdc(dc1);
g2.ReleaseHdc(dc2);
Bitmap bmp = new Bitmap(MyImage);
int x = e.MarginBounds.X;
int y = e.MarginBounds.Y;
int width = bmp.Width;
int height = bmp.Height;
if ((width/e.MarginBounds.Width) > (height/e.MarginBounds.Height))
{
width = e.MarginBounds.Width;
height = bmp.Height * e.MarginBounds.Width/bmp.Width;
}
else
{
height = e.MarginBounds.Height;
width = bmp.Width * e.MarginBounds.Height/bmp.Height;
}
System.Drawing.Rectangle destRect = new System.Drawing.Rectangle(x, y, width, height);
e.Graphics.DrawImage(bmp, destRect, 0, 0, bmp.Width, bmp.Height, System.Drawing.GraphicsUnit.Pixel);
}
Faites également 700 x 700 pixels sur papier. Il sera tranchant mais malheureusement vous aurez besoin d'une loupe pour le voir. Ne pas imprimer les formulaires. –
@Hans Passant: cela rend mon problème encore pire .. :(.. alors je dois imprimer un fichier PDF à partir de mon code sans aucun lecteur PDF installé sur la machine ... Est-ce possible en C# ..? –