[英]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.