PDA

View Full Version : window.print



GerryM
Apr 21st, 2010, 09:30 PM
[referred to this forum from the asp forum]

I have an unusual problem with printing tables using window.print from an .asp page.. The printer works fine otherwise. Let me describe the Table Printing Problem in more detail:

Assume I have a table of 156 rows and 2 columns. Using 7 pt font size a page header + a table header + 55 rows are printed (correctly) on the 1st page, a page header + 63 rows are printed (correctly) on the second page, and a page header + 38 rows are printed on the 3rd page except that the entry for the cell in row 1, column 1 (row 119 of the original table) is not printed; all other cellls are printed correctly.

If I increase the font size then only 38 rows of the table are printed on the first page but the entry in row 1, column 1 of the 2nd page (row 39 of the original table) is not printed, and incidentally the row 1, column 1 entries of pages 3 and 4 are also not printed, while all other table entries are printed ok. This pretty much proves to me that it is not some peculiar contents in a specific table cell.

The behavior is not consistent. In other tests, the entry in row 1, column 1 of page 2 is not printed; or the entries in row 1, column 1 of pages 2 and 3 are not printed. But in all cases, the remaining entries on those pages are printed ok.

I'm using Windows XP Professional SP3, an HP5510 printer, and have reinstalled the most recent printer driver from HP.

What may be the problem?

GerryM

mbaker
Apr 21st, 2010, 11:55 PM
I have no idea what the problem is (but do have suspicions). The following may help figure it out what is going on.

What browser are you using?

Do you have any other browsers installed? Have you tried other browsers? Do you get the same results?

My suspicion is that this is a problem of a particular browser, rather than the printer you are using. However have you tired a virtual printer driver? - such as one that prints pdf files. There are several available for free download.

GerryM
Apr 22nd, 2010, 12:57 AM
I'm using Internet Explorer 8; the problem also occurred in earlier versions of IE. At this time I have no other browser installed.

The strange thing is that the screen display of the table is perfectly ok, it's only when the table is printed (using window.print) that the problems occur.

Thanks,

GerryM

mbaker
Apr 22nd, 2010, 10:05 AM
I'm using Internet Explorer 8; the problem also occurred in earlier versions of IE. At this time I have no other browser installed.

That was my suspicion that the problem is occurring with IE.

I would strongly advise you to obtain and use another browser other that IE for everyday use. My favourite is Google Chrome, but Firefox and Safari are also very good.

GerryM
Apr 22nd, 2010, 04:59 PM
I tried Google Chrome; it does not like my asp pages.

The problem is related to how the browser determines a page break is needed. It starts printing the side borders of the table cells at the bottom of the page, THEN discovers a page break is needed, and prints the rest of the table row (without cell top borders) on the next page. The contents of the leftmost table cell of that row is somehow lost, most of the time, in the process.

If I count number of rows printed and force a page break (a work-around suggested by Old Pedant in the ASP forum here) all is well: pages end with the bottom borders of table cells and start with the top border of table cells.
But that's all it is -- a work-around.

Cheers,

GerryM

mbaker
Apr 22nd, 2010, 06:35 PM
I tried Google Chrome; it does not like my asp pages.

I assume that your asp pages are on a server that runs asp. That being the case all that is delivered to your browser is HTML. If Google Chrome does not like it, this suggests that there is something wrong with the HTML that your asp page is generating.

Have you run your page through the w3c html validator (see my sig for link)?

GerryM
Apr 22nd, 2010, 09:55 PM
Well, I played with your validator a bit. It claims the following is an error:
[quoting]
Line 25, Column 39: an attribute value specification must start with a literal or a name character
style="font:normal 9pt Arial" value=></td>
[end quote]
where the asp program had
style="font:normal 9pt Arial" value=<%= xxx %>></td>
where xxx is the name of an asp variable.

Why is this considered an error?

Cheers,

GerryM

GerryM
Apr 22nd, 2010, 09:56 PM
Sorry, the asp statement should have shown <%= xxx %>.

GerryM

met
Apr 22nd, 2010, 11:03 PM
style="font:normal 9pt Arial;" value="<%=xxx %>"></td>


should be enclosed in quotes regardles..i assume this is an input box of sorts?

that also suggests the variable isn't being set?

value=></td>

GerryM
Apr 22nd, 2010, 11:45 PM
Input box, yes. I thought browsers were getting pretty lenient with respect to quotes around values, but I'll put quotes around some of them and see whether that makes the validator happy.

Of course, the variable could be a Session variable set on another asp page and when the page is validated by itself the value would not be set.

Further, since asp pages typically contain conditionally executed program segments and only the segment for which the condition happens to be true is translated into html when the program runs, wouldn't the validator only be able to test the "default" html segment? Or is my understanding of asp, or what a validator could do, faulty?

I think I'll have trouble validating my programs.

Cheers,

GerryM

mbaker
Apr 23rd, 2010, 02:03 AM
Your understanding of validators is correct. However it is possible to use direct input to them.

Do whatever you do to get a version of your page that is causing problems, then view the source for that page. Copy the whole of the source to your clipboard and paste into the direct input field on the validator.

This process is a bit more involved and not so easy to automate, but will allow you to test the html that results from arbitrarily complex interactions with your asp website.

GerryM
Apr 23rd, 2010, 04:57 AM
Thanks, that is good to know.

GerryM