- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我想使用 iOS 应用程序创建以下文件类型之一:RTF、DOC 或 DOCX。用户应该能够编写文本并向其添加图像。UI 的构建不是问题,问题只是文件的创建。
有什么最佳实践可以做到这一点吗?!
第 3 方框架是一个选项,但我想自己做。
谢谢
最佳答案
我可以帮助您获取 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>
Docx 使用 <w:p>
段落标签。它使用 <w:r>
对于具有一种格式的文本 block 。它使用 <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"/>
关于ios - 在 iOS 中创建 RTF 、 DOC 或 DOCX,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16914677/
我有一个来自 C# 库的 Paragraph 对象 DocX并尝试设置 LineSpacing 属性但没有任何效果? internal static Paragraph StandardFormat(
我正在寻找一种方法来提取文档中每个单词的位置 (x, y) 和属性(字体/大小)。 从 python-docx 文档中,我知道: Conceptually, Word documents have t
我有一个带有空表的 .docx 模板,我要在其中添加值: def manipulate_table(): table = doc.tables[0] table.cell(0, 0).text = '
我目前正在开发一个将 docx 文件作为输入并使用它来构建 html 页面的库,由于 docx 的模糊和缺乏文档,我不得不严重依赖示例输出来决定如何处理某些事情。其中之一是超链接。 就我目前所见,do
使用以下代码,我尝试创建一个文档,其中第 2 页和第 3 页为横向,而其他页为纵向。所有尺寸都应为 8.5"x 11"。 using (System.IO.MemoryStream ms = new
我使用了 python-docx 中的示例,在运行代码后,我找不到 docx 文件在哪里,我可以指出要添加的特定路径吗? from docx import Document from docx.sha
我对 python-docx 中“运行级别内容”的概念有些困惑。我明白,如果我想检查一个段落是否以粗体显示,我需要检查 run.bold,但究竟是什么它? 官方定义是:运行是与内联内容最密切相关的对象
我了解到 .docx 文件基本上是二进制文件。但我不知道下面的结构。 .docx 文件的基本结构是什么?比如,标题有多长?实际的文档内容从什么时候开始?最后有签名吗? 基本上,.docx 文件的结构是
我正在尝试将 .adoc 文件转换为 .docx 实际上我正在使用: asciidoctor file.adoc -o file.html pandoc -s -S file.html -o outp
我可能错过了一些东西或犯了一个错误,无论如何,我似乎无法访问 .docx 模板中字典中的数据。文档说它的工作方式类似于 jinja2,但使用 {{ dict['dict_key'] }} 即使在 if
我遇到了有关如何使用 C# 合并 docx 文件的解决方案: Append multiple DOCX files together 在此解决方案中,他遍历文件并将正文“outerxml”复制到新文档
我正在使用 Docx dll 获取段落信息但无法获取段落格式(字体大小-字体名称-字体颜色) 这是我的代码: using (DocX document = DocX.Load("Tes
使用 Markdown 代码块时,DOCX 文档中生成的等宽字体大小太大。 我可以通过指定自定义 template.docx 文件来调整段落的字体大小,但由于某种原因,生成的代码块不使用段落样式,这与
doc=Document() table = doc.add_table(rows = 13, cols = 5) table.style = 'Table Grid' row = table.row
我想打开一个现有的 Word 文档,我已经在其中添加了页码,然后向其中添加了一些文本和标题。 这是我如何尝试实现目标的基本示例 #!/usr/bin/env python from docx impo
我想使用 DocX Library 将图像添加到 C# 中的 Word 文件中.问题是我在网上找不到任何东西。 情况 我知道如何创建文件,我知道如何在文件中写入文本。遗憾的是,图书馆的文档非常小。希望
我已经下载并开始使用 DocX library .我有一个名为 template.docx 的文档正在加载到内存中。我在该文档中有一个表,其中包含 id = 241。我想通过它的 id 获取该表并向其
是否可以使用应用了样式的 python-docx 将 HTML 插入到文档中?我唯一需要做的就是斜体。 例如如何插入"Today is Saturday."星期六实际上是用斜体插入的吗? 谢谢! 最佳
我想在命令行 (Linux) 中执行此操作,这样我就可以自动执行它,而无需在中间设置用户界面。 最佳答案 WordprocessingML 中没有明确的页面布局模型。 但是,如果文件最后是由 Word
我必须以 docx 格式存储一些文档,但无法忍受使用 msword:我想编辑某种纯文本标记,除了基于 XML 的东西(我也不喜欢那样)和从/到那个到/从 docx 转换。 有什么选择吗? 编辑:由于人
我是一名优秀的程序员,十分优秀!