Note that there are some explanatory texts on larger screens.

plurals
  1. POPrinting multipage Tiff with C#
    text
    copied!<p>I am trying to print a multidimensional tiff. This tiff is having 3 Pages using variable imagetoprint. So I wrote following code, that unfortunately only prints the first dimension. All others are printed on empty paper. If I save the image from memory to file, irfanview shows all pages correctly...</p> <p>Who can give me a hint ?</p> <pre><code> public void print(Bitmap imageToPrint, string printerName, int pagesToPrint) { try { printmap = imageToPrint; cur_page = 0; max_pages = pagesToPrint; m.Top = 1 * dpi; // Set a 1' margin, from the top m.Left = 1.25f * dpi; // Set a 1.25' margin, from the left m.Bottom = printmap.Height - m.Top; // 1', from the bottom m.Right = printmap.Width; // rechter Rand so weit wie es eben geht m.Width = printmap.Width - (m.Left * 2); // Get the width of our working area m.Height = printmap.Height - (m.Top * 2); // Get the height of our working area pd.PrintPage += new PrintPageEventHandler(pd_PrintPage); if (printerName != "") pd.DefaultPageSettings.PrinterSettings.PrinterName = printerName; pd.DefaultPageSettings.Color = true; pd.DefaultPageSettings.PrinterSettings.PrintFileName = "tiffprint"; pd.DocumentName = "InstantFormsPrinting"; if (m.Width &gt; m.Height) { pd.DefaultPageSettings.Landscape = true; } pd.Print(); // Print } catch (Exception ex) { Console.WriteLine("Error during print preparation:" + ex.Message); } } // Our printing event public void pd_PrintPage(object sender, PrintPageEventArgs e) { Rectangle crop = new Rectangle(1, 1, 200, 200); try { printmap.SelectActiveFrame(FrameDimension.Page, cur_page); e.Graphics.DrawImageUnscaled(printmap, new Point(0, 0)); ++cur_page; e.HasMorePages = (cur_page &lt; max_pages); } catch (Exception ex) { Console.WriteLine("Error during print operation:" + ex.Message); } } </code></pre> <p>On Page 2 pd_PrintPage thows an exception with "general gdi problem"</p> <p>I have no idea so far. It would be very nice if somebody can help.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload