您可能需要查看以下链接:
http://social.msdn.microsoft.com/Forums/office/en-US/e48b3126-941d-490a-85ee-e327bbe7e81b/convert-specific-word-pages-to-pdf-in-c?forum=worddev,该链接展示了如何从Word文档中获取特定的页面范围(并保留格式)。
以下是相关部分(以防链接失效):
打开一个Word实例。
Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application();
打开您的文档。在打开文件后,您需要为您的选择准备范围。Count和count2是您在特殊情况下提供的页面编号。
object what = WdGoToItem.wdGoToPage;
object which = WdGoToDirection.wdGoToFirst;
object count = 1;
Range startRange = word.Selection.GoTo(ref what, ref which, ref count, ref oMissing);
object count2 = (int)count + 3;
Range endRange = word.Selection.GoTo(ref what, ref which, ref count2, ref oMissing);
endRange.SetRange(startRange.Start, endRange.End - 1);
endRange.Select();
Selection.Copy()将所选页面复制到剪贴板,同时保留格式。
word.Selection.Copy();
其余的源代码会创建一个新文档,将您的选择粘贴在其中。
word.Documents.Add();
word.Selection.Paste();
object outputFileName = "d:\\test1.doc";
object fileFormat = WdSaveFormat.wdFormatDocument97;
word.ActiveDocument.SaveAs(ref outputFileName,
ref fileFormat, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing);
我希望这能对您有所帮助。