Capture image with best possible clarity

Please copy/paste the attached code into a file and save it as a .HTML file.
I am trying to capture a screenshot of a table created using the code.

The size of the image must be 1.6" X 4.8" (approx) when pasted in Microsoft Word.

Please tell me how I can get the best possible clarity (with regard to the text written inside the textboxes). I am open to all options - changing the font size, font, etc.

Thanks!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>OOP Table Manipulation</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
body, p, td, div { font-family: Calibri, Arial, Tahoma; }

table {
	margin:10px 0;
	border-collapse: collapse;
}

tr { margin-top:2px; }

td {
	margin-left:2px;
	padding: 2px;
}
div.newcol a {
	text-decoration: none;
}
.xmark {
	font-size:14px;
}
.xmark, .pmark, .pRowMark {
	color:#888;
	text-decoration:none;
}
.pmark {
	font-size: 22px;
	margin-left: -8px;
}

.xRowMark, .pRowMark {
	margin-right: 10px;
	margin-left: 65px;
}

.pRowMark {
	font-size: 22px;
	margin-right: 9px;
}

.xTableMark {
	font-size:18px;
	color:#888;
	text-decoration:none;
}

.xmark:hover,
.xTableMark:hover { color:#F00; }

.tableContainer {
	display: inline-block;
	position: relative;
	padding: 0 20px 20px 0;
	overflow: visible;
}

.tableContainer img.button {
	position: absolute;
	z-index: 1000;
}

.tableContainer img.button:hover { cursor: pointer; }

.tableContainer img.newCol {
	top: 60px;
	right: 0px;
	width: 20px;
	height: 20px;
}

.tableContainer img.newRow {
	bottom: 5px;
	right: 100px;
	width: 16px;
	height: 16px;
}

</style>
<script type="text/javascript">
//<![CDATA[
var tableInstancePool = new Array();
var counter = 0;
var numTables = 0;

var dropDown = "<select name='' id='' style='width: 100%'><option value='1'>1</option><option value='2'>2</option><option value='3'>3</option></select>";
//var textBox = "<input type='text'></input>";
var textBox = "<input type='text' onfocus=\"this.style.border='2px solid gray';\" onblur=\"this.style.border='';\"></input>";
var b = "1px solid red";

function move(e, el) {
      var did = el.id;
      var parts = did.split('*');
      var grow = parts[1].split('_');
      var gcol = parts[2].split('_');
      var currow = parseInt(grow[1]);
      var curcol = parseInt(gcol[1]);

var key = (window.event) ? event.keyCode : e.keyCode;

window.status = key;
var newcol = curcol;
var newrow = currow;

var oRows = document.getElementById(parts[0]).getElementsByTagName('tr').length - 1;
var oCols = document.getElementById(parts[0]).getElementsByTagName('tr')[0].getElementsByTagName('td').length - 1;

if (key == 37) { // left arrow
if (curcol > 0) {var newcol = curcol - 1;} else if (currow > 0) {newrow = currow - 1; newcol = oCols - 2;}
} else if (key == 38) { // up arrow
if (currow > 0 ) {var newrow = currow - 1;}
} else if (key == 39) { // right arrow
if (curcol < oCols - 2) {newcol = curcol + 1;} else {newrow = currow + 1; newcol = 0;}
} else if (key == 40) { // down arrow
newrow = currow + 1;
}

var newid = parts[0] + '*tr_' + newrow + '*td_' + newcol;      
var element = document.getElementById(newid);
var inp = element.getElementsByTagName('input');
inp[0].focus();
return false;

}

function highlightRow(cellElem) {

	// Cell that contains the delete link
	var cellElem = cellElem.parentNode;

	// Table that contains the cell
	var tbody = cellElem.parentNode.parentNode;

	// Get row index of current cell
	var rowIndex = -1;
	var rows = tbody.getElementsByTagName("tr");

	outerLoop:
	for(i=0; i<rows.length; i++) {

		var cells = rows[i].getElementsByTagName("td");
		for(j=0; j<cells.length; j++) {

			if(cells[j] == cellElem) {
				rowIndex = i;
				break outerLoop;
			}
		}
	}

	// Highlight all cells in same row
	if(rowIndex > 0) {
		var cells = rows[rowIndex].getElementsByTagName("td");

		cells[1].style.borderLeft = b;
		for(j=1; j<cells.length; j++) {

			cells[j].style.borderTop = b;
			cells[j].style.borderBottom = b;
		}
		cells[cells.length-1].style.borderRight = b;
	}
}

function highlightCol(cellElem) {

	// Cell that contains the delete link
	var cellElem = cellElem.parentNode;

	// Table that contains the cell
	var tbody = cellElem.parentNode.parentNode;

	// Get row index of current cell
	var colIndex = -1;
	var rows = tbody.getElementsByTagName("tr");

	outerLoop:
	for(i=0; i<rows.length; i++) {

		var cells = rows[i].getElementsByTagName("td");
		for(j=0; j<cells.length; j++) {

			if(cells[j] == cellElem) {
				colIndex = j;
				break outerLoop;
			}
		}
	}

	// Highlight all cells in same row
	if(colIndex > 0) {

		rows[1].getElementsByTagName("td")[colIndex].style.borderTop = b;
		for(i=1; i<rows.length - 1; i++) {

			var cell = rows[i].getElementsByTagName("td")[colIndex];

			cell.style.borderLeft = b;
			cell.style.borderRight = b;
		}
		rows[rows.length-2].getElementsByTagName("td")[colIndex].style.borderBottom = b;
	}
}

function highlightTable(tableElem) {

	var tbody = tableElem.parentNode.parentNode.parentNode;

	var rows = tbody.getElementsByTagName("tr");
	for(i=1; i<rows.length - 1; i++) {

		var cells = rows[i].getElementsByTagName("td");
		for(j=1; j<cells.length; j++) {

			if(i==1) cells[j].style.borderTop = b;
			if(j==1) cells[j].style.borderLeft = b;
			if(i==rows.length-2) cells[j].style.borderBottom = b;
			if(j==cells.length-1) cells[j].style.borderRight = b;
		}
	}
}

function clearHighlights(cellElem) {

	// Table that contains the cell
	var tbody = cellElem.parentNode.parentNode.parentNode;
	var cells = tbody.getElementsByTagName("td");
	for(i=0; i<cells.length; i++) {

		cells[i].style.borderLeft = '';
		cells[i].style.borderRight = '';
		cells[i].style.borderTop = '';
		cells[i].style.borderBottom = '';
	}
}

function table(numRows, numCols, parentId) {
	numTables++;
	name = ++counter;
	this.name = name;
	this.numRows = numRows;
	this.numCols = numCols;
	this.parentId = parentId;
	this.rowCounter = numRows;
	this.colCounter = numCols;

	var tableHTML = '<div class="tableContainer"><table id="id_' + name + '">';

	// first row with the table delete button
	tableHTML += '<td align="center" style="color:#F00;"><a href="javascript:void(0);" onmouseover="highlightTable(this);" onmouseout="clearHighlights(this);" class="xTableMark" title="Delete Table" onclick="tableInstancePool[\'' + this.name + '\'].deleteThisTable(this);">X</a><br /><input id="id_' + this.name + '_checkbox_checkboxno" type="checkbox" style="margin-left: 30px; margin-bottom: 5px" checked="checked" /></td>';

	// first row with the col delete buttons
	for (var colCounter = 0; colCounter < numCols; colCounter++) {
		tableHTML += '<td align="center" valign="bottom" style="color:#F00"><div style="float: left"><a class="pmark" href="#" style="text-decoration: none" onclick="tableInstancePool[\'' + this.name + '\'].addCol(this)">+</a></div><a href="#" class="xmark" onmouseover="highlightCol(this);" onmouseout="clearHighlights(this);" onclick="tableInstancePool[\'' + this.name + '\'].delCol(this.parentNode);">X</a></td>';
	}
	
	// add the last col delete button
	tableHTML += '<td align="center" valign="bottom" style="color:#F00"><div style="float: left"><a class="pmark" href="#" style="text-decoration: none" onclick="tableInstancePool[\'' + this.name + '\'].addCol(this)">+</a></div>';
	
	
	tableHTML += '</tr>';

	// second row with select boxes
	tableHTML += '<tr><td>&nbsp;</td>'; // no delete button on this row
	for (var colCounter = 0; colCounter < numCols; colCounter++) {
		tableHTML += '<td>' + dropDown + '</td>';
	}
	tableHTML += '</tr>';

	// remaining rows with input fields
	for (var rowCounter = 0; rowCounter < numRows; rowCounter++) {
		tableHTML += '<tr id="">';
		tableHTML += '<td align="right" style="color:#F00"><a href="#" class="xmark xRowMark" onmouseover="highlightRow(this);" onmouseout="clearHighlights(this);" onclick="tableInstancePool[\'' + this.name + '\'].delRow(this.parentNode);">X</a></td>';
		for (var colCounter = 0; colCounter < numCols; colCounter++) {
			tableHTML += '<td id="" onkeyup="move(event,this);">' + textBox + '</td>';
		}
		tableHTML += '</tr>';
	}
	
	var container = document.createElement("div");
	container.innerHTML = tableHTML;
	document.getElementById(parentId).appendChild(container);	
	
	addLastRow(this);
	this.renameID();
	
	var firstTextbox = document.getElementById("id_"+ name + "*tr_0*td_0");
	var inp = firstTextbox.getElementsByTagName('input');
	inp[0].focus();
}

table.prototype.addRow = addRow;
table.prototype.deleteRow = deleteRow;
table.prototype.deleteThisTable = deleteThisTable;
table.prototype.addCol = addCol;
table.prototype.delCol = delCol;
table.prototype.delRow = delRow;
table.prototype.renameID = renameID;

function addRow() {
	tableHTML = '<td align="right" style="color:#736F6E;"><a href="#" class="xmark xRowMark" onmouseover="highlightRow(this);" onmouseout="clearHighlights(this);" onclick="tableInstancePool[\'' + this.name + '\'].delRow(this.parentNode);">X</a></td>';
	for (var colCounter = 0; colCounter < this.numCols; colCounter++) {
		tableHTML += "<td onkeyup='move(event,this);'>" + textBox + "</td>";
	}

	this.rowCounter++;
	this.numRows++;
	var table = document.getElementById("id_" + this.name);
	table = table.getElementsByTagName("TBODY")[0];
	// add a new row to the table, and insert the cells we've just written
	rowElement = document.createElement('tr');
	
	// remove the last row so it can be readded later
	var last = document.getElementById("lastRow_" + this.name);
	if (last != null) table.removeChild(last);
	newRow = table.appendChild(rowElement);
	newRow.innerHTML = tableHTML;
	addLastRow(this);
	this.renameID(this);
}

function addLastRow(currentTable) {
	var lastRow = '<td align="right" style="margin-top: -2px"><a class="pRowMark" href="#" style="text-decoration: none" onclick="tableInstancePool[\'' + currentTable.name + '\'].addRow(this)">+</a></td><td colspan="20" />';
	var table = document.getElementById("id_" + currentTable.name);
	table = table.getElementsByTagName("TBODY")[0];
	rowElement = document.createElement('tr');
	rowElement.id = "lastRow_" + currentTable.name;
	newRow = table.appendChild(rowElement);
	newRow.innerHTML = lastRow;
}

function addCol(row_link) {
	index = row_link.parentNode.parentNode.cellIndex-1;
	if (index == null) { index=this.numCols; }
	var table = document.getElementById("id_" + this.name);
	var rows = table.rows;
	var delCrossAdded = false;
	
	for (var rowCounter = 0; rowCounter < this.numRows + 2; rowCounter++) {
		var row = rows[rowCounter];
		var cell = row.insertCell(index + 1);
		if (delCrossAdded) {
			cell.id = "";
			cell.innerHTML = textBox;
			cell.setAttribute("onkeyup","move(event,this);");
		} else {
			delCrossAdded = true;
			cell.setAttribute("align", "center");
			cell.setAttribute("valign", "bottom");
			cell.setAttribute("style", "color:#F00");
			cell.innerHTML = '<div style="float: left"><a class="pmark" href="#" style="text-decoration: none" onclick="tableInstancePool[\'' + this.name + '\'].addCol(this)">+</a></div><a href="#" class="xmark" onmouseover="highlightCol(this);" onmouseout="clearHighlights(this);"  onclick="tableInstancePool[\'' + this.name + '\'].delCol(this.parentNode);">X</a>';

			// now add the second row with the select box
			rowCounter++;
			var row = rows[rowCounter];
			var cell = row.insertCell(index + 1);
			cell.innerHTML = dropDown;

		}
	}
	
	this.numCols++;
	this.colCounter++;
	this.renameID();
}

function delRow(rowObject) {
	//if(this.numRows <= 1) deleteTable(this.name);
	//else {
		rowObject.parentNode.parentNode.removeChild(rowObject.parentNode);
		this.numRows--;
		this.renameID();
	//}
}

function delCol(colObject) {
	if(this.numCols <= 1) deleteTable(this.name);
	else {
		var cells = colObject.parentNode.getElementsByTagName("td");
		var c = 0;
		for (c; c < cells.length; c++) if (cells[c] == colObject) break;
		var rows = colObject.parentNode.parentNode.getElementsByTagName("tr");
		for (var r = rows.length - 2; r >= 0; r--) colObject.parentNode.parentNode.rows[r].deleteCell(c);
		this.numCols--;
		this.renameID();
	}
}

function deleteRow(rowNumber) {
	this.numRows--;
	var row = document.getElementById("id_" + this.name + "*tr_" + this.rowCounter);
	row.parentNode.remove(row);
}

function deleteThisTable() {
	numTables--;
	var table = document.getElementById("id_" + this.name);
	var div = table.parentNode.parentNode;
	div.parentNode.removeChild(div);
}

function createTable() {
	var rows = parseInt(document.getElementById("rows").value);
	var cols = parseInt(document.getElementById("cols").value);
	if (isNaN(rows)) rows = 2;
	if (isNaN(cols)) cols = 4;
	var newTable = new table(rows, cols, "tables");
	tableInstancePool[name] = newTable;
}

function deleteTable(tableName) {
	var tableInstance = tableInstancePool[tableName];
	tableInstance.deleteThisTable();
}

function addRowToTable(tableName) {
	var tableInstance = tableInstancePool[tableName];
	tableInstance.addRow();
}

function addColToTable(tableName, index) {
	var tableInstance = tableInstancePool[tableName];
	tableInstance.addCol(index);
}

function renameID(renameLast) {
	var rows = document.getElementById("id_" + this.name).getElementsByTagName("tr");
	
	for (var i = 1; i < rows.length - 1; i++) {
		rows[i].id = "id_" + this.name + "*tr_" + (i - 1);

		cells = rows[i].getElementsByTagName("td");
		for (var j = 1; j < cells.length; j++) {
			cells[j].id = "id_" + this.name + "*tr_" + (i - 2) + "*td_" + (j - 1);
			selectBoxes = cells[j].getElementsByTagName("select");
			if (selectBoxes.length) {
				selectBoxes[0].id = "id_" + this.name + "dropdown_" + (j - 1);
				selectBoxes[0].name = "id_" + this.name + "dropdown_" + (j - 1);
			}
		}
	}
}
//]]>
</script>
</head>
    <body>
        Rows:
        <input id="rows" type="text" value="2" />
        <br />
        Cols:  
        <input id="cols" type="text" value="4" />
        <br />
        <a href="#" onclick="createTable(); return false;">Create Table</a>
        <div id="tables"></div>

    </body>
</html>

Open in new window

dshrenikAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
To get this image I used a copy of PaintShopPro and did File->Import->ScreenCapture->Start.  Similar capabilities are available in other drawing programs like Gimp and Photoshop.  I saved the image as a PNG file (no JPG compression boogers - just good pixels) and uploaded it here.

Any information you want to extract or crop is best done in the drawing program.  Then save the image as a high-resolution JPG.  Close the drawing program and re-open it to the JPG version of the image before cutting and pasting into Word.

HTH, ~Ray
dshrenik.png
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BillDLCommented:
Hi dshrenik

I have my standard old CRT monitor set to 1,024 x 768.  If I adjust my Internet Explorer Zoom level to 40% I get a very rough approximation of how your table will appear in a screenshot cropped and resized to 4.8" wide x 1.6" high (that's a 3:1 ratio).  The text is not, and will not be, legible at that size no matter what you do with the actual text.  Even if each table cell is fully populated to its entire width with text characters, the font is not large enough to read.  Increasing the font size will mean that less characters fit into each table cell.  If the cells dynamically resize to fit the text, then it will change the aspect ratio of an image needed to capture the width and height of the table.  You would then need to reduce the width of the table when resizing to 4.8" x 1.6" and end up with the same or worse in terms of legibility.

I don't think that even changing the cell background shading, page colour, text colour, or other formatting to increase contrast is going to help.  It's the miniscule size of the image that is problematic.  If it could be increased to nearer the page width of standard paper, then I'm sure you will get much better results.

As far as I'm aware, although I may be wrong, when you insert an image into a Microsoft Word document it is converted into Windows Meta File (*.WMF) mage format.  This lends itself better to stretching and squashing within the document without causing excessive degradation.  When you save an MS Word document as an HTML file it will extract the image content to separate images, and depending on your Word settings it may create PNG images for the new web page.

I don't think any of this helps or is to the detriment of the images in the Word document.  If they don't have the clarity due to the small size, then they won't appear any better or worse than the quality of the screenshot you reduced in size before inserting.

You might want to experiment and see if there is any difference between:
1. Capturing a screenshot at the full width as it appears in the browser, saving it as an uncompressed TIF or BMP image, or as a PNG, and inserting that into the document and squashing it to size within Word
AND
2. First cropping and reducing the size of the image, saving as an image as above, then inserting that image into the document.

I still don't think you are going to get legible text at the image size you need.

I will mess around and see if I can suggest something.

Bill
0
Ray PaseurCommented:
This does not look to bad on my screen/printer.

When talking about two-dimensional images, convention leads us to list the width first and the height second, so the image in this document is about 4.8" X 1.6".  That may not be exact, and it does not match the aspect ratio of the image in the screen capture I showed above.  In the screen capture the height was about 1.6" but the image was considerably wider, so this version is squished a little in the horizontal dimension.

Ones suggestion going forward - consider using Acrobat and making PDF files when you need precision in page layout.  It's a powerful tool!

All the best, ~Ray
dshrenik.doc
0
BillDLCommented:
Aaah.  I was including the "Create Table" link and the column/row options at the top left.

Yes, that looks to be about the minimum dimensions where any text in the cells should still be legible. The image inserted into the document (stored as EMF data) was 9.63" x 2.13" and was then squashed to 6.35" x 1.8".

I have attached my Word 2003 Doc into which I inserted a PNG image with dimensions as close to 4.8" x 1.6" as I could, and had no need to squash it.  To get the aspect ratio of 3:1 in the source image at those dimensions means the inclusion of a lot of white space on the vertical though.  I can JUST read the text, but I do believe that I may need glasses ;-)

I also attached the original source PNG file and its equivalent as a JPG for comparison purposes.  To resize the source PNG from the screenshot taken in Paint Shop Pro 7 I used Bilinear Resampling because it yielded the best results on the text I added to the table cells.

 dshrenik-02.doc

 The source image I inserted
 Image above as a JPG
Bill
0
BillDLCommented:
Thank you dshrenik
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Images and Photos

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.