Page 1 of 1

Printing Graph from a Web Project

Posted: Tue Jun 01, 2010 11:13 am
by 15655935
I am trying to give a user the option to print a graph on a web page, and I get a 'No Printers are installed' error, my pc does have printers installed though?
Load graph
Dim ch1 As Steema.TeeChart.Chart = WebChart1.Chart
Dim tmpChart As New MemoryStream()


Print Graph Button

Dim tmpChart As New MemoryStream()

If IsNothing(Session("ch1")) Then

Else
'retrieve the session stored Chart
tmpChart = DirectCast(Session("ch1"), MemoryStream)

'set the Stream position to 0 as the last read/write
'will have moved the position to the end of the stream
tmpChart.Position = 0

'import saved Chart
WebChart1.Chart.Import.Template.Load(tmpChart)

WebChart1.Chart.Printer.Landscape = True
WebChart1.Chart.Printer.Grayscale = True

WebChart1.Chart.Printer.BeginPrint()

WebChart1.Chart.Printer.Print(WebChart1.Chart, New Rectangle(50, 10, 1100, 800))

WebChart1.Chart.Printer.EndPrint()
End If

Above is my code snippet from my Print Graph button - Any ideas would be appreciated

Re: Printing Graph from a Web Project

Posted: Tue Jun 01, 2010 1:33 pm
by narcis
Hi JF_3D,

What about doing as discussed here?

Hope this helps!

Re: Printing Graph from a Web Project

Posted: Fri Jun 04, 2010 10:55 am
by 15655935
Thanks for advice, I am new to this, I have added Javascript at the beginning of my Source, but when I add printpage() to my button click I get the error 'printpage' is not a member of 'ASP.webiss_graph_history_aspx'.

This is my button code

<td style="width: 445px; height: 8px; text-align: center">
<asp:Button ID="btnPrint" runat="server" BackColor="#C0FFC0" Height="32px" OnClick="printpage()"
Text="Print Graph" ToolTip="Print Graph" /></td>


This is what I added at the top

<script language="Javascript1.2">
function printpage() {
window.print();
}
</script>

Re: Printing Graph from a Web Project

Posted: Mon Jun 07, 2010 3:37 pm
by 15655935
OK, I managed to print using the onClientClick from your example.

The problem I have is - I only want the graph to print - not the whole screen

Please help :(

Re: Printing Graph from a Web Project

Posted: Tue Jun 08, 2010 8:09 am
by yeray
Hi JF_3D,

Could you please take a look at here where something similar was discussed?