我已經編寫了一個小應用程序,它以編程方式創建視覺效果,並且我試圖在橫向打印頁面(它以縱向剪輯)。當我印刷時,它確實出現在風景中,但我的視覺仍然被剪裁,因爲它僅限於縱向。在橫向打印WPF視覺效果,打印機仍然以縱向尺寸剪輯
這是我的代碼:
StackPanel page = new StackPanel();
// ... generate stuff to the page to create the visual
PrintDialog dialog = new PrintDialog(); // System.Windows.Controls.PrintDialog
bool? result = dialog.ShowDialog();
if(result.HasValue && result.Value)
{
dialog.PrintTicket.PageOrientation = PageOrientation.Landscape;
Size pageSize = new Size { Width = dialog.PrintableAreaWidth,
Height = dialog.PrintableAreaHeight };
// pageSize comes out to {1056, 816}, which is the orientation I expect
page.Measure(pageSize);
// after this, page.DesiredSize is e.g. {944, 657}, wider than portrait (816).
page.UpdateLayout();
dialog.PrintVisual(page, "Job description");
}
執行在此之後,印刷的內容被正確地佈置,但似乎仍然被限幅到的816的寬度,切斷的內容的顯著塊。我已經通過在印刷品上拿着另一張紙來檢查它,並且它完全適合在裏面。
有沒有什麼我做錯了測量和安排控制?如何讓我的打印機使用橫向全景空間?
我試着用有描述(使用XpsDocumentWriter用新創建的打印標籤)的方法,但是碰到了幾乎相同的問題。 – Jimmy