473,385 Members | 1,342 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Printing Multi-page .tif files

Thanks to Bob's help, I was able to get .tif printing working. Now
i've got a new problem; if the image is more than one page, it only
prints the first page.

Here's my code:

############################################

public class PrintTif
{
public string curfname;
public string blankf;

public PrintTif(string blank)
{
this.blankf = blank;
}

public int PrintTheTif(string tifname)
{
this.curfname = tifname;
PageSettings ps = new PageSettings();
ps.Landscape = false;
ps.Margins.Bottom = 100;
ps.Margins.Top = 100;
ps.Margins.Left = 100;
ps.Margins.Right = 100;
PrintDocument pd = new PrintDocument();
pd.DefaultPageSettings = ps;
pd.PrintPage += new
PrintPageEventHandler(this.PrintImageHandler);
try
{
pd.Print();
return 1;
}
catch(Exception ex)
{
throw ex;
}
finally
{
pd.Dispose();
}
}

private void PrintImageHandler(object sender,
PrintPageEventArgs ppea)
{

Image img = Image.FromFile(this.curfname);
Image blank = null;

for(int i = 0; i < img.GetFrameCount(FrameDimension.Page); ++i)
{
blank = Image.FromFile(this.blankf);
Rectangle r = new Rectangle(0,0,blank.Width,blank.Height);
img.SelectActiveFrame(FrameDimension.Page, i);
Bitmap temp = new Bitmap(img);
temp.SetResolution(100,100);
Graphics g = ppea.Graphics;
g.DrawImage(temp,r);
temp.Dispose();
if(i == (img.GetFrameCount(FrameDimension.Page) - 1))
ppea.HasMorePages = false;
else
ppea.HasMorePages = true;
blank.Dispose();
}
img.Dispose();
}
}
#########################################

Apologies for the funky formatting. Here's a pastebin w/ the same code
if anybody is having a hard time reading it:

http://pastebin.com/307914

I'm pretty sure I konw what the problem is. It seems that the result
of the g.DrawImage() call is only being sent back to the calling method
once, instead of for each page. Is this correct?

Assuming it is, I'm not sure if i need to loop through the pages
outside of PrintImageHandler() or what.

Any ideas?

TIA,
Brett

Nov 17 '05 #1
0 1998

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Roger Binns | last post by:
My program has a random smattering of print statements scattered throughout that are mainly a debugging aid. They are typically things like this: print "entering key mode" The code is...
11
by: Marian Aldenhövel | last post by:
Hi, I am very new to Python and have run into the following problem. If I do something like dir = os.listdir(somepath) for d in dir: print d The program fails for filenames that contain...
9
by: Gary | last post by:
I need to read a table from MySQL into a Perl script (already working) and then be able to print fields from the table selectively using a print button which is part of the HTML/CGI. Can someone...
16
by: gb | last post by:
Hi All, Ive created a popup page using 'var openWindow = window.open("new","pop")' And added content using openWindow.document.write(" "); statements. But now I would like to be able to print...
1
by: BJS | last post by:
Sorry for the cross-posting, but based on the number of people I have seen ask for a solution to this problem, I hope by cross-posting this, that it will help a lot of people out of a common...
9
by: Jody Gelowitz | last post by:
I am trying to find the definition of "Safe Printing" and cannot find out exactly what this entitles. The reason is that I am trying to print contents from a single textbox to no avail using the...
1
by: John | last post by:
Hi I am looking into Oki ML 590 and ML 591 printers to see if any of these will work with multi-part (multiple copies) continuous stationery for printing invoices from access. Has anyone had any...
1
by: Yatin Bhuta | last post by:
Hi, I have a web form, which has many text boxes and a few buttons. One of the button is to print the web form. Some of the text boxes are multi line. Due to screen space limitation the...
0
by: matpublic | last post by:
Hi, I'm working in a networked printer environment and within my application I'm using reporting services to create several documents. These documents may have different paper sources (trays)...
1
by: Anish G | last post by:
Hi, I am trying to print multiple label images in case of ups multi label implementaion. The response i get in XML schema and from that i parsedout the label images and stored in an array and from...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.