如何在Brother SDK上更改纸张尺寸?

时间:2019-05-09 04:34:38

标签: android ios react-native printing

我在我的应用上拍摄了快照,并尝试从Brother打印机(兄弟QL-720NW)将其打印出来。纸张与图像的比例为1:1。

但是我不知道如何在IOS上更改纸张尺寸。

我可以找到有关在Android上设置纸张尺寸的代码。

PrinterInfo myPrinterInfo = new PrinterInfo();
myPrinterInfo.paperSize = PrinterInfo.PaperSize.CUSTOM;

但是我在IOS上找不到它。

我尝试添加printInfo.nCustomLengthprintInfo.nCustomLength不起作用。

我仍然尝试调整图像大小并打印出来,但仍然无法正常工作。

这是我在IOS上关于印刷品的代码:

func printFromIos(_ filePath: String) {

    let printer = BRPtouchPrinter()

    printer.setPrinterName("Brother QL-720NW")
    printer.setInterface(CONNECTION_TYPE.WLAN)
    printer.setIPAddress("192.168.1.68")

    let printInfo = BRPtouchPrintInfo()

    printInfo.strPaperName = "62mm"
    printInfo.nPrintMode = PRINT_FIT
    printInfo.nDensity = 0
    printInfo.nOrientation = ORI_LANDSCAPE
    printInfo.nCustomLength = 10 // doesn't work
    printInfo.nCustomWidth = 10 // doesn't work
    printInfo.nHalftone = HALFTONE_ERRDIF
    printInfo.nHorizontalAlign = ALIGN_CENTER
    printInfo.nVerticalAlign = ALIGN_MIDDLE
    printInfo.nPaperAlign = PAPERALIGN_LEFT

    printInfo.nAutoCutFlag = 1
    printInfo.nAutoCutCopies = 1

    printer.setPrintInfo(printInfo)

    printer.isPrinterReady()

    // get the png from its path and transform to UIImage
    let image = UIImage(contentsOfFile: filePath)


    if printer.startCommunication() {
      let result = printer.print(image?.cgImage, copy: 1)

      if result != ERROR_NONE_ {
        print (" Printing Error!")
      }
      printer.endCommunication()
      print("✔️ Successfully printed badge")
    } else {
      print(printer.startCommunication())
      print(" Printer Communication Error!")
    }

  }

任何人都知道如何在IOS上更改纸张尺寸吗?非常感谢。

0 个答案:

没有答案