Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Question regarding printing crystal reports using printDocument

Posted on 2004-08-17
Medium Priority
Last Modified: 2008-01-09
Im currently developing a print report winform application that will print a crystal report without using the crystal reports viewer and the printdialog component in c# winform. Iam retrieving the data of the crystal report (line per line) using the printpage event in order for it to be a printDocument. Im enabling it to be used in the print preview dialog and pagesetup dialog. However, whenever i do this, it returns unreadable ASCII characters in the print document.

Are there any ways for me to convert these characters into a a readable one?

Question by:Keeshan
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
LVL 42

Expert Comment

ID: 11819863
I assume these unreadable characters are formatting and positioning elements - you could probably do a search & replace to get rid of them or convert them to something harmless like a (space) char, etc.
LVL 101

Expert Comment

ID: 11819903
What file are you reading?  How are you creating that file?


Author Comment

ID: 11826832
Im reading a rpt Crystal Reports file.initially i get the file using a filestream and assigned it in a streamreader, then read it in the printpage event for print previewing, page setup, and printing.

to Frodoman: do you know the ways on how to search and replace that characters and convert them into readable codes?
On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

LVL 42

Expert Comment

ID: 11827065
You'll have to first identify the characters - which may take a little effort.  I don't code c# but most languages have some variation of a "replace" function that typically looks something like this:  targetString = Replace( sourceString, searchText, replaceText )

For example in vb to replace a line-break control character with a space character the code would be: targetString = Replace( sourceString, chr(10), " ")

LVL 42

Expert Comment

ID: 11827069
By the way, have you considering that instead of trying to read the .rpt file you may want to export the output of the report to a different format (.txt or .csv perhaps) and then use those as the source for your filestream?  I suspect this would give you a much cleaner file to work with...

Author Comment

ID: 11827170
I already tried to export the rpt file into a different format but still produced wrong data. i also tried your solution regarding the way replacing, but the problem is that the data generated by the report is retrieved from dbase. in this case, i dont know if that code is an equivalent for a space,char, etc.. and i dont even know what kind of ascii char it prints.. do you get my pt? :D thanks!

Another alternative im trying to do is to make use of the reportDocument of the crystal report. But i cant convert it into a printdocument in order for it to be used in printpreview and page setup dialogs in c#.. is it possible to convert reportDocument into a printDocument?
LVL 42

Accepted Solution

frodoman earned 500 total points
ID: 11829575
>>> in this case, i dont know if that code is an equivalent for a space,char, etc.. and i dont even know what kind of ascii char it prints.. do you get my pt?

As I said, you'd have to identify the characters to be replaced which will take some effort.  Probably you'll have to read from the stream and dump the ascii value of each character and examine them manually to identify the non-printing values for replacement.

If that doesn't work you may need to read the report as a binary stream and then decided on a byte-by-byte basis which values to discard and which to convert to ascii for display.

It's possible to do because there are 3rd party viewers out there that obviously can parse .rpt files.  I don't expect that it's an easy undertaking however and you're unlikely to find much in the way of documentation to help you.


Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question