Utilize the Microsoft Report Viewer for printing and I highly recommend it. Create a high-quality report on an aspx page and display it within a frame in a popup window. Ensuring alignment issues are non-existent is crucial.
Alternatively, construct the report as HTML and embed it into the frame. Check out this functional example: http://jsfiddle.net/D4K3E/1/,
here is the specified code:
ShowPrintWindow = function (frameUrl, title, width, height, hidePrintButton) {
height = height ? height : 509;
width = width ? width : 675;
if (typeof (title) == 'undefined') title = 'Print';
var win = Ext.create('Ext.window.Window', {
id: 'printWindow',
width: width,
height: height,
autoDestroy: true,
title: title,
iconCls: 'icon-printer',
modal: true,
items: [{
border: false,
html: '<iframe id="printFrame" src="' +
frameUrl +
'" width="' +
(width - 12) +
'" height="' +
(height - 61) +
'" frameborder="0"></iframe>'
}],
layout: 'fit',
buttons: [{
iconCls: 'icon-printer',
text: 'Print',
hidden: hidePrintButton ? true : false,
listeners: {
click: {
fn: function (item, e) {
printIframe('printFrame');
}
}
}
}, {
text: 'Close',
listeners: {
click: {
fn: function (item, e) {
Ext.getCmp('printWindow').close();
}
}
}
}]
}).show();
};
function printIframe(id) {
var iframe = document.frames ? document.frames[id] : document.getElementById(id);
var ifWin = iframe.contentWindow || iframe;
iframe.focus();
ifWin.print();
return false;
}