簡體   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