react-native - 如何在 native react 中打印屏幕内容?

标签 react-native printing

有没有办法在 React Native 中将屏幕内容(包含渲染的图像)打印到打印机?我研究了 react-native-print 但它只接受 HTML 文本,而 react-native-xprinter 仅支持 Android。谢谢。

最佳答案

设法让它发挥作用。请参阅下面的代码。

import RNPrint from 'react-native-print';

var htmlString = `<div style="(your CSS style here)"> (HTML contents here) </div>`;

RNPrint.print({html: htmlString});

如果您想在 HTML 中嵌入图像,请参见下文:

var htmlString = `<div style="(your CSS style here)"> 
    <img src="data:image/png;base64, ${imgData}" style="width: $imgWidth; height: $imgHeight"/>
</div>`;

您可以将“image/png”替换为其他图像类型。希望这会有所帮助。

关于react-native - 如何在 native react 中打印屏幕内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47903985/

相关文章:

德尔福打印技术

windows - 通过 Add-PrinterPort PowerShell 命令添加 IPP 端口?

在 System Verilog 中打印打包结构

html - 如何制作网页的可打印版本?

javascript - React.js 从函数返回样式属性并在 render() 函数中使用它

ios - react native : storage only works in simulator

react-native - 选项卡导航器中的图标图像被切断 - native react

javascript - react native componetWillUpdate 不起作用

react-native - 在不使用 Modal 的情况下使用 Navigator 以透明方式响应 Native Modal

c++ - 手动打印 N 字节整数