相同的C#應用程序使用不同的打印機以不同的尺寸打印文本。打印的文本沿x軸相同,但沿y軸不同。我的意思是在一個印刷品中,文字比其他印刷品稍微(4-5mm)向上,但沿着x軸相同,即沒有文字比其他印刷品的文字向後或向前。例如:同一C#Windows窗體應用程序中不同打印機的不同打印尺寸
「本文是沿x軸相同,但y軸之間不同」(打印1)
「本文是沿x軸相同,但y軸之間不同」(打印2)
我的頁面設置爲:
private void PaperSettings()
{
PaperSize paperSize = new PaperSize("New Page", 377, 1095);
paperSize.RawKind = (int)PaperKind.Custom;
printDocument1.DefaultPageSettings.PaperSize = paperSize;
Margins margin = new Margins(0, 0, 0, 0);
printDocument1.DefaultPageSettings.Margins = margin;
printDocument1.DefaultPageSettings.Landscape = true;
PrinterSettings printer = new PrinterSettings();
printDocument1.PrinterSettings.PrinterName = printer.PrinterName;
}
在改變紙張寬度(377)手動,文本向上偏移上增加它和向下遞減的它。但是在同一個頁面的設置是不工作在不同的打印機* (HP Officejet的J3500打印文字稍微downdards比HP DESKJET 1510打印文本)。*
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
e.Graphics.DrawString(label1Payee.Text, label1Payee.Font, Brushes.Black, label1Payee.Location.X, label1Payee.Location.Y);
e.Graphics.DrawString(labelAmountWords.Text, labelAmountWords.Font, Brushes.Black, labelAmountWords.Location.X, labelAmountWords.Location.Y);
e.Graphics.DrawString(labelDate1.Text, labelDate1.Font, Brushes.Black, labelDate1.Location.X, labelDate1.Location.Y);
e.Graphics.DrawString(labelAmount.Text, labelAmount.Font, Brushes.Black, labelAmount.Location.X, labelAmount.Location.Y);
}
任何建議..
謝謝!
硬件/驅動程序的來源不同。我前一段時間做了一個「精確打印」項目,最後我迫使用戶打印校準頁(在(0,0)處打印X),以毫米爲單位輸入頁面左上角的偏移量並計算打印機特定的偏移量,然後我轉換打印座標。 –
@AlexK。哦,請幫助我瞭解如何通過提供更多的細節和一些基本代碼來實現這一點。 –