A dashed line has a different count of dashes depending on the resolution of printer. Why isn't it dpi independent? How can I fix it?
var line = new Line();
line.Stroke = Brushes.Black;
line.StrokeThickness = 1;
line.X1 = line.Y1 = 100;
line.X2 = line.Y2 = 200;
line.StrokeDashArray = new DoubleCollection(new[] { 8.0 });
var dialog = new PrintDialog();
if (dialog.ShowDialog() == true)
{
Size pageSize = new Size(
dialog.PrintableAreaWidth, dialog.PrintableAreaHeight);
line.Measure(pageSize);
line.Arrange(new Rect(0, 0, pageSize.Width, pageSize.Height));
dialog.PrintVisual(line, "description");
}
I've used PrintVisual, but you can to create FixedDocument with dashed lines and use PrintDocument. The result will be the same.