【问题标题】:How to get the DPI of the printer in WPF如何在WPF中获取打印机的DPI
【发布时间】:2011-06-03 00:36:27
【问题描述】:

我有一个带有自定义控件的 WPF 应用程序。自定义控件将自身呈现为位图,我可以使用以下代码来确定要使用的分辨率,以便位图与显示分辨率匹配。

        PresentationSource ps = PresentationSource.FromVisual(this);
        if (ps != null)
        {
            pixelsPerLogicalUnitX = ps.CompositionTarget.TransformToDevice.M11;
            pixelsPerLogicalUnitY = ps.CompositionTarget.TransformToDevice.M22;
        }

不幸的是,当我通过 PrintDialog 将此控件发送到打印机时,PresentationSource 为空,因此我不知道 DPI。

有没有办法获取打印机的 DPI(或 PresentationSource)?

【问题讨论】:

    标签: wpf printing dpi


    【解决方案1】:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-07-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-09
      相关资源
      最近更新 更多