나는 도형을 PrintDocument
에 그리는 방법과 특정 크기의 용지를 인치로 그리는 방법을 알아 내려고하고 있습니다.인쇄 해상도
private void DrawShapes(Graphics graphics)
{
graphics.DrawRectangle(new Pen(Color.HotPink), new Rectangle(0, 0, (int)Math.Round(1 * graphics.DpiX), (int)Math.Round(1 * graphics.DpiY)));
graphics.DrawRectangle(new Pen(Color.HotPink), new Rectangle(0, 0, (int)Math.Round(1.5 * graphics.DpiX), (int)Math.Round(1.5 * graphics.DpiY)));
graphics.DrawRectangle(new Pen(Color.HotPink), new Rectangle(0, 0, (int)Math.Round(2 * graphics.DpiX), (int)Math.Round(2 * graphics.DpiY)));
graphics.DrawRectangle(new Pen(Color.HotPink), new Rectangle(0, 0, (int)Math.Round(2.5 * graphics.DpiX), (int)Math.Round(2.5 * graphics.DpiY)));
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
DrawShapes(e.Graphics);
}
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
DrawShapes(e.Graphics);
}
이는 OnPaint
기능에서 Graphics
객체에 대해 잘 작동하지만 밖으로 인쇄가 잘못 : 나는이 내가 시작 무엇입니까 PrintDocument
의 DPI에 대한 혼란 스러워요. 약간의 디버깅을 수행하여 이벤트의 이벤트의 DPI가 크다는 것을 알았지 만 (코드를 실행했을 때 600) 페이지의 경계는 1100에서 850입니다. 따라서 인쇄 할 때 DPI를 100으로 사용하고 폼에 드로잉 할 때 그래픽의 DPI. 이것은 완벽하게 작동했습니다.
내가 얻지 못하는 것은 PrintDocument
이 DPI를 어떻게 다루는가입니다. PrintPage
이벤트의 Graphics
개체에 다른 DPI가 있다고 표시 되더라도 PrintDocument
은 항상 실제 DPI가 100입니까? 인쇄 할 때 96dpi로 그리고 그림을 인쇄 할 때 100dpi로 생각하면 문제가 발생합니까?
고맙습니다! 그래픽 장치가 표시되도록 설정되었는지 알지 못했습니다. 나는 약간의 연구를했으며 훨씬 더 의미가 있습니다. 나는 대답을 주셔서 감사합니다 :) –