Keeshan
asked on
Question regarding printing crystal reports using printDocument
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?
Thanks!
Are there any ways for me to convert these characters into a a readable one?
Thanks!
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.
What file are you reading? How are you creating that file?
mlmcc
mlmcc
ASKER
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?
to Frodoman: do you know the ways on how to search and replace that characters and convert them into readable codes?
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), " ")
HTH
For example in vb to replace a line-break control character with a space character the code would be: targetString = Replace( sourceString, chr(10), " ")
HTH
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...
ASKER
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?
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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.