应用程序是WPF和C#的组合,我遇到的所有代码都在C#部分......
我有一个应用程序生成一些HTML并使用MS Word Interop将其保存为PDF。我想让用户可以选择包含他们从我的应用程序中单独创建的页眉或页脚,如果他们选择这样做的话。我设法完成了这个,但我面临的问题是这个。如果在插入下一个文档时,任何文档在页面底部结束,则会在其间显示空白页。
粗略的例子:
所以,如果有人能够看到我是如何做到这一点并让我知道我的逻辑中有什么问题,或者给我一个提示,看看哪里会很棒。谢谢大家,如果我需要提供更多说明,请告诉我。
此代码的灵感来自this SO question
//Itterate through all wordFiles that have been passed in, in a string array
for ( int i = 0; i < wordFiles.Length; i++)
{
//Get the current word file
string file = wordFiles[i];
//Insert the file
wDoc.Application.Selection.Range.InsertFile(file,
ref oMissing,
ref oMissing,
ref oMissing,
ref oFalse);
if(i != 0)
//if not add a page break
wDoc.Application.Selection.Range.InsertBreak(ref wdPageBreak);
// Moves to the end of the current page
// (Same funcionality of pressing the "End" Key)
wDoc.Application.Selection.EndKey(ref wdStory, ref oMissing);
}