Hi Martin,
Based on my understanding, you want to use GDI+ to draw image, then print
them out.
I have tried your code, I think there is not much problem about it. Only
that I think the height you set for your rectText is too small, you'd
better set it to 100, not 10.(Or you can only display part of the text)
How do you print your drawing picture? I think you may use PrintDocument
class. On machine, I have used PrintDocument with your code snippet to
print out the image, the text really on top of the picture. So I do not
know why your problem arise.
I think you may first try to use PrintPreviewDialog to preview the
pre-print document, if the print preview works well, I think the problem
should be your printer. The code snippet like this:
PrintDocument pd=null;
private void button1_Click(object sender, System.EventArgs e)
{
try
{
Font printFont = new Font("Arial", 10);
pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(this.pd_PrintPage);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void pd_PrintPage(object sender, PrintPageEventArgs ev)
{
Rectangle rect = new Rectangle(10, 10, 100, 100);
Rectangle rectText = new Rectangle(40, 40, 300, 100);
StringFormat sf = new StringFormat();
Bitmap b= new Bitmap("D:\\1_p1.JPG");
ev.Graphics.DrawImage(b, rect);
ev.Graphics.DrawString("TEXT", new Font("Impact", 20), new
SolidBrush(Color.Red), rectText, sf);
}
private void button2_Click(object sender, System.EventArgs e)
{
PrintPreviewDialog dlg = new PrintPreviewDialog() ;
dlg.Document=pd;
dlg.Show();
}
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.