简体   繁体   English

Expo 打印在 Expo go 中有效,但在构建 apk 中无效

[英]Expo Print works in Expo go but not in build apk

I am trying to use the expo print api to be able to generate and print a receipt, however on button press it shows the preview on development (the expo go app) but on the build apk, nothing is shown.我正在尝试使用 expo 打印 api 来生成和打印收据,但是在按下按钮时它显示了开发预览(expo go 应用程序)但是在构建 apk 上,没有显示任何内容。 Here is my implementation:这是我的实现:

This hook generates my html data:这个钩子生成我的 html 数据:

  export const DynamicTable = async () => {   
   const receipthtml = `
       <html>
       <head>
       <style>
       </style>
       <body> 
       //some html
       </body> 
       </html>`
       return receipthtml;
        }

function to do the printing function做印刷

   const dynamiccontainer =DynamicTable(); //accessing the html data
   const printReceipt = async () => {   
   await Print.printAsync({
   html:await dynamiccontainer,
   height: 1754,
   width: 1240,
  });
 };



 <Button
        text="Print Receipt"
        backgroundColor="#0091ea"
        rippleColor="#367588"
        borderRadius={8}
        paddingHorizontal={5}
        icon={faPrint}
        onPress={printReceipt}
        height={50}
      ></Button>

I don't seem to find anything wrong with my implementation我似乎没有发现我的实施有任何问题

check if you have a base64 image, the problem is that the eas build command doesn't upload certain files.检查您是否有 base64 图像,问题是 eas build 命令没有上传某些文件。 In the case of images, if they aren't used as splah or icon, they aren't found and the print dosen't open.在图像的情况下,如果它们不用作 splah 或图标,则找不到它们并且打印不会打开。 Then it will work in expo go, but when you generate the app it won't anymore.然后它会在 expo go 中工作,但是当你生成应用程序时它就不会再工作了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM