Report Design
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Report Design
Message Icon Topic: Matching CR with .NET Post Reply Post New Topic
Author Message
DreamState
Newbie
Newbie


Joined: 13 Mar 2007
Online Status: Offline
Posts: 16
Quote DreamState Replybullet Topic: Matching CR with .NET
    Posted: 03 Apr 2007 at 3:53am
I asked this question some time ago on the MSDN forums to no avail. I gave up in the end, settling for a make do situation. But having come across this forum I thought, heck, I'll ask it again LOL

The situation is this.

I have a Crystal Report and I have a .NET application. What I want to achieve is a perfect (or as near as possible) match between a CRTextbox on the report (which takes a field from a database) and a RichTextBox in the application. Essentially, I want to know how many lines will fit in the CR textbox and match it with the RTB. So if a user goes over this 'line limit' I can warn them. Unfortunately, the box in the report can't just stretch as it has been designed to be such a size.

Currently, I match up the fonts, get a rough line number whilst editing the report itself, and then use that line number to limit the rtb. However, this limits the text box to plain text. No text formatting etc.

Ideally, I would like to supply the width and height taken from Crystal Reports and some how use them in .NET to give the user all the Rich Text formatting but with warning if they stray over the box size.

Does that make sense? lol. DeadDead

Any thoughts, nudges in a certain direction, ideas, etc will be appreciated.

Jon.
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 03 Apr 2007 at 11:05am
Yes, what you are saying makes sense. But I would do it the same way you are doing it. I don't know a way around it b/c using different fonts gives you a different number of characters that can fix in the textbox. I saw a formula for doing something similar once (but not exact) and its not an easy task. I think you are limited to using fixed font b/c CR doesn't have any such functionality built in.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
DreamState
Newbie
Newbie


Joined: 13 Mar 2007
Online Status: Offline
Posts: 16
Quote DreamState Replybullet Posted: 13 Apr 2007 at 2:38am
Brian,

Sorry for the delay in reply.

I have managed to code a system that takes the dimensions of the crystal reports box and is able to work out the various numbers of lines/characters dependent on the font supplied at runtime (from a database). It can then warn the user if they have gone over the available size, irregardless of what font or formatting they use.

So this works well for my needs.  The dimensions are the CR size divided by 15 for the windows form.

What is frustrating, and something I find hard to work out why, is that if I set a different printer to the default, the number of characters that can be printed in the box changes.

If for example, I set the default printer to a laserjet (HP2200 for arguments sake), then launch the report viewer, what I wrote into the box in the windows form (the application) exactly matches the printed version. So line one ends with 'the', line two with 'and', etc.... it matches fine.

Now, if I set the default to a deskjet (HP 990c) and do the same, the number of characters that appear in the box in the report viewer is quite a bit less and the windows form version and the crystal reports version do not match up.

What would be useful to know is whether this is always going to be the way or whether there is a way I can compensate for this.

Thanks,

Jon.
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 13 Apr 2007 at 8:13am
Each printer driver works slightly different than the others. This has been a source of frustration for CR users since the beginning. The recommendation is to set the printer to be No Printer in design mode and that way the report formatting is generic for multiple printers. Then this gives you the most consistent match across multiple brands of printers. But since you are trying to be so precise then this might still not be good enough for you.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
DreamState
Newbie
Newbie


Joined: 13 Mar 2007
Online Status: Offline
Posts: 16
Quote DreamState Replybullet Posted: 18 Apr 2007 at 12:48pm

Hi Brian,

I tried your suggestion about selecting no printer - this is the ideal for me if I could know for certain that it would print identically every time on EVERY printer (and all exports to PDF and printing using the 'printtoprinter' method !). Is this something you know is completely printer (and screen dpi, font, etc) independent as it may be the way forward for me. With a printer the form box size is 15th the size of the CR text box. With the no-printer version its like 16.78 or something (as it doesn't allow as many characters per line or indeed as many lines ?? - is it printing all characters fixed width?? this would not be so good?) but I could get it very close I think.

Another frustrating thing is replicating the issues! I have witnessed the amount of characters able to be printed in the box alter when printers change, etc but do think I can replicate the issue tonight for testing. LOL no chance. If anyone can shed some light on this I would appreciate it. I am using CRXIr2 - I think things are printed in a different way to than before?

Meh, maybe I am getting too tired - I've tackled this issue a number of times and given up. I guess I'll carry on down the avenue that the report is designed for laserjets to be printed on laserjets (it seems most laserjets come out roughly the same compared to inkjets). And also leave some additional space in the report just in case the odd word drops down a line and causes the text to go drop off the text box.

Jon.

 
 
Jon.


Edited by DreamState - 18 Apr 2007 at 1:27pm
IP IP Logged
DreamState
Newbie
Newbie


Joined: 13 Mar 2007
Online Status: Offline
Posts: 16
Quote DreamState Replybullet Posted: 19 Apr 2007 at 12:05am
I was thinking about this overnight (who else dream-programs lol) and I think using the generic printer reverse the problem somewhat.
 
I do think that the generic printer method (ie. no printer) will print accurately with all printers, print methods and exports (would need to test). However, it seems to space out the characters a little differently which means now that the Rich Text Box cannot accurately match it! So I could get CR printing correctly irregardless but now I can't match the RTB to it ConfusedAngryCry...!!!
 
I tested with a print out and it spaces the 'i' out more than the RTB (just an example character - more like a fixed character width?). The RTB doesn't do this and hence even if the two widths (the RTB and CR Text Box) match, in some cases one will show a word a line down whilst the other doesn't!!!
 
Slightly closer maybe? How to alter the RTB.....Stern%20Smile
 
Jon


Edited by DreamState - 19 Apr 2007 at 12:07am
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.