2010-11-24 4 views
1

작은 머리글로 일부 텍스트에서 페이지를 인쇄하고 싶습니다. 나는 모든 텍스트가 페이지 중앙에 위치하기를 원했지만 어떻게해야할지 모르겠다. ..WPF 인쇄 FlowDocument가 센터링되지 않습니다.

여기 내 코드가있다. t는 아티스트 이름과 같은 정보를 담고있는 유형의 트랙이다. , 앨범 이름, 노래 제목 및 가사.

PrintDialog dialog = new PrintDialog(); 
      if (dialog.ShowDialog() != true) 
      { return; } 
      FlowDocument doc = new FlowDocument(); 
      Section sec = new Section(); 
      Paragraph header = new Paragraph(); 
      Paragraph body = new Paragraph(); 
      Bold boldSong = new Bold(); 
      boldSong.Inlines.Add(new Run(t.Song)); 
      header.Inlines.Add(boldSong); 
      header.Inlines.Add(new LineBreak()); 
      Bold boldArtist = new Bold(); 
      if (!string.IsNullOrWhiteSpace(t.Artist)) 
      { 
       boldArtist.Inlines.Add(new Run(t.Artist)); 
       header.Inlines.Add(boldArtist); 
       header.Inlines.Add(new LineBreak()); 
      } 
      Bold boldAlbum = new Bold(); 
      if (!string.IsNullOrWhiteSpace(t.Album)) 
      { 
       boldAlbum.Inlines.Add(new Run(t.Album)); 
       header.Inlines.Add(boldAlbum); 
       header.Inlines.Add(new LineBreak()); 
      } 
      header.TextAlignment = TextAlignment.Center; 
      body.Inlines.Add(t.iTunesFileTrack.Lyrics); 
      body.TextAlignment = TextAlignment.Center; 
      doc.Blocks.Add(header); 
      doc.Blocks.Add(body); 
      doc.Name = "FlowDoc"; 
      IDocumentPaginatorSource idpSource = doc; 
      DocumentPaginator holder = idpSource.DocumentPaginator; 
      holder.PageSize = new Size(dialog.PrintableAreaWidth, 
     dialog.PrintableAreaHeight); 
      dialog.PrintDocument(holder, "Lyrics"); 

모든 일이 인쇄 된 문서의 왼쪽에 달라 붙는다는 사실을 제외하고 잘 페이지가 인쇄 ... 난 내가 제대로 설정되지 않았거나 전혀 설정하고 있지 않다 몇 가지 특성이 알고있다.

답변

0

ColumnWidth 속성의 크기를 늘리거나 '999999'로 지정하십시오.