繁体   English   中英

图像打印不正确的宽高比?

[英]Image printing not correct aspect ratio?

我正在尝试打印图像,但是我在A4纸上的纵横比不正确。 我进行了搜索,并尝试使用与A4纸相同的毫米尺寸,但没有运气。 我正在使用.NET 3.5开发Unity3D 2017.0.3f。

图片

如您在上图中所看到的,它在右下角,所有空间都留在后面。 我希望它只是横向打印普通A4。

这是我用来打印的代码:

public void btnPrint_Click()
{
    PrintDocument pd = new PrintDocument();
    pd.PrinterSettings.PrinterName = availablePrinter[0];
    pd.DefaultPageSettings.Margins = new Margins(100, 100, 100, 100);
    pd.OriginAtMargins = true;
    pd.DefaultPageSettings.Landscape = true;
    pd.PrinterSettings.DefaultPageSettings.Landscape = true;

    pd.PrintPage += new PrintPageEventHandler(pqr);
    pd.Print();
}

void pqr(object o, PrintPageEventArgs e)
{
    Debug.Log("PrintingImage");

    System.Drawing.Image i = System.Drawing.Image.FromFile(path);
    e.Graphics.DrawImage(i, e.MarginBounds);
}

我尝试使用rect并手动进行制作,但仍然无法正常工作。

所以我设法解决了但改变了边距

        pd.DefaultPageSettings.Margins = new Margins(0, 0, 50, 125);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM