2017-11-22 10 views
-1

를 추가 aspose.word 섹션 나누기를 삽입하지 못할하지만 닷넷 에 대한 aspose.word에 삽입 구역 나누기가 내 코드는 여기에있을 때 예외가 발생난 후 내가 BreackNewPage 삽입 할 aspose.word에 삽입 헤더 후 헤더

builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary); 
     Shape shape = builder.InsertImage(dataDir); 
     shape.Height = builder.PageSetup.PageHeight - 200; 
     shape.Width = builder.PageSetup.PageWidth - 50;   
     shape.WrapType = WrapType.None; 
     shape.BehindText = true; 
     shape.RelativeHorizontalPositionRelativeHorizontalPosition.Page; 
     shape.RelativeVerticalPosition = RelativeVerticalPosition.Page; 
     shape.VerticalAlignment = VerticalAlignment.Center; 
     builder.InsertBreak(BreakType.SectionBreakNewPage); 
+0

'builder.MoveToHeaderFooter'가 주어지면 헤더에 섹션 나누기를 추가하려고한다는 사실이 마음에 들지 않습니까? – mjwills

+0

System.InvalidOperationException –

+0

true ... so thanks @mjwills –

답변

1

커서는 요청한 중단을 삽입 할 수 있도록 "기본 스토리"안에 있어야합니다. 다음 코드를 참조하십시오 :

Document doc = new Document(); 
DocumentBuilder builder = new DocumentBuilder(doc); 
builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary); 
Shape shape = builder.InsertImage(MyDir + @"aspose.words.jpg"); 
shape.Height = builder.PageSetup.PageHeight - 200; 
shape.Width = builder.PageSetup.PageWidth - 50; 
shape.WrapType = WrapType.None; 
shape.BehindText = true;    
shape.RelativeVerticalPosition = RelativeVerticalPosition.Page; 
shape.VerticalAlignment = VerticalAlignment.Center; 
builder.MoveToDocumentEnd(); 
builder.InsertBreak(BreakType.SectionBreakNewPage); 
doc.Save(MyDir + @"17.11.docx"); 

개발자 대상으로 Aspose와 협력합니다.