Thread: Printing a number of HTML documents

  1. #1
    Registered User
    Join Date
    Oct 2007

    Post Printing a number of HTML documents

    C#'s not my strongest language ... ... but I have a working program with a problem. Here's the code in question :

    		private void button2_Click(object sender, System.EventArgs e)
    			string[] frmdata = textBox1.Lines; //Incoming numbers, each number is a different form to print.  
    			string[] valid = new String[textBox1.Lines.Length]; //Make an array to use as a check.
    			int cnt = 0; 
    			Regex nMatch =new Regex("^[0-9]{5,}$"); //Each line should be 5 digits. 
    			object bleh = System.Reflection.Missing.Value; //A junk value - used later as a filler for variables that are not used.  
    			foreach (string frmElem in frmdata) {
    				if ((nMatch.IsMatch(frmElem))) 
    				{ //Is the current line a good result? 
    					valid[cnt] = frmElem; //Yeah, add to the check array.
    					valid[cnt] = "XXXXX:" + frmElem; //No doh!  Change it to the flag-value
    			for (int x = 0;x < valid.Length;x++)  
    				axBrowse1.BringToFront(); //Use the browser to view the HTML forms.  
    				valid[x] = @"c:\forms\" + valid[x] + ".html"; //Modify the checked value to a local address.
    					axBrowse1.Navigate(valid[x],ref bleh,ref bleh,ref bleh,ref bleh); //Load 
    					mshtml.IHTMLDocument2 doc = (mshtml.IHTMLDocument2) axBrowse1.Document; 
    					while(axBrowse1.ReadyState != SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE) 
    					{ //While the form's not loaded, just do whatever the program needs to do . 
    						ref bleh, ref bleh); //It's done loading the form. Print it to the default printer.  
    					//1.1 sec pause for the job to finish??  It helped out-of-order somewhat, but there are still problems.  
    					valid[x] = "XXXXX: ERROR: " + valid[x] + " was not found."; 
    					// Note all errors for later.   A list of valid and invalid prints is saved to print a job report later on.  
    Yes, I already know I'm using a depreciated library (mshtml). I can deal with that for the moment. But, the problem is as such:

    I'm printing a number of sequential HTML files, each file as a separate print job. The code is passed those files as frmdata.

    Everything prints fine.

    But, everything doesn't print in order. I'd expect the doevents() to clean up and flush + my thread-sleep ... so everything comes out in order ... but the spooler just doesn't do it for some reason. Is there something I should be doing to force-send to the spooler so things come in order?

    Also, on occasion ... a print from the end of the list might come out first (huh??!!) So that's a bonus right there.

    It's not a big deal - as this program saves a good half hour of work daily, but, we could save another 5 minutes if I could figure out how to get everything printed in order.

    Any ideas? What is it that I'm just missing/overlooking?

    My normal job size is 30-50 separate documents, some of them multiple pages.
    Last edited by kasemo; 10-25-2007 at 05:12 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Number Guessing
    By blacknapalm in forum C Programming
    Replies: 2
    Last Post: 10-01-2008, 01:48 AM
  2. Random number + guessing game trouble
    By Ravens'sWrath in forum C Programming
    Replies: 16
    Last Post: 05-08-2007, 03:33 AM
  3. Stone Age Rumble
    By KONI in forum Contests Board
    Replies: 30
    Last Post: 04-02-2007, 09:53 PM
  4. newbie needs help with creating html table
    By Dylancougar in forum C Programming
    Replies: 4
    Last Post: 10-31-2005, 09:13 PM
  5. reading a text file printing line number
    By bazzano in forum C Programming
    Replies: 4
    Last Post: 09-16-2005, 10:31 AM