cancel
Showing results for 
Search instead for 
Did you mean: 

Print crystal report PDF client side using ASP.NET

Former Member
0 Kudos

I have developed am ASP.Net 4.0 application that generate a PDF from report on the server. my problem is that i want the user to click a button on the from and for the pdf to print sliently to a printer. the printer name is stored in the database. i believe this is possible using ActiveX. i have also came across Scriptx but client is not willing to pay the licensing fees. if anyone could enlighten me on the options i have or point me in the right direction that would be great.

the PDF is not static so embeding on client is not an option

the PDF is basically a label for a Parcel which contains Name address and a barcode

Accepted Solutions (1)

Accepted Solutions (1)

former_member183750
Active Contributor
0 Kudos

Once the report is rendered to a PDF, it really is out of CR control. What you may want to do is an export to PDF, save it client side, then use Adobe APIs to print it on the client.

About all I can think off...

Ludek

Follow us on Twitter http://twitter.com/SAPCRNetSup

Got Enhancement ideas? Try the [SAP Idea Place|https://ideas.sap.com/community/products_and_solutions/crystalreports]

Answers (3)

Answers (3)

Former Member
0 Kudos

Cheers for you advice Ludek

looks like im no further on.

so this is not really possible by clicking on a server side button, without the use of third party or ActiveX?

former_member183750
Active Contributor
0 Kudos

Yeah... brave new world of the internet...

Have a great weekend,

- Ludek

Former Member
0 Kudos

in a nutshell the application is a web site for a parcel delivery company. the site will be used by its customers(ie:shops, warehouse staff) the end users will enter details of where their parcels are to be deliverd. when the info is generated the app is to produce sticky label( the rpt) to be stuck on the parcel. this is all working fine apart fromt the fact that the user need to view the label and click print. in a warehouse this is to slow. when new parcel is added the printer should just spit out label.

it dosent have to be PDF but i heard that produces the best results. can this be done client side as rpt without viewer and without clicking print?

any help on this would be great as i seem to be going around in circles. cheers

just finishing work now Ludek so will catch up tomorrow

Edited by: stephenPolin on Oct 27, 2011 6:29 PM

former_member183750
Active Contributor
0 Kudos

Problem with direct print to a client printer is that by definition there will be no user intervention. IE does not allow this as that is a major security treat.

To achieve client-side printing where all the pages of a Crystal report can be printed to the client, some kind of client-side code needs to be executed. Adobe Acrobat and Microsoft Word achieve printing entire documents by supplying a client side control that can access the entire document and print it. This solution isnu2018t zero-client, meaning that a component must be installed on the client machine.

So, as I mentioned in my previous post, if PDF is not the way to go, then you can use an RPT. But again, somehow you need to get it on to the client. The client would have to have the CR runtime and a small one button app - again requiring user intervention...

When you google client side printing for CR, there are articles that describe client side printing by "faking" (e.g.; client side code) things out via java applets. But, this is a security threat and you'd be on your own implementing this.

- Ludek

Former Member
0 Kudos

Any ideas how i would go about this? is it possible? can i access the clients file system. is there any way to do this with the report instead of exporting to PDF. i dont want to display the report in a viewer just print.

the code i have at the moment

Public Sub print_ems_label(ByVal consignmentID As Integer)

Dim sqlcon As New SqlConnection

Dim sqlcom As New SqlCommand

Dim sqlda As New SqlDataAdapter

Dim ds As New DataSet

Dim rpt As New ReportDocument

Dim reportPath As String = Server.MapPath("~/reports/Label128.rpt")

sqlcon.ConnectionString = Settings.ConnectionString

sqlcom.Connection = sqlcon

sqlcom.CommandType = Data.CommandType.StoredProcedure

sqlcom.CommandText = "sp_reports"

sqlcom.Parameters.AddWithValue("@Action", "lbl_39") ' SAME REPORT FOR BOTH

sqlcom.Parameters.AddWithValue("@ConsignmentID", consignmentID)

sqlda.SelectCommand = sqlcom

sqlda.Fill(ds)

rpt.Load(reportPath)

rpt.SetDataSource(ds.Tables(0))

Dim mem As IO.MemoryStream = DirectCast(rpt.ExportToStream(CrystalDecisions.[Shared].ExportFormatType.PortableDocFormat), IO.MemoryStream)

Response.Clear()

Response.Buffer = True

Response.ContentType = "application/pdf"

Response.BinaryWrite(mem.ToArray())

this is ok but it is displayed in PDF Browser plugin which is not meeting clients requirements of slient print.

can i do this wihout creating pdf?

Edited by: stephenPolin on Oct 27, 2011 4:42 PM

former_member183750
Active Contributor
0 Kudos

Hello Stephen

I really do understand what you are trying to do, but without some Adobe APIs, you will not be able to do this. E.g.; there is no CR APIs at this time for direct PDF print to a client printer. Rumor has it there is something on the way - for BOE... if it ever makes that to the CR SDK is anyone's guess.

Now, a question that occurs to me is; would the requirements of the app allow you to print this report as an rpt file to the client printer? This we can do - no ActiveX print or anything. Just send report to printer where the printer is client side. If this is a possibility, let me know and I'll fire off some resources your way on how to do this.

- Ludek