2

我正在尝试将标签网格打印到一张 A4 标签纸上。

用户以毫米为单位指定纸张的左边距和上边距。

A4 为 210 x 297。

如果我将可打印区域和边距相加,Siverlight 告诉我可打印区域为 793 x 1122。

printDocument.PrintPage += (s, e) =>
    {
        var printableArea = e.PrintableArea;
        var pageMargin = e.PageMargins;
    }

如果我进行数学计算,210 和 793 与 297 和 1122 之间的比率是 3.777777,它(更准确地说)是 34/9。

为什么是这个值?

无论打印的目的地如何,它总是这个值?我检查了一台实际的打印机和一个设置为 A4 尺寸的 XPS 文档,看起来确实如此,但我不想在 6 个月内被抓到。

如果它确实改变了我如何在代码中解决这种关系?

4

1 回答 1

1

After a little bit more research I've worked out the answer.

The sizes Silverlight is using is the paper size in device independent units - calculated as 1/96th of an inch.

297 mm = 11.6929 inches

Multiply that by 96 and you get 1122.51

Similarly

210 mm = 8.2677 inches

which works out to 493.70

So now I understand where the numbers come from I can happily use my slightly more accurate calculation of 34/9 along with a comment explaining where it comes from.

于 2013-11-07T14:02:25.093 回答