Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

I would like to know how could i print in a pvc card  with c# and .NET?

Posted on 2009-04-03
1
Medium Priority
?
1,790 Views
Last Modified: 2012-05-06
I would like to know how could i print in a pvc card? Using GDI+? Whta's the exact size of a PVC Card in pixels?. If you have any other recomendation i'll be pleased. Thanks in advance.
0
Comment
Question by:rdelossantos
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 11

Accepted Solution

by:
dbrckovi earned 2000 total points
ID: 24086338
Hi!

I assume you have a printer for PVC cards which is installed as normal windows printer.

If that's the case then something like this should do the job for you:
 - get a background image. I found that 1004 x 638 looks best on the printer we have (Evolis Pebble 4)
 - place a PrintDocument control on the form
 - make button which will be used to start printing
 - put the code from below into button_Click and printDocument1_Print events

Please note that I haven't tested this code.
I have pasted it from different places from my application, so you'll probably have to adopt it to your application.

private void button1_Click(object sender, EventArgs e)
{
     //printer selection dialog 
     PrintDialog PD = new PrintDialog();
     DialogResult DR = PD.ShowDialog();
 
     //if printer is selected
     if (DR == DialogResult.OK)
     {
          PaperSize PrinterPaperSize = PD.PrinterSettings.PaperSizes[0];
     
          //you might skip this check if names are different on your printer
          if (PrinterPaperSize.PaperName != "CR80 Card")
          {
               MessageBox.Show("Selected printer doesn't support PVC cards");
          }
          else
          {
                printDocument1.PrinterSettings = PD.Printersettings;
                printDocument1.Print();
          }
      }
}
 
 
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
     //load background image
     Image background = Image.FromFile("c:\\aaa\\image.bmp");
     //create graphics object. we use it to draw onto background image
     Graphics g = Graphics.FromImage(background);
 
     //draw some strings
     Font PrintFont = new Font("Arial",11);
     SolidBrush PrintBrush = new SolidBrush(Color.FromArgb(0,54,121));
     g.DrawString("ABC123", PrintFont, PrintBrush, 235, 525);
     g.DrawString("Name surname", PrintFont, PrintBrush, 780, 525);
 
     //draw some shapes
     g.DrawRectangle(Pens.Red, 30, 60, 127, 450);
     g.DrawEllipse(Pens.Green, 145, 274, 380, 500);
 
     //when all drawing to the image is done, tell printer to print it 
 
     Rectangle PrintRect = new Rectangle(0, 0, printDocument1.PrinterSettings.PaperSizes[0].Width, printDocument1.PrinterSettings.PaperSizes[0].Height);
     e.Graphics.DrawImage(imgBackground, PrintRect);
 
}

Open in new window

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question