[英]Issue printing image as expected
我有一張要打印到法定尺寸的圖像。 但是,這存在一些挑戰。
這是我正在使用的代碼:
PrintDocument pd = new PrintDocument();
pd.PrintPage += (sender, args) =>
{
Image i = Image.FromFile(Globals.TempDirectory + @"\temp.jpg");
Point p = new Point(100, 100);
Margins margins = new Margins(50, 50, 50, 50);
pd.DefaultPageSettings.Margins = margins;
args.Graphics.DrawImage(i, p);
};
pd.Print();
我一直在遇到麻煩,因為我無法設置邊距並且似乎無法正確打印。 我希望它能合法打印,但是當我打印圖像時,它沒有正確旋轉,只能打印到默認打印機。 我想盡一切辦法使它起作用。
用C#打印很爛
嘗試一個
printdialog()
允許用戶選擇打印機和設置。 一旦您能夠使用它,其余的內容可能就會為您點擊。
編輯:向您展示在哪里以及如何使用它。
PrintDialog pDialog = new PrintDialog();
if (pDialog.ShowDialog() == DialogResult.OK)
{
pd.PrinterSettings = pDialog.PrinterSettings;
pd.Print();
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.