6
사용자 지정 컨트롤이있는 WPF 응용 프로그램이 있습니다. 사용자 정의 컨트롤은 비트 맵으로 렌더링되며 다음 코드를 사용하여 비트 맵이 디스플레이 해상도와 일치하도록 사용할 해상도를 결정할 수 있습니다. 나는 PrintDialog를 통해 프린터에이 컨트롤을 보낼 때 나는 DPI를 모르는, 그래서WPF에서 프린터의 DPI를 얻는 방법
PresentationSource ps = PresentationSource.FromVisual(this);
if (ps != null)
{
pixelsPerLogicalUnitX = ps.CompositionTarget.TransformToDevice.M11;
pixelsPerLogicalUnitY = ps.CompositionTarget.TransformToDevice.M22;
}
불행하게도,의 PresentationSource은 null입니다.
프린터에 DPI (또는 PresentationSource)를 가져 오는 방법이 있습니까?