I’m using Perpetuum Reports to print the invoice in my application. Now I need to allow my users printing the invoice. How should I do it using hiperlink?
I use the following code but it doesn’t work:
<script src="@Url.Content("~/Scripts/jquery.treeview.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/mscorlib.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/PerpetuumSoft.Reporting.WebViewer.Client.Model.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/PerpetuumSoft.Reporting.WebViewer.Client.js")" type="text/javascript"></script>
<script type="text/javascript">
var reportViewer = null;
$(document).ready(function ()
{
var reportViewer = new PerpetuumSoft.Reporting.WebViewer.Client.ReportViewer("#ReportViewerElement");
reportViewer.setServiceUrl("http://jmanlocal/ReportServiceController");
reportViewer.reportName = "InvoicesRep";
reportViewer.renderDocument();
reportViewer.setThumbnailsControl("#ssr_thumbnailContentPanel");
reportViewer.setDocumentMapControl("#documentMapView");
});
function PrintRep()
{
reportViewer.exportToPdf();
}
</script>
<div id="ReportViewerElement"></div>
<button onclick="PrintRep()">Print</button>
It looks like you have extra var key word in your document.ready handler. It declares local variable for your handler function, so global reportViewer variable does not get reference to your report viewer. So, this is corrected code: