NSAttributedStringクラスで見つかった異常な動作です。ドキュメントによると、このクラスのオブジェクトはさまざまな種類のデータを生成できます。私はテキストをdocxの現代的なフォーマットに変換したい。再度docsによると、私はNSOfficeOpenXMLTextDocumentTypeドキュメント属性を使用する必要があります。だから私は:NSAttributedString dataFromRangeは、テールインデントのないdocxファイルを生成します。
// produce an NSAttributedString with all of the indents have set
let stringToConvert = currentDocument.computePrintableAttributedString(forProduct: product)`
// now create a document attributes dictionary
let documentAttributes = [NSDocumentTypeDocumentAttribute : NSOfficeOpenXMLTextDocumentType]
// finally convert the string into the docx data
do {
let convertedData = try stringToConvert.dataFromRange(fullLength, documentAttributes: documentAttributes)
} catch {
print(error)
}
すべてうまくいきます。私はファイルにデータを書き込む。 MS Wordで開きます。そしてすべてがうまくいくように見えます...文書では、属性付き文字列の段落スタイルのすべての尾のインデントを失っています。
私は間違っていますか?エクスポートされたdocxドキュメントの末尾インデントを保持する方法は?
私はNSRTFTextDocumentType属性を試していますが、本当にうまく書式設定されたrtfファイルにすべてのテールインデントを配置しています。
NSOfficeOpenXMLTextDocumentTypeには何がありますか?
振る舞いを再現できるように、テキストの例(テールインデント付き)を提供することがあります。 –