Unity call the pit printer encountered

For personal study

1. Universal Print

System.Diagnostics.Process.Start("mspaint.exe", "/pt d:\\screenshots\\sample.jpg");

//"mspaint.exe "represents a sketchpad program.

//"d:\\screenshots\\sample.jpg "represents the absolute path of the pictures.

Note that this is a call to the native drawing program

So unity if it is to print images of 1080 * 1920, then there will be some problems. As shown below

2. This time we should consider other approaches, I have here is to find a plug-in (LCPrint).

Print.PrintTexture (texture2D.EncodeToPNG (), 1, ""); // print the picture, copy number, name of the picture

Print.PrintTextureByPath ( "D: \\ pic.png", 1, ""); // print images specified path, copy number, name of the picture

Using this method, then, to keep the size of the photo printer to print matching, if the mismatch error:

paper size of pinter driver and indribbon type do not match.

Pinter paper size and the print ribbon drive does not match that

3. Use win comes with software

The method by https://blog.csdn.net/qq_42855293/article/details/81981308

 public void MyPrint()
    {
        string path = Application.dataPath + @"\Textures\002.png,0,0,750,400";//图片路径 + 将图像调整为750×400点(计算:750mm/28.346 px/cm=529点,400mm/28.346 pm/cm=352点)
        string exepath = Application.streamingAssetsPath + @"\PrintImage.exe";//这个是需要下载的应用直接放到电脑上就行(调用打印机打印图片应用的路径)
        ProcessStartInfo info = new ProcessStartInfo(exepath);//指定启动进程时使用的一组值
        info.Arguments = path;//获取或设置启动应用程序时要使用的一组命令行自变量
        using (Process p=new Process())
        {
            p.StartInfo = info;
            p.Start();
        }
    }

 

Published 23 original articles · won praise 13 · views 10000 +

Guess you like

Origin blog.csdn.net/qq_42047805/article/details/91041436