Home > Net >  Using Aspose. Words Section complete copy of a document to another document, including the header an
Using Aspose. Words Section complete copy of a document to another document, including the header an

Time:11-04

Using Aspose. Words Section complete copy of a document to another document, including the header and footer?

String strFile=@ "C: \ \ Xp aaaaaa. Doc";
The Document originalDoc=new Document (strFile);

String strCurrentPath=System. IO. Directory. GetCurrentDirectory () + "\ ";
//
Int sectCount=originalDoc. Sections. Count;

For (int sectIndex=0; SectIndex & lt; SectCount; SectIndex++)
{
The Document mainDoc=new Document ();
MainDoc. FirstSection. Body. RemoveAllChildren ();
//NodeImporter importer=new NodeImporter (originalDoc, mainDoc, ImportFormatMode. KeepSourceFormatting);

Aspose. Words. Section srcSection=originalDoc. Sections [sectIndex];
//the Node dstSection=originalDoc. ImportNode (srcSection, true, ImportFormatMode. KeepSourceFormatting);
//mainDoc. The AppendChild (dstSection);
Int nodeCount=srcSection. Body..childnodes. Count;
NodeImporter importer=new NodeImporter (originalDoc, mainDoc, ImportFormatMode. KeepSourceFormatting);
For (int nodeIndex=0; NodeIndex & lt; NodeCount; NodeIndex++)
{
The Node srcNode=srcSection. Body..childnodes [nodeIndex];
The Node newNode=importer. ImportNode (srcNode, true);
MainDoc. FirstSection. Body. The AppendChild (newNode);
}
MainDoc. Save (strCurrentPath + (sectIndex + 1). The ToString () + ". "doc, Aspose. Words. SaveFormat. Doc);
}
MessageBox. Show (" process completed ");


The code above content can be copied in the past now, but failed to replicate the past, pages and footer excuse me is there any way to deal with,

CodePudding user response:

How is not over,

CodePudding user response:

I used your method, which is jointly and severally header, footer can import oh

CodePudding user response:

Header, footer in the section, not in the Body, in company with the Body, your code is copied node in the Body, can't replicate HeaderFooter, of course, because HeaderFooter not in the Body

CodePudding user response:

You are to complete the transfer of the section, why want to write so much code, I written in the Java soon; Why now I can't find the style change, but the content is reach

CodePudding user response:

Do you even ask,,,
  •  Tags:  
  • C#
  • Related