The trick is to get each part of the image to its own page, and this is done in the PrintPageevent PrintDocument.
, - , . , (, , , ). PrintDocument, PrintPage :
private List<Image> _pages = new List<Image>();
private int pageIndex = 0;
private void PrintImage()
{
Image source = new Bitmap(@"C:\path\file.jpg");
_pages.AddRange(SplitImage(source, 3));
PrintDocument printDocument = new PrintDocument();
printDocument.PrintPage += PrintDocument_PrintPage;
PrintPreviewDialog previewDialog = new PrintPreviewDialog();
previewDialog.Document = printDocument;
pageIndex = 0;
previewDialog.ShowDialog();
printDocument.PrintPage -= PrintDocument_PrintPage;
}
private void PrintDocument_PrintPage(object sender, PrintPageEventArgs e)
{
e.Graphics.DrawImageUnscaled(_pages[pageIndex],
e.PageBounds.X,
e.PageBounds.Y);
pageIndex++;
e.HasMorePages = (pageIndex < _pages.Count);
}
, reset pageIndex 0 (, ).