Я пытаюсь создать файлы OOXML .docx программно с использованием тегов altChunk для вставки простого текста из файлов в соответствии с этой статьей .Мне удалось создать файл docx (который представляет собой просто zip-файл с фиксированной внутренней структурой), но когда я открываю файл в LibreOffice, содержимое файла .txt не включается.
.docx
altChunk
.txt
Содержимое файлаФайл r0b025d0e-c9a2-4fc7-80cd-42358fe280b5.txt - это просто обычный текст.Моя долгосрочная цель - внедрить содержимое некоторого html-файла, но сначала я бы хотел, чтобы он работал только с простым текстом.
r0b025d0e-c9a2-4fc7-80cd-42358fe280b5.txt
Содержимое моего [Content_Types].xml файла:
[Content_Types].xml
<?xml version="1.0" encoding="UTF-8"?> <Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"> <Override PartName="/r0b025d0e-c9a2-4fc7-80cd-42358fe280b5.txt" ContentType="text/plain"/> <Override PartName="/_rels/.rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/> <Override PartName="/docProps/app.xml" ContentType="application/vnd.openxmlformats-officedocument.extended-properties+xml"/> <Override PartName="/docProps/core.xml" ContentType="application/vnd.openxmlformats-package.core-properties+xml"/> <Override PartName="/word/_rels/document.xml.rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/> <Override PartName="/word/settings.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml"/> <Override PartName="/word/fontTable.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml"/> <Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/> <Override PartName="/word/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml"/> </Types>
Файл document.xml:
document.xml
<?xml version="1.0" encoding="UTF-8"?> <a:document xmlns:xml9930="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:xml9931="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" xmlns:a="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:b="http://schemas.openxmlformats.org/markup-compatibility/2006" b:Ignorable="xml9930 xml9931"> <a:body> <a:altChunk xmlns:c="http://schemas.openxmlformats.org/package/2006/relationships" c:id="r0b025d0e-c9a2-4fc7-80cd-42358fe280b5"/> <a:sectPr><a:type a:val="nextPage"/> <a:pgSz a:w="11906" a:h="16838"/> <a:pgMar a:left="1134" a:right="1134" a:header="0" a:top="1134" a:footer="0" a:bottom="1134" a:gutter="0"/> <a:pgNumType a:fmt="decimal"/> <a:formProt a:val="false"/> <a:textDirection a:val="lrTb"/> </a:sectPr> </a:body> </a:document>
Файл _rels/.rels:
_rels/.rels
<?xml version="1.0" encoding="UTF-8"?> <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"> <Relationship Id="r0b025d0e-c9a2-4fc7-80cd-42358fe280b5" Target="r0b025d0e-c9a2-4fc7-80cd-42358fe280b5.txt" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/aFChunk" TargetMode="Internal"/> <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officedocument/2006/relationships/metadata/core-properties" Target="docProps/core.xml"/> <Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="docProps/app.xml"/> <Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml"/> </Relationships>
Файл docx успешно загружается и когда я размещаю текст (в тегах p)) до или после тегов altChunk они отображаются правильно.Однако вместо тегов altChunk содержимое txt-файла не импортируется.
p
Поэтому я считаю, что синтаксис и общая семантика верны, но что-то по-прежнему отсутствует.Мои вопросы: altChunk поддерживается в LibreOffice?В чем здесь ошибка, и как сделать так, чтобы содержимое файла txt появилось и в файле docx?Большое спасибо.