Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/292.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#打印文档打印图像_C#_Zebra Printers_Printdocument - Fatal编程技术网

C#打印文档打印图像

C#打印文档打印图像,c#,zebra-printers,printdocument,C#,Zebra Printers,Printdocument,我一直在尝试通过标签打印机打印条形码图像。但是使用SATO CG408打印机打印的图像非常小。以下是当前的代码 static void Main(string[] args) { try { PrintDocument pd = new PrintDocument(); pd.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSi

我一直在尝试通过标签打印机打印条形码图像。但是使用SATO CG408打印机打印的图像非常小。以下是当前的代码

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));
    }
不太清楚为什么图像显示得很小。正在打印的图像是在不同的服务器上生成的。图像大小为2480px乘以1748px


能找个人帮忙吗。在过去的几天里试图解决这个问题。提前谢谢。

也许你应该确定你的方向。。。 试试这个:

pd.DefaultPageSettings.Landscape = true; 
尝试删除边距

int leftMargin = 0;
int rightMargin = 0;
并检查进气比:2480px/1748px~1.419400px/450px~0889。因此,不妨尝试:

int printHeight = 420;
int printWidth = 596;

问题是打印机为纸张设置了错误的尺寸。这就是为什么它打印得这么小。我现在觉得很傻。谢谢大家的帮助