Hi
I have a report template with diffrent orientations(both Landscape and Portrait). I am using Aspose.word to merge individual documents into a single one using this report template based on bookmarks. While merging, if any individual document is not found, then I am removing corresponding section to avoid blank pages. When I am deleting blank pages, the header image is changed according to page orientation. But, sometimes its not changed and remain same.
Aspose.Words.License license = new Aspose.Words.License();
license.SetLicense("Aspose.Words.lic");
Document mainDoc = new Document("C:\\ReportRepository\\ReportTemplate.docx");
MergeDocument(mainDoc, "C:\\ServiceImprovementPlan.doc", "ServiceImprovementPlan", 5);
MergeDocument(mainDoc, "C:\\SummaryOfIncidentsClosed.doc", "SummaryOfIncidentsClosed", 6);
MergeDocument(mainDoc, "C:\\SummaryOfIncidentsOpen.doc", "SummaryofIncidentsOpen", 6);
MergeDocument(mainDoc, "C:\\SummaryOfIncidentsNotMetSLA.doc", "SummaryOfIncidentsNotMetSLA", 17);
private static void MergeDocument(Document mainDoc, string path, string bookmarkName, int sectionNo)
{
if (File.Exists(path))
{
// Get document form specified path.
Document subDoc = new Document(path);
DocumentBuilder builder = new DocumentBuilder(subDoc);
builder.RowFormat.AllowAutoFit = false;
// Get specified bookmark define in document.
Aspose.Words.Bookmark bookmark = mainDoc.Range.Bookmarks[bookmarkName];
// Insert document below the specified bookmark.
InsertDocument(bookmark.BookmarkStart.ParentNode, subDoc);
}
else
{
// this code removes the blank pages
Node node = mainDoc.Range.Bookmarks[bookmarkName].BookmarkStart;
while (node.NodeType != NodeType.Section) node = node.ParentNode;
node.Remove();
}
}
In the above code the problem occurs when ServiceImprovementPlan.doc is not available and when I delete the page for ServiceImprovementPlan, the header image is still in same size even in Landscape pages.
I have attached the report template and final document.
Please provide a workaround for this ASAP.