using System;
using Microsoft.Office.Interop.Word;
namespace PageSetup
{
class TestPageOrientation
{
static void Main(string[] args)
{
var app = new Microsoft.Office.Interop.Word.Application();
app.Visible = true;
//Load Document
Document document = app.Documents.Open(@"C:\Temp\myDocument.docx");
// I've added this rows below. ...And that works
document.Sections.First.PageSetup.Orientation = WdOrientation.wdOrientLandscape;
document.Sections.Last.PageSetup.Orientation = WdOrientation.wdOrientLandscape;
document.PageSetup.Orientation = WdOrientation.wdOrientLandscape;
// ... and this. But the LeftMargin I can leave it.
document.PageSetup.LeftMargin = 1.00F;
document.Save();
}
}
}
我不知道它在 Word 库源中是如何工作的。但是我已经尝试过 WdOrientation.wdOrientPortrait 并且有一次让我感到惊讶。我在横向格式中看到了这个页面。
我认为我的文档部分有问题,因为文档(有很多表格、图形和图像)太大了。这只是在使用这种方法之后。
所以我的下一个问题是:如何缩小这个 Word 文档的大小?
我该怎么做才能限制这个word文档中格式设置的数量?