1
有找到紙張中心座標的方法嗎?c#打印等邊距
我已經閱讀了許多討論,論壇和提示 - 我無法做到這一點。 林印像這樣:
using (PrintDialog pd = new PrintDialog())
{
if (pd.ShowDialog() != DialogResult.OK) return;
PrintDocument document = new PrintDocument();
document.PrinterSettings = pd.PrinterSettings;
document.PrintPage += new PrintPageEventHandler(Document_PrintPage);
document.Print();
}
private void Document_PrintPage(object sender, PrintPageEventArgs e)
{
int X = (int)e.PageSettings.PrintableArea.X;
int Y = (int)e.PageSettings.PrintableArea.Y;
int width = (int)e.PageSettings.PrintableArea.Width - X;
int height = (int)e.PageSettings.PrintableArea.Height - Y;
int centerX = (width - X)/2 + X;
int centerY = (height - Y)/2 + Y;
e.Graphics.DrawRectangle(Pens.Gray, new Rectangle(X, Y, width, height));
e.Graphics.DrawLine(Pens.Black, centerX - 100, centerY, centerX + 100, centerY);
e.Graphics.DrawLine(Pens.Black, centerX, centerY - 100, centerX, centerY + 100);
}
當然我試圖計算在很多方面這些座標,包括使用MarginBounds,Hardmargins的,保證金等
任何人都知道如何打印的東西究竟在一張中心?