OPOS 收据去除顶部边距

huangapple go评论79阅读模式
英文:

OPOS reciept remove top margin

问题

我正在使用C#来使用OPOS命令打印收据。我打印的所有收据都带有一个很大的上边距。
我已经使用爱普生(Epson)和斑马(Xprinter)进行了测试,结果都是一样的。是否有任何解决方法?

以下是我的代码:

public bool OpenPrint(string szPrinterName)
{
    if (PrinterOpen == false)
    {
        di.pDocName = ".NET RAW Document";
        di.pDataType = "RAW";

        if (OpenPrinter(szPrinterName.Normalize(), ref hPrinter, IntPtr.Zero))
        {
            if (StartDocPrinter(hPrinter, 1, di))
            {
                if (StartPagePrinter(hPrinter))
                    PrinterOpen = true;
            }
        }
    }

    return PrinterOpen;
}

public bool SendStringToPrinter(string szPrinterName, string szString)
{
    if (PrinterOpen)
    {
        IntPtr pBytes;
        Int32 dwCount;
        Int32 dwWritten = 0;

        dwCount = szString.Length;

        pBytes = Marshal.StringToCoTaskMemAnsi(szString);

        var res = WritePrinter(hPrinter, pBytes, dwCount, ref dwWritten);
        Marshal.FreeCoTaskMem(pBytes);
        return res;
    }
    else
        return false;
}

public void ClosePrint()
{
    if (PrinterOpen)
    {
        EndPagePrinter(hPrinter);
        EndDocPrinter(hPrinter);
        ClosePrinter(hPrinter);
        PrinterOpen = false;
    }
}

[![enter image description here][1]][1]


  [1]: https://i.stack.imgur.com/xD5s7.png

<details>
<summary>英文:</summary>

I&#39;m using OPOS commands to print receipts using C#. All the receipts I print comes with a large top margin.
I have tested this with both epson and xprinter and the results are same. Are there any workaround for this?

My codes are given below

    public bool OpenPrint(string szPrinterName)
        {
            if (PrinterOpen == false)
            {
                di.pDocName = &quot;.NET RAW Document&quot;;
                di.pDataType = &quot;RAW&quot;;

                if (OpenPrinter(szPrinterName.Normalize(), ref hPrinter, IntPtr.Zero))
                {
                    if (StartDocPrinter(hPrinter, 1, di))
                    {
                        if (StartPagePrinter(hPrinter))
                            PrinterOpen = true;
                    }
                }
            }

            return PrinterOpen;
        }

    public bool SendStringToPrinter(string szPrinterName, string szString)
        {
            if (PrinterOpen)
            {
                IntPtr pBytes;
                Int32 dwCount;
                Int32 dwWritten = 0;

                dwCount = szString.Length;

                pBytes = Marshal.StringToCoTaskMemAnsi(szString);

                var res = WritePrinter(hPrinter, pBytes, dwCount, ref dwWritten);
                Marshal.FreeCoTaskMem(pBytes);
                return res;
            }
            else
                return false;
        }

    public void ClosePrint()
        {
            if (PrinterOpen)
            {
                EndPagePrinter(hPrinter);
                EndDocPrinter(hPrinter);
                ClosePrinter(hPrinter);
                PrinterOpen = false;
            }
        }


[![enter image description here][1]][1]


  [1]: https://i.stack.imgur.com/xD5s7.png

</details>


# 答案1
**得分**: 1

这通常是由打印头和切纸器之间的间隙造成的。
由于物理位置的原因,没有打印机对此免疫。

然而,一些打印机可以通过固件中的特殊功能/模式设置来减小边距。
请向您的打印机供应商询问您的打印机是否具有此类功能/模式,如果有的话,如何使用它。

对于没有此类功能/模式的打印机,一般的过程是在每次打印收据之前打印下一个收据的开头,然后切纸。

<details>
<summary>英文:</summary>

This is generally due to the gap between the printhead and paper cutter.  
Due to the physical position, no printer is more or less immune to it.  

However, some printers can reduce the margins by special feature/mode settings in the firmware.  
Please ask your printer vendor if your printer has such a feature/mode, and if so, how to use it.  

For printers that do not have such a feature/mode, the general process is to print the beginning of the next receipt before cutting the paper each time a receipt is printed.  


</details>



huangapple
  • 本文由 发表于 2023年1月9日 18:23:20
  • 转载请务必保留本文链接:https://go.coder-hub.com/75055872.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定