简体   繁体   English

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

[英]Image printing not correct aspect ratio?

I'm trying to print an image however my aspect ration on the A4 papaer is incorrect. 我正在尝试打印图像,但是我在A4纸上的纵横比不正确。 I did my search and tried to use the same mm size as the A4 paper but no luck. 我进行了搜索,并尝试使用与A4纸相同的毫米尺寸,但没有运气。 I'm working on Unity3D 2017.0.3f using .NET 3.5. 我正在使用.NET 3.5开发Unity3D 2017.0.3f。

图片

As you can see in the image above, it's in the bottom right and leaving all the space behind. 如您在上图中所看到的,它在右下角,所有空间都留在后面。 I want it just landscape normal A4 printed. 我希望它只是横向打印普通A4。

Here's my code that I'm using to print: 这是我用来打印的代码:

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);
}

I tried using a rect and making it manually but still didn't work. 我尝试使用rect并手动进行制作,但仍然无法正常工作。

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

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

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

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