1
votes

I'm trying to print userdata to a smartcard using a smartcard printer but the result is that i'm getting blank cards out of the printer. I've been stuck on this problem for a day now and there is no(findable) answer on the internet.

With printing to the printer (it's an Datacard SP35 Plus) using no custom papersize and no printdialog. the result is an empty card.

using (PrintDocument pd = new PrintDocument())
{
    pd.PrintPage += (object sender, PrintPageEventArgs e) =>
    {
        Image i = Image.FromFile("E:\\tmp.png");
        e.Graphics.DrawImage(i, e.MarginBounds);
    };

    pd.Print();
}

The image is present and visible and plenty of size.

Furthermore, I came across a post that said that the size of the printdocument has to be set

PaperSize papersize = new PaperSize("Custom", Convert.ToInt32(widthInInch * 100), Convert.ToInt32(heightInInch * 100));
pd.DefaultPageSettings.PaperSize = papersize;
pd.PrinterSettings.DefaultPageSettings.PaperSize = papersize;

But didnt result in a visible print.

I've also tried

e.Graphics.DrawImage(i, 0, 0);

instead of

e.Graphics.DrawImage(i, e.MarginBounds);

but didn't result in a visible print.

The widthInInch is 3.38 and the heightInInch is 2.13(The default size of an CR80 card). This also resulted in an empty card.

When I print to PDF the result is visible and correct(I do not know the whitespace, of course).

Does somebody see the problem or has worked out something similar?

1
As far as I know this printer comes with SDK which contains examples...does the examples work?vlp
I haven't tried the sdk yet. I will keep you updated @vlpKoen Vuurens

1 Answers

0
votes

I "fixed" it by rewriting my application to UWP. This uses the new print function and made it work as intended.