これは、さまざまな原因によって発生する可能性があります。あなたが追加することができますいくつかのステップがありますが、正しく実行されたとき、cause the flying men to return with goods and knowledge.が
まず、あなたが印刷されたページ(a2zdotnetからコード)に拡大すべきである可能性があります
System.Printing.PrintCapabilities capabilities =
printDlg.PrintQueue.GetPrintCapabilities(printDlg.PrintTicket);
//get scale of the print wrt to screen of WPF visual
double scale = Math.Min(capabilities.PageImageableArea.ExtentWidth/this.ActualWidth, capabilities.PageImageableArea.ExtentHeight/
this.ActualHeight);
//Transform the Visual to scale
this.LayoutTransform = new ScaleTransform(scale, scale);
//get the size of the printer page
Size sz = new Size(capabilities.PageImageableArea.ExtentWidth, capabilities.PageImageableArea.ExtentHeight);
//update the layout of the visual to the printer page size.
this.Measure(sz);
this.Arrange(new Rect(new Point(capabilities.PageImageableArea.OriginWidth, capabilities.PageImageableArea.OriginHeight), sz));
//now print the visual to printer to fit on the one page.
printDlg.PrintVisual(this, "Code ganked from http://www.a2zdotnet.com/View.aspx?id=66");
貨物カルトコードはです測定とアレンジのステップ。多くの場合、メジャーに電話してnew Size(Double.MaxValue, Double.MaxValue)
を渡してください。
第2の儀式は、ディスパッチャーをバンプすることです。
visual.DataContext = foo;
Dispatcher.Invoke((Action)()=>{;}); // bamp
// print here
これらを試してみてください。
でのトリックはあなたが彼らがHPプリンターの問題を引き起こしているすべての要素があるかどうかを確認するためにPrintInvoiceを簡素化しようとしたことがありませんか? – RQDQ
PrintInvoiceはページであり、Microsoft XPS Document Writerの出力は完璧です。 –
両方のケースでpi.ActualHeightとpi.ActualWidthを確認するためにチェックしました。高さ= 950、幅= NaN これは原因と考えられる原因とその理由と解決方法です(HPプリンタのマシンが選択されている場合)Height = 0、Width = NaN ....(Microsoft XPS Document Writerが選択されている場合)この –