在 iOS 中创建 RTF 、 DOC 或 DOCX

2024-01-09

我想使用 iOS 应用程序创建以下文件类型之一:RTF、DOC 或 DOCX。 用户应该能够写文字并且添加图像到它。 UI 的构建不是问题,问题只是文件的创建。

有没有最佳实践可以做到这一点?

第三方框架是一种选择,但我想自己做。

Thanks


我可以帮助您获取 docx 文件(RTF 文件更容易,doc 文件与 docx 完全相同,但组织不太好)

我认为您能做的最好的事情就是首先在文本编辑器中打开 docx 文件。您必须首先解压缩该文件。

您将拥有以下文件夹

>_rels
>customXML
>docProps
>word:
    >_rels:
         document.xml.rels //this document tells word where the images are situated
    >media  //Here are the images
    >theme
    >document.xml //Here is the actual content of the file
    >header1.xml //Here is the content of your header
>[Content_Types].xml

要插入一些文本,请查看 document.xml 文件。

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:document mc:Ignorable="w14 wp14" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" xmlns:wpi="http://schemas.microsoft.com/office/word/2010/wordprocessingInk" xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape">
<w:body>
....
</w:body>
</w:document>

文档使用<w:p>段落标签。 它用<w:r>对于具有一种格式的文本块。 它用<w:t>对于实际文本

这将产生一个简单的 Hello world

<w:p w:rsidP="00CA7135" w:rsidR="00137C91" w:rsidRDefault="00137C91">
    <w:r>
        <w:t>Hello world</w:t>
    </w:r>
</w:p>

对于图像,您必须输入更多信息:

            <w:p w:rsidP="00CA7135" w:rsidR="00B12C70" w:rsidRDefault="00B12C70">
                <w:r>
                    <w:rPr>
                        <w:noProof/>
                        <w:lang w:eastAsia="fr-FR"/>
                    </w:rPr>
                    <w:drawing>
                        <wp:inline distB="0" distL="0" distR="0" distT="0" wp14:anchorId="7CC0BC42" wp14:editId="09031C8D">
                            <wp:extent cx="866775" cy="1323975"/>
                            <wp:effectExtent b="9525" l="0" r="9525" t="0"/>
                            <wp:docPr id="13" name="Image 13"/>
                            <wp:cNvGraphicFramePr>
                                <a:graphicFrameLocks noChangeAspect="1" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"/>
                            </wp:cNvGraphicFramePr>
                            <a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
                                <a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture">
                                    <pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture">
                                        <pic:nvPicPr>
                                            <pic:cNvPr id="0" name=""/>
                                            <pic:cNvPicPr/>
                                        </pic:nvPicPr>
                                        <pic:blipFill>
                                            <a:blip r:embed="rId15"/>
                                            <a:stretch>
                                                <a:fillRect/>
                                            </a:stretch>
                                        </pic:blipFill>
                                        <pic:spPr>
                                            <a:xfrm>
                                                <a:off x="0" y="0"/>
                                                <a:ext cx="866775" cy="1323975"/>
                                            </a:xfrm>
                                            <a:prstGeom prst="rect">
                                                <a:avLst/>
                                            </a:prstGeom>
                                        </pic:spPr>
                                    </pic:pic>
                                </a:graphicData>
                            </a:graphic>
                        </wp:inline>
                    </w:drawing>
                </w:r>
            </w:p>

该标签内的 id (13):<wp:docPr id="13" name="Image 13"/>必须是唯一的。然后,Word 将查看 document.xml.rels 以查看图像的存储位置。

文档.xml.rels:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
    <Relationship Id="rId8" Target="endnotes.xml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes"/>
    <Relationship Id="rId13" Target="media/image5.png" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"/>
    <Relationship Id="rId18" Target="media/image10.png" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"/>
    <Relationship Id="rId26" Target="header3.xml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/header"/>
    <Relationship Id="rId3" Target="styles.xml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles"/>
    <Relationship Id="rId21" Target="media/image13.png" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"/>
    <Relationship Id="rId7" Target="footnotes.xml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes"/>
    <Relationship Id="rId12" Target="media/image4.png" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"/>
    <Relationship Id="rId17" Target="media/image9.png" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"/>
    <Relationship Id="rId25" Target="footer1.xml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer"/>
    <Relationship Id="rId2" Target="numbering.xml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering"/>
    <Relationship Id="rId16" Target="media/image8.png" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"/>
    <Relationship Id="rId20" Target="media/image12.png" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"/>
    <Relationship Id="rId1" Target="../customXml/item1.xml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml"/>
    <Relationship Id="rId6" Target="webSettings.xml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings"/>
    <Relationship Id="rId11" Target="media/image3.png" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"/>
    <Relationship Id="rId24" Target="header2.xml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/header"/>
    <Relationship Id="rId5" Target="settings.xml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings"/>
    <Relationship Id="rId15" Target="media/image7.png" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"/>
    <Relationship Id="rId23" Target="header1.xml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/header"/>
    <Relationship Id="rId28" Target="theme/theme1.xml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme"/>
    <Relationship Id="rId10" Target="media/image2.png" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"/>
    <Relationship Id="rId19" Target="media/image11.png" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"/>
    <Relationship Id="rId4" Target="stylesWithEffects.xml" Type="http://schemas.microsoft.com/office/2007/relationships/stylesWithEffects"/>
    <Relationship Id="rId9" Target="media/image1.png" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"/>
    <Relationship Id="rId14" Target="media/image6.png" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"/>
    <Relationship Id="rId22" Target="media/image14.png" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"/>
    <Relationship Id="rId27" Target="fontTable.xml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable"/>
</Relationships>

如您所见,使用此标签,id 为 13 的图像位于 Target 属性处。

<Relationship Id="rId13" Target="media/image5.png" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"/>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在 iOS 中创建 RTF 、 DOC 或 DOCX 的相关文章

  • iOS 应用程序崩溃 com.apple.root.background-qos

    在应用程序中发现应用程序崩溃 我怀疑这可能是由于 firebase 观察者的代码而发生的 由于在用户案例中 用户可以从一个事件转到用户配置文件 参与此事件 然后从用户配置文件可以返回到此事件 我需要一个 ref 句柄来删除特定的观察者 因此
  • 使用 popToRootViewController 时我丢失了导航栏

    我有一个 iOS 应用程序 其中主屏幕是 UICollectionViewController 从集合视图中选择项目时 视图将推送到该项目的详细信息视图 在细节视图中 我构建了一个从侧面移出的抽屉 滑块 为了让视图看起来像我想要的那样 我隐
  • 从 Xcode iOS 项目运行 swift 脚本作为构建阶段

    这是一个简单的快速脚本 usr bin env xcrun swift import Foundation let task NSTask task launchPath bin echo task arguments farg1 arg2
  • 我可以更改导航栏项目的位置吗?

    Here is the snapshot 代码在这里 UIButton leftButton UIButton buttonWithType UIButtonTypeCustom leftButton frame CGRectMake 0
  • 如何在 iOS 中通过 wifi 传输大文件

    我下载了WiTap http developer apple com library ios samplecode WiTap Introduction Intro html代码来自苹果网站 它用于通过本地 WiFi 网络传输数据 我正在从
  • 如何将任意颜色的色度键滤镜应用到实时摄像头源ios?

    基本上我想将色度键滤镜应用到 ios 实时摄像头源 但我希望用户选择将被另一种颜色替换的颜色 我找到了一些使用绿屏的示例 但我不知道如何动态替换颜色而不仅仅是绿色 知道如何以最佳性能实现这一目标吗 您之前曾询问过我的情况GPUImage h
  • 如何在iOS应用程序中实现信号量?

    是否可以在ios应用程序中实现计数信号量 对的 这是可能的 有很多可用的同步工具 同步 NSLock NS条件 NS条件锁 GCD 信号量 并行线程锁 我建议阅读 线程编程指南 http developer apple com librar
  • 更改“返回”键盘按钮的文本

    如何将 返回 按钮的标准文本更改为其他内容 我希望它是 添加 不幸的是 您可以使用以下命令将 Return 更改为这些预定义标签之一 returnKeyType财产 返回 默认 Go Google Join Next Route Searc
  • 为什么我的 Cordova/PhoneGap iOS 应用程序在设备旋转时不旋转?

    我正在尝试做一个仅横向应用程序 https stackoverflow com questions 10996676 phonegap page has wrong rotation shows as portrait in landsca
  • xib(Xcode8) 上 UIView/UIImageView 的大小变为 (1000, 1000)

    我在 xib 上使用自动布局来创建我的 UI 当我完成我的用户界面时 它在模拟器上运行良好 但是当我下次打开 Xcode8 时 xib 显示很奇怪 一些 UIView 和 UIImageView 变大 大小变为 1000 1000 即便如此
  • XCODE:如何从设备获取/验证准确的时间戳

    在没有互联网连接的情况下是否可以获得 NTP 或准确的时间戳 我不能接受 不信任带有 NSDate date 的设备时间戳 因为它可以由用户修改 并且我的应用程序将通过修改系统日期和时间而被黑客攻击 除此之外 是否有任何方法可以检查系统日期
  • 使用 QuartzCore 为 UITextView 创建阴影 [重复]

    这个问题在这里已经有答案了 我使用创建了一个阴影QuartzCore for my UITextView使用以下代码 myTextView layer masksToBounds NO myTextView layer shadowColo
  • 从核心数据存储创建 .sqlite 文件?

    我在书籍和提供 sqlite 文件下载的网站上看到过教程 sqlite 文件用于核心数据 如何获取 sqlite 文件FROM应用程序或核心数据存储TO我的桌面 如果您要创建一个预填充的 sqlite 文件以与 Core Data 一起使用
  • 在 SwiftUI App 中实现深色模式切换

    我目前正在我的应用程序中研究深色模式 虽然由于我的 SwiftUI 基础 深色模式本身并不困难 但我正在努力选择将 ColorScheme 设置为独立于系统 ColorScheme 的选项 我在苹果人机界面指南中找到了这一点 https i
  • 将 NSData 视频文件合并为一个视频文件

    我有一堆视频文件想要合并成一个视频文件 我正在使用 NSMutableData 来完成该任务 NSMutableData concatenatedData NSMutableData alloc init for int i 0 i lt
  • 迁移大型 Core Data 数据库崩溃

    我有一个将产品存储在核心数据文件中的应用程序 这些产品包括作为 可转换 数据的图像 现在我尝试使用轻量级迁移添加一些属性 当我使用一个小型数据库对其进行测试时 它运行良好 但当我使用一个接近 500 MB 的大型数据库时 应用程序通常会因内
  • 如何安全地将 CGFloat 降低或提高到 int?

    我经常需要在地板或天花板上安装CGFloat to an int 用于计算数组索引 我永远看到的问题floorf theCGFloat or ceilf theCGFloat 是浮点不准确可能会带来麻烦 那如果我的CGFloat is 2
  • 如何在WKInterfaceLabel下面放置一个WKInterfaceLabel?

    大家好 我在 watchkit 开发中有新的东西 我有特殊要求 我将一个 WKInterfaceLabel 安排在另一个 WKInterfaceLabel 下面 我尝试使用很多关闭选项 例如编辑位置 但 WKInterfaceLabel 未
  • GIDSignIn 在提示前指定范围

    我在 iOS 上升级到 GoogleSignIn 6 0 但找不到在登录时指定登录范围的方法 我只能看到一个名为 addScopes 的 API 我可以在基本登录后指定范围 但这会导致两个单独的登录提示 这很奇怪 之前 我们可以简单地指定登
  • 滚动视图下的iOS swift 4 imageview:双击缩小

    我已经应用了图像视图来通过捏合来放大 缩小 那很容易 当在图像视图上应用双击时 无法检测到选择方法 我使用 Xcode 9 和 swift 4 您能告诉我滚动视图是否应该应用双击手势吗 var previewImage UIImage ni

随机推荐

  • 使用带有 Font Awesome 的数字

    我想使用数字列出流程中的步骤 我很好奇如何使用 Font Awesome 来做到这一点 我想使用带有 1 2 3 的圆圈 这可能吗 Font Awesome 会在图标列表中添加数字吗 Thanks 字体真棒实际上有内置支持 https fo
  • Android 工作室:NoClassDefFoundError 与 java.util.Base64

    抱歉 我扫描了许多听起来相似的问题 但没有一个对我有帮助 我正在运行 Android Studio 3 0 1 我是新手 我正在遵循在线教程 HelloWorld 程序 但随后添加了对 java util Base64 getDecoder
  • 运算符 new 将内存初始化为零

    有这样的代码 include
  • 如何在 Android 中将 ImageButton 与背景图像正确对齐?

    在使用 XML 的 Android UI 设计中 如何将 ImageButton 与 Activity xml 文件的背景完全对齐 假设我有两张图像 一张用作活动的背景图像 第二张用作图像按钮源 这是背景图像 https i stack i
  • 如何在 Python 中获得人类可读的时区名称?

    在我正在从事的一个Python项目中 我希望能够获得以下形式的 人类可读 时区名称美洲 纽约 对应系统本地时区 显示给用户 我见过的每一段访问时区信息的代码都只返回数字偏移量 0400 或字母代码 EDT 有时两者都返回 是否有一些 Pyt
  • NEAT 错误 - AttributeError:“tuple”对象没有属性“connections”

    我目前正在尝试创建一个 NEAT 算法来解决 FlappyBird 但在运行我的代码时遇到错误 参见标题 目前我已经设置了我的run功能和我的eval genomes功能 我已经简化了它们以删除pygame并试图将其保留在neat pyth
  • 如何使用vba禁用单元格中的更改?

    我正在使用以下代码 此代码的示例如下 如果我在单元格 A1 中输入任何值 单元格 B1 将显示时间戳 Private Sub Worksheet Change ByVal Target As Excel Range With Target
  • “单例”工厂,好还是坏?

    我有很多 抽象 工厂 它们通常作为单例实现 通常是为了方便 不必将它们传递给实际上与使用或了解这些工厂无关的层 大多数时候我只需要在启动时决定哪个工厂实现其余的代码程序 也许通过一些配置 它看起来例如喜欢 abstract class Co
  • 使用 Mips Assembly 读取和打印 txt 文件中的内容

    我正在尝试读取并打印 txt 文件中的内容 稍后我还想从 mips 读取转储的文件 我看到代码 看起来没问题 但没有输出任何内容 data myFile asciiz teste txt filename for input buffer
  • 从 RecyclerView 中删除行

    我在这篇文章的帮助下以某种方式实现了 recyclerview 现在我的要求是在运行时从此回收视图中删除一行 link http treyrobinson net blog android l tutorials part 3 recycl
  • 首先使用 Entity Framework 6.0 代码创建与 LINQPad 的 DbContext 连接时出现问题

    我正在使用 LINQPad v4 51 03 并尝试从 Entity Framework 6 0 6 1 1 中的代码优先实现创建 DbContext 连接 public partial class MyEntities DbContext
  • Google Apps 脚本 - 单元格中的 .setValue 基于 for 循环匹配

    我试图从数据范围中获取值 循环数据 匹配该数据中的值 然后根据匹配值更新位于几列上方的单元格 我能够找到要匹配的值 但我很难理解如何更新几列的单元格 下面是我到目前为止得到的代码 减去 setValue 部分 var trackingSS
  • 数据表中的条件差异计算

    我有一百万行长data table大约有20个柜台式的柱子 这些列显示各种存储系统操作的计数器随时间的增加 然而 有时 受监控系统上的计数器会重置 并且单个观测值低于前一个观测值 我需要计算一个opsdiff列 其中包含基于列的相同类型的后
  • iOS MKMapView 缩放以显示所有标记

    我正在与MKMapView并在地图上标出了几个点 我已经用过MKCoordinateRegion and MKCoordinateSpan围绕其中一个点启用缩放等 但这不是我想要的 我正在尝试使用类似于 Javascript 缩放到边界功能
  • 如何在 Go 中编写多行字符串?

    Go 是否有类似于 Python 的多行字符串的东西 line 1 line 2 line 3 如果不是 那么编写跨多行字符串的首选方式是什么 根据语言规范 http golang org doc go spec html String l
  • 如何在 Scala/Spark 中从多个 DataFrame 创建包含多个工作表的 Excel 文件?

    In Scala Spark应用程序我创建了两个不同的DataFrame 我的任务是为每个 DataFrame 创建一个包含两个工作表的 Excel 文件 我决定使用火花Excel https github com crealytics s
  • 包含非托管对象的 ConcurrentBag 的完成

    我在正确处理 Dispose Finalization 时遇到问题ConcurrentBag包含非托管对象 运行下面的代码 通常 会产生一个ObjectDisposedException Cannot access a disposed o
  • 在 SwiftUI 中切换视图的最佳方式是什么?

    我尝试了几种在 SwiftUI 中切换视图的选项 然而 每一个都存在一些问题 比如多次来回切换时会出现时间滞后等问题 我正在尝试找到使用 SwiftUI 切换视图的最佳和最干净的方法 我只是想制作一个多视图用户界面 In View1 swi
  • 预定的网络作业

    我正在创建一个新的 Azure WebJob 项目 它似乎是可以作为 Web 作业运行的控制台应用程序的优化版本 我希望这项工作根据时间表运行 但在Main 方法 见下文 微软为您提供了host RunAndBlock 使作业能够连续运行
  • 在 iOS 中创建 RTF 、 DOC 或 DOCX

    我想使用 iOS 应用程序创建以下文件类型之一 RTF DOC 或 DOCX 用户应该能够写文字并且添加图像到它 UI 的构建不是问题 问题只是文件的创建 有没有最佳实践可以做到这一点 第三方框架是一种选择 但我想自己做 Thanks 我可