Showing posts with label HTML. Show all posts
Showing posts with label HTML. Show all posts

How to keep HTML table rows undivided by page breaks when printing HTML into PDF?

When printing large HTML tables it happens that a row gets wrongly divided between two pages. In order to solve this we can instruct the printer to keep the row on only one of the pages by adding CSS style to the table row.:

When page-break-inside property is set to avoid the  page-break should be avoided inside a HTML element, in this case table row. Of course ti can be applied to other elements like pre, blockquote, etc.
tr{
     page-break-inside:avoid;
     page-break-after:auto
}


Forcing downloading files by save dialog

Here is the code snippet for downloading files with asp.net:

Response.Clear();

Response.AddHeader("content-disposition", "attachment;filename=" + filename);
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "image/jpeg";

byte[] data = System.IO.File.ReadAllBytes(MapPath(url));
Response.BinaryWrite(data);
Response.Flush();
Response.End();


The key moment in forced save dialog is the header "content-disposition" with file attachment. This will tell to your browser to show you dialog and give you the possibility to get directly that file.
If you use attachment in "inline" header (appending it instead of "content-disposition") the file is gonna be opened in the same window. Browser back button can get you back on your page.

List of content types can be found here: MIME Reference

Very good way to see how your html table will look like

http://www.somacon.com/p141.php

Interactive tool for creating good looking html table using css. Make the table you want and copy and paste the generated css classes.

HTML Hyphenation

There are two ways of hyphenation - with plain hyphen and soft hyphen. The plain hyphen is interpreted like a plain symbol, but soft hyphen is used only if it is necessary. The soft hyphen is represented by the character entity reference & s h y ; . This will solve many formatting problems like list text indent.