Print multi-page TIFF

  • Thread starter Thread starter Nazza
  • Start date Start date
N

Nazza

Guest
Hi,
I have a Windows Form that should print a multi-page TIFF.

My code:




private System.Drawing.Printing.PrintDocument _PrintDocument;

private System.Windows.Forms.PrintDialog _PrintDialog;



public void Print()

{

_PrintDocument.PrintPage += new PrintPageEventHandler(_PrintDocument_PrintPage);



if (_PrintDialog.ShowDialog() == DialogResult.OK)

{

TiffToPrint = Image.FromFile(MyFilePath);

Guid objGuid = TiffToPrint.FrameDimensionsList[0];

FrameDimension objDimension = new FrameDimension(objGuid);



// Cycle through each frame of the TIFF

for (int iFrame = 0; iFrame < TiffToPrint.GetFrameCount(objDimension); iFrame++)

{

TiffToPrint.SelectActiveFrame(objDimension, iFrame);



// Call the PrintPage event

_PrintDocument.Print();

}

}

}



void _PrintDocument_PrintPage(object sender, PrintPageEventArgs e)

{

e.Graphics.DrawImage(TiffToPrint, e.MarginBounds);

}




In this way I'm able to print each page of the TIFF, but the Print dialog doesn't know how nuch pages I have (it is called before the cycle).

Example, if I select "Current Page", all pages are print.

I think a different work is sent for each page, in fact, if I have 4 pages, I see 4 different windows telling "printing page 1 of document"



Is there a way to "bufferize" the pages and print them togheter ?

Continue reading...
 
Back
Top