是否可以在xcode中使用JavaScript将文件(例如pdf)写入iPad(本地)

Is it possible to write a file (e.g. pdf) to the iPad (locally) using JavaScript in xcode?

本文关键字:本地 文件 例如 pdf 写入 iPad JavaScript xcode 是否      更新时间:2023-09-26

到目前为止,我有一个运行javascript代码的html链接,但我不确定下一步该怎么做。

基本上我想:

  1. 按下超链接
  2. 运行JavaScript代码
  3. 读取文件
  4. 将文件写入iPad上的本地目录

这是我到目前为止的代码:

<a id="mylink"><img src="../assets/images/research/Download.jpg"></a>
<script type="text/javascript">
    window.onload = function() {
        var a = document.getElementById("mylink");
        a.onclick = function() {
            console.log("WORKED");
            //here is where it will read/write the file
        }
    }
</script>

我在objectivec中看到了很多webview的例子,但我尝试过这些,它会打乱应用程序的布局。

查看Apple文档中的Quartz 2D编程指南以创建PDF文件

MyCreatePDFFile的代码列表提供了将CGRect保存为PDF的代码。我过去曾将其改编为UIView+PDF类别。