WPF打印流程文件不居中
我想打印一页从一些文本,我有一个小标题。 我想把所有的文字都放在页面的中心,但我不知道怎么做 这是我的密码。。t是track类型,它只是一个保存艺术家姓名、专辑名称、歌曲标题和歌词等信息的对象WPF打印流程文件不居中,wpf,printing,alignment,center,flowdocument,Wpf,Printing,Alignment,Center,Flowdocument,我想打印一页从一些文本,我有一个小标题。 我想把所有的文字都放在页面的中心,但我不知道怎么做 这是我的密码。。t是track类型,它只是一个保存艺术家姓名、专辑名称、歌曲标题和歌词等信息的对象 PrintDialog dialog = new PrintDialog(); if (dialog.ShowDialog() != true) { return; } FlowDocument doc = new FlowDocu
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");
这一页打印得很好,只是打印时整个页面都贴在文档的左边。。。我知道有些属性设置不正确或根本没有设置 增大ColumnWidth属性的大小或仅将其设置为“999999”增大ColumnWidth属性的大小或仅将其设置为“999999”