I am developing an application for managing records of secondary school students. After collating data of students (like name, subjects offered, continuous assessment), we then print it out in batches (say like 50 students at once) Simple.
What I do is that:
Create a Student.cs class with a property declared: "public static string studentHTML;"
Create a List<Students>;
Get records of about 50 students from the database for the first batch of students ("SELECT * FROM
students
WHEREstudentStatus
='good' LIMIT 50")For each record, format the data as HTML so that it is presentable to the user on a webbrowser and create a Student object and add HTML-formatted string to the student's Student.studentHTML property.
Add each student's record to the List<Students>
After all students have been processed, I loop through the List<Students> and concatenate all studentObject.studentHTML into one large gigantic string that is finally passed to webBrowser.DocumentText for display to user.
Now, when the user is contented with the output, he decides to print. But do not forget that the string passed to webBrowser.DocumentText is like "<html>...</html><br/><br/><br/><html>...</html><br/><br/><br/><html>...</html>..." (because all the student's individual studentObject.studentHTML has been concatenated)
PROBLEM: I HAVE TO PROVIDE A WAY TO PRINT EACH STUDENT'S RECORD ON A SEPARATE PAPER
The "<br/>" between each student's studentObject.studentHTML is just to provide a visible demarcation between a record and the other.
Info: I think it will help if I say that I can get the correct PageSettings and PrinterSettings required to correctly print a student's record to fit to a page.
What I don't get is the logic or algorithm to print these different parts of the webbrowser containing each different student's record.
Note: The HTML on the webbrowser contains <input type='text'/> that allows the user to edit some things, so I can't directly print anything from that List<Student>.
How possible is it to get the height of the "<br/><br/><br/>" between the HTML display of each student? Maybe that can be used to correctly split the rendered webbrowser HTML into Rectangle for System.Drawing.Graphics or is there any other way of achieving this issue of "segmented" records?
Edit: I saw a SO question here that is practically saying that what I intend to achieve is impossible.
However, everyone knows that it is possible to print a 100-paged webpage from any standard browser like IE (without having to scroll it page-by-page or whatever). I am trying to achieve this same feat!
I simply want to (programmatically) print the contents of a webBrowser.Document that is so long that the height can reach 35000px (so will have scroll bars)
(I can't even get to printpreview it when the height is 30101px - a very large document with scrollBars)
Something like this - (still unanswered)
Thanks a bunch (in advance)