PrintDocument always makes a difference

I am having a problem when using PrintDocumentwith fields.

No matter what I do, there is always margin in everything that I print, this means that nothing is aligned where necessary.

Here is the code I use to create PrintDocument

public void Print()
{
   PrintDocument printDocument = new PrintDocument();
        printDocument.DefaultPageSettings.PaperSize = new PaperSize("A5",583,827);
        printDocument.OriginAtMargins = true;
        printDocument.DefaultPageSettings.Margins.Top = 0;
        printDocument.DefaultPageSettings.Margins.Left = 0;
        printDocument.DefaultPageSettings.Margins.Right = 0;
        printDocument.DefaultPageSettings.Margins.Bottom = 0;

        if (!string.IsNullOrWhiteSpace(PrinterName))
        {
            printDocument.PrinterSettings.PrinterName = PrinterName;
        }

        printDocument.PrintController = new StandardPrintController();
        printDocument.PrintPage += On_PrintPage;
        printDocument.Print();
}

A method On_PrintPagehas various method calls e.Graphics.Draw....

How can I make sure that something that I print at 0.0 will print in the very top left corner of the page. I know that if the printer cannot print so far from the edge of the page, it will be blank, however it should do this, and not print 0.0, not in the upper left corner of the page.

I'm really lost here

+4

Source: https://habr.com/ru/post/1523918/


All Articles