javaScript window.print only printing portion from view

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gchq
    New Member
    • Jan 2007
    • 96

    javaScript window.print only printing portion from view

    Hi there

    I have a Table nested in a Div that in turn is nested in panel (with scrollbars) in turn nested in a multiview..

    The table has the class set as 'print' - that points to a css file via the link
    Code:
    <link href="../../../../Styles/Print.css" rel="stylesheet" type="text/css" media="print" />
    The CSS being quite simple -

    Code:
    body 
    {
        visibility:hidden;
    }
    .print 
    {
    visibility:visible;
    overflow:visible;
    
    }

    and a button with the following code in the Page_Load event

    Code:
    If not page.IsPostBack then
    PrintBalanceSheet.Attributes("onClick") = "javascript:window.print();"
    I've tried altering the length of both the Div and the table - there cannot be any 'overflow' and set, in turn, both the div and table class to print - but still it only prints a third of the total - this is probably due to the fact it sits within a panel with a scrollbar

    Soooo the question - is there any way (by changing the CSS) to make the whole table visible for printing?
  • gchq
    New Member
    • Jan 2007
    • 96

    #2
    Solved it!

    Code:
    Dim PBS As String
                PBS = "function printContent() { "
                PBS += "var documentContainer = document.getElementById('printDiv'); "
                PBS += "var windowObject = window.open('', 'BalanceSheetData', 'width=740, height=400, toolbars=no, "
                PBS += "scrollbars=yes, status=no, resizable=no'); "
                PBS += "windowObject.document.writeln(documentContainer.innerHTML); "
                PBS += "windowObject.document.close(); "
                PBS += "windowObject.focus(); "
                PBS += "windowObject.print(); "
                PBS += "windowObject.close(); }"
    
                ScriptManager.RegisterStartupScript(PrintBalanceSheet, GetType(Page), "PrintBalanceSheet", PBS, True)
                Me.PrintBalanceSheet.Attributes.Add("onclick", "printContent();")

    Comment

    Working...