Expo + React Native-PDF创建和下载 [英] Expo + React Native - PDF Creation & Download

查看:56
本文介绍了Expo + React Native-PDF创建和下载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否存在创建文件的可靠方法(特别是通过打印.printToFileAsync API),因为它会在用户的

Is there a reliable way to create a file (specifically via Print.printToFileAsync API), and since it creates the new file in the user's cacheDirectory, copy it across to their documentDirectory - that works in both Android and iOS?

我遇到了其他尝试做相同事情的人在这里,但是无济于事.

I've come across others trying to do the same thing here, but to no avail.

我看到的一种解决方案是使用MediaLibrary API将文件下载到设备的CameraRoll -但这很容易破解,在iPhone上不起作用,因为我要复制/下载的文件是PDF,而不是图像/电影

One solution I've seen is to use the MediaLibrary API to download the file to the device's CameraRoll - but this is hacky and doesn't work on iPhone since the file I'm trying to copy/download is a PDF, and not an image/movie.

这里也列出了各种解决方案-但是它们要么不起作用,要么只能在一个操作系统上工作.

Various solutions are listed here too - but they either don't work, or only work in one OS.

我的最终目标是能够在设备上生成PDF并将其保存到用户的存储中,而无需将信息发送回服务器.我的应用程序没有按原样弹出.

My end goal is to be able to generate a PDF on the device and save it to the user's storage, without needing to send information back to the server. My app is not ejected as it stands.

任何建议/指导将不胜感激!

Any advice/direction would be appreciated!

考虑在某个阶段弹出,但是由于我正在从事的项目的性质,我宁愿在最后完成该操作.还遇到了这篇文章试图共享文件URI ,但是Android不支持.

Considering ejecting at some stage, but due to the nature of the project I'm working on I'd prefer to do that right at the end. Also came across this post which tries to Share the file URI, but this isn't supported on Android.

推荐答案

我希望您在创建pdf时没有任何问题,以保存尝试过的文件

I hope you dont have any problem with creating the pdf,to save the file have you tried

https://github.com/Lyrillind/react-native-file-manager

它同时支持anroid和ios.

it supports both anroid and ios.

如果需要,您可以构建自己的本机模块来保存文件,

If you want you can build your own native module to save the file ,

http://facebook.github.io/react-native/docs/native-modules-ios.html#content

这篇关于Expo + React Native-PDF创建和下载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆