私はC#とOpen XML SDKを使って単語文書を生成しています。私は、いくつかの段落の向きとそのページを横向きに変更し、他の段落を縦向きにしたいと思います。
私はいくつかのソリューションを試しましたが、私が探していたものを達成せず、代わりにすべてのページの向きが最初のものを除いてランドスケープに変更されました。これらのソリューションは、次のとおりです。
を - 私が風景に その向きを変更したい段落にSectionPropertiesを追加:Open XMLとC#を使用して単一段落またはページの向きを変更する方法は?
WordprocessingDocument WordDocument = WordprocessingDocument.Open(ReportFile, true)
Paragraph paragraph = new Paragraph(new ParagraphProperties(
new SectionProperties(new PageSize()
{ Width = (UInt32Value)15840U, Height = (UInt32Value)12240U, Orient = PageOrientationValues.Landscape })));
WordDocument.MainDocumentPart.Document.Body.Append(paragraph);
- メイン文書に新しいボディを追加し、それに段落を追加:
WordprocessingDocument WordDocument = WordprocessingDocument.Open(ReportFile, true)
Body body = new Body();
Paragraph paragraph = new Paragraph(new ParagraphProperties(
new SectionProperties(new PageSize()
{ Width = (UInt32Value)15840U, Height = (UInt32Value)12240U, Orient = PageOrientationValues.Landscape })));
body.Append(paragraph);
WordDocument.MainDocumentPart.Document.Append(body);
- メイン文書に新しいボディを追加し、それに直接SectionProprtiesを追加:
WordprocessingDocument WordDocument = WordprocessingDocument.Open(ReportFile, true)
Body body = new Body();
Paragraph paragraph = new Paragraph();
SectionProperties sectionProp = new SectionProperties(new PageSize() { Width = (UInt32Value)15840U, Height = (UInt32Value)12240U, Orient = PageOrientationValues.Landscape });
body.Append(paragraph);
body.Append(sectionProp);
WordDocument.MainDocumentPart.Document.Append(body);
したがって、段落/ページの向きを変更する方法はありますか?
あなたがMSを使用して、単一の段落の向きを変えることができる場合、私は、疑いますOffice Word(アプリケーション)自体? –
カスタムマージンを使用してMS Office Wordで実行できます。このリンクを確認してください。http://www.officetooltips.com/word/tips/how_to_use_different_page_orientations_inside_one_document.html –
OKチェックしました。ただし、選択したテキストの前後にセクション区切りを挿入します。たとえば、ある風景を含む3つの段落とポートレートモードの他の段落は、3ページの文書を作成します。これは、あなたの望むことですか? –