Click here to Skip to main content
15,893,722 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Can anyone help me out how to go about designing a ID card in WPF.
I want all the data to be together wit the picture to be pulled out from the Text-block without Data Base.
Just hit the pint button and card will be printed. can anyone give me some hints.
If you have source code please give it to me.
Posted

1 solution

As I am more familiar with Windows Forms I would chose that path, unless there is a requirement to use WPF.

Create a form with the number of TextBox you need, add a PictureBox for the ID photo and add a PrintPreviewControl[^] to the form.

Every time toy change any data or the picture, you call the method printPreviewControl.InvalidatePreview().

You also need a PrintDocument[^] that you connect to the PrintPreviewControl.
Implement the event PrintDocument.PrintPage and do all drawing here.
Small example: (You have better examples at MSDN)
C#
private void printDocument_PrintPage(object sender, PrintPageEventArgs e)
{
    Graphics g = e.Graphics;

    if (pictureBox.Image != null)
        g.DrawImage(pictureBox.Image, 0, 0, 200, 200);
    g.DrawString("Hello World", new Font("Arial", 10.0F), 
                new SolidBrush(Color.Blue), 10, 250);
}

Note that the units are in 100 of an inch. (4" = 400 units)

This way you can "print" everything to the preview control instead of wasting paper.

When you want to send the data to a printer, call the method PrintDocument.Print().
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900