-1

I have been trying to print a barcode image via the label printer. but the image that is printing using the SATO CG408 printer is very small. Here is the code as it is currently.

static void Main(string[] args)
    {
        try
        {
            PrintDocument pd = new PrintDocument();
            pd.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("Custom", 100, 77);

            //We want potrait. 
            pd.DefaultPageSettings.Landscape = false;
            pd.PrintPage += PrintPage;
            pd.Print();
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
            Console.ReadLine();
        }
    }

    private static void PrintPage(object o, PrintPageEventArgs e)
    {
        //System.Drawing.Image img = System.Drawing.Image.FromFile(@"c:\test\test.png");
        //img.RotateFlip(RotateFlipType.Rotate90FlipNone);
        //e.Graphics.DrawImage(img,0,0);

        int printHeight = 450;
        int printWidth = 400;
        int leftMargin = 20;
        int rightMargin = 0;
        System.Drawing.Image img = System.Drawing.Image.FromFile(@"c:\test\test.png");
        img.RotateFlip(RotateFlipType.Rotate90FlipNone);

        e.Graphics.DrawImage(img, new Rectangle(leftMargin, rightMargin, printWidth, printHeight));
    }

Not really sure why the image is displaying small. The image that is being printed is generated at a different server. The image size is 2480px by 1748px.

enter image description here

Can some one please help. Trying to solve this for the past few days. Thanks in advance.

dogwasstar
  • 852
  • 3
  • 16
  • 31

3 Answers3

0

maybe you should set your direction ... try this:

pd.DefaultPageSettings.Landscape = true; 
0

Try to remove margins

int leftMargin = 0;
int rightMargin = 0;

and check imgage ratio: 2480px / 1748px ~ 1.419, 400px / 450px~ 0,889. So maybe try:

int printHeight = 420;
int printWidth = 596;
daniell89
  • 1,832
  • 16
  • 28
0

The problem was that the printer had the wrong dimensions set up for the paper. Thats why it was printing so small. Feel silly now. Thanks all for help.

dogwasstar
  • 852
  • 3
  • 16
  • 31