首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何阅读Word文档中的页面(C#)

如何阅读Word文档中的页面(C#)
EN

Stack Overflow用户
提问于 2012-07-27 19:22:16
回答 3查看 2.5K关注 0票数 1

我们使用PDF-Focus。我们想要导出横向格式的PDF文档到Word文档。我们要将此文档导出到Word。我们在Word中获取文档。一切看起来都很好。如果我们想打印这个新的word文档,这个文档的页边距是纵向的。

为了解决这个问题,我创建了一个空的Word文档,然后插入一个临时导出的Word文档。然后我把方向改成了横向。我看到这个解决方案是有效的。文档现在是以横向为导向的。

但现在,带有图形和其他图像的页面正在与表格重叠。

因此,我认为我必须通过读取单独的页面,然后使用循环插入,将临时文档插入到新创建的文档中。

我们应该使用什么功能来以编程方式解决这个问题?或者也许有更好的解决方案?你能帮帮我吗?

韦斯利

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2012-07-27 19:34:32

下面的代码适用于我,并打开一个更改页面方向的word文档。你是在找这样的东西吗?

代码语言:javascript
复制
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");

            document.PageSetup.Orientation = WdOrientation.wdOrientLandscape;
        }
    }
}
票数 0
EN

Stack Overflow用户

发布于 2012-07-31 21:23:43

代码语言:javascript
复制
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();
        }
    }
}

我不知道它在词库源代码中是如何工作的。但我试过WdOrientation.wdOrientPortrait,有一次我很惊讶。我看到了这个横向格式的页面。

我认为我的文档部分有问题,因为文档(包含许多表格、图形和图像)太大了。这只是在使用这个方法之后。

所以我的下一个问题是:我如何缩小这个Word文档的大小?

我要怎么做才能限制word文档中的格式设置的数量?

票数 0
EN

Stack Overflow用户

发布于 2012-09-10 17:27:46

问题是PDFFocus会将PDF格式转换成RTF格式。如果你更改设置,文档的大小将快速增长

所以我解决了这个问题,首先将它保存为带有RTF-extension.的RTF文档然后我将这个文档保存为Word97-document with a DOC-extension.

对于两个转换,我有相同的文档名。两者都带有DOC-扩展名。另存为word97文档不起作用。我认为这是Word 2007的一个错误。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11686761

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档