Crystal Report is automatically (randomly) adding white space after a sequence of text X's before a number in a field. Want to prevent the whitespace - crystal-reports

I have a field that I'm sure does not have white space in it at a certain location, but for some reason Crystal Reports is automatically adding space to the field but only after X's in certain scenarios. This is a text field which I'm sure is pulling down from a text field in the db as well.
This is hard to explain without a pictured example, so here's what I mean:
Random Spaces
As you can see, there is whitespace after the X's. it should not be there, as this is not what is coming from the db. And strangely, when copy/pasted from the report, there is no white space either! Here it is when copy/pasted straight from the report:
"Test 15dig w spaces XXXXXXXXXXX2345"
Why is this occurring, and how can it be corrected? Currently there is no real formula for the field, it is just taking whatever it coming from the db straight into that field. The whitespace is being added automatically somehow, and I'm not sure at all why.
Here is what I've tried: Have tried calling ToText on the field (even though it is already a text field). Have also tried formatting the field in various different ways. Tried asking on SAP forum but no help as of yet.

Copy & Paste the text "Test 15dig w spaces XXXXXXXXXXX2345" into a text object in Crystal. Apply the same font and formatting (use the brush toolbar button to clone the formatting).
If you don't see the same strange space, the problem is due to non-printable characters in the database field. In that case, you can strip away such characters using a formula and the Replace() function.

Related

How can I manage display and spacing on a Crystal Report where I have to display images between the text field?

I have a field that I'm displaying on a report that is a combination of text and codes that represent an image. Some of those icons have ascii symbols that I've used a replace formula to display them as their ascii version. For two or three of the images, I have no luck and have to display a mini picture for the representation.
The codes being sent are something like:
^he^ = ♥ ^st^ = ⭐ ^cl^ = 🍀 etc...
So for the clover leaf, there is no emoji support in my version of Crystal for clover leaves, and the ascii icon I found online for it just shows the empty square icon when an emoji isn't supported.
My workaround for this is to have a formula that converts all my icons to the appropriate ascii where supported, and to leave two blank spaces for the unsupported icons.
>stringvar gift_msg;
>gift_msg:= {DataTable1.gift_field};
>gift_msg := replace(gift_msg,"^CL^"," ");
>gift_msg := replace(gift_msg,"^HE^","♥");
>gift_msg := replace(gift_msg,"^ST^","★");
>gift_msg
I then put a suppression formula on each image that looks like this:
>mid({DataTable1.gift_field},2,4)<>"^CL^"
So I duplicated the image along the length of the field and increment the mid formula to match the field. I also set the font to Consolas so that it's fixed width to remove any surprises in spacing. My issue is that this still creates very strange spacing, and I'm almost certain there's a much easier way to do this.
One option is to use a free service such as Calligraphr.com to convert your image to a font.
Given that your image relies on several colors, the font option might not work.
Another option is to build the expression as html with image source directives where you need them. You would then need a create or use a 3rd-party UFL to convert the full expression to an image that you can load on the fly using the Graphic Location expression. At least one of the UFLs listed by Ken Hamady here provides such a function.

Dynamically create textbox rotated by 180 degrees

I would like to create a Word document with multiple text boxes that serve as name badges. Each name appears twice, once set normally and once rotated by 180 degrees. Later, they are printed on paper, cut and folded, so they can stand on a table.
I am using docx4j to generate the DOCX file. My idea is to have a fragment in one Word file that serves as a template for a single name badge. I'd like to load that template and fill the placeholders with real names. Multiple fragments are then concatenated and written to a second Word template, so ultimately I have a list with multiple name badges. The paper I use allows two name badges on each page (i.e. four text boxes).
However, I fail implementing this with docxj4. This is what I tried:
(1) First, I tried filling a single name badge. The placeholders got filled correctly, but the rotated text box of my Word template (input) became an ordinary (not rotated) text box in the output file.
(2) I also tried MainDocumentPart#addParagraph(String) and created the entire paragraph myself, using XML code generated in Word (where the text box was rotated). The output generated by docx4j, however, again did not respect the rotation. It created two text boxes, but when I view them in Word now, I even cannot rotate them there anymore. It seems like the generated text boxes are different from those created by Word in the first place.
Long story short, how can I create a rotated text box with docx4j?
It would be very convenient, if I could have a Word template to layout the name badges, but if I would have to create the entire thing programatically, it would be fine, too. Also, other ways of rotating text would be okay for me. But it seems like text boxes are the only objects in Word that can actually be rotated by 180 degrees.

Word/Publisher email merge issues

I've been searching for days for an answer to this issue. I'm trying to append an Access field to a base URL to customize each email in my merge like so: http://www.example.com/myItems.asp?ItemID={field}.
I tried several approaches in Word 2007, then gave up and finally tried Publisher after coming across this post - MS Word: Mailmerge hyperlinks with query get URL string with a MERGEFIELD.
In Publisher, I got everything to merge properly including the custom links (according to preview), but when I hit "send email" it wasn't passing the emails to Outlook - said 0 message(s) sent. I tried again, using a blank email template and got it to pass the email, but the email showed field names rather than the merged data.
Coming across this article regarding the field names - http://msgroups.net/microsoft.public.publisher/emailmerge-not-working-in-publishe/213664 - I clicked outside the text box as suggested before sending email but still, the field names show and not the merged data.
I'm super frustrated and exhausted. This shouldn't be this difficult! Any ideas or suggestions would be appreciated.
This shouldn't be this difficult!
I agree. I can't help on the Publisher front, but this link should help for Windows Word.
To summarise, when you insert the HYPERLINK field, do it this way:
Use ctrl-F9 to insert a field code brace pair { }
Type HYPERLINK between the braces
Select the field and update it once (F9)
Do not update this field code again. If you do, Word will always insert the same link text (i.e. the hyperlink target). People working with fields often select F9 quite a lot just to make sure things are up to date, so you have to try not to do that.
If you Alt-F9, you should see that the display text is an error message (starting with "E" in the ENglish language version of Word).
Move the insertion point so it is immediately after the E. Type the display text that you want, or, if you want a variable display text built from text + MERGE fields etc, enter that text and those codes).
Carefully remove the "E" and the other part of the error text.
Use ALt-F9 again to display the HYPERLINK field code. Click after the K, type a space, then enter the following fields and text, assuming your variable text is coming from a MERGE field called fieldname:
"{ SET X 1 }http://www.example.com/myitems.asp?ItemID={ MERGEFIELD fieldname }"
(The SET field is there to stop Word doing something else wrong. If you have more than one HYPERLINK field, you will need to SET a different variable name (X1, X2 etc.) in each HYPERLINK). This is discussed in more detail here - interestingly enough, that question was also about merge to HTML email, but I think you also have to do the additional stuff I mention above to make it all work.

JasperReports: Prevent textField to split on space or hyphen

I have a JasperReports template that contains a textField element that will contain a variable length of strings. If the string is too long to fit the width, it'll be split which is fine except when the string contains a hyphen or a space char. In this case the string is split from that char. Below are some example of what's the input, observed outcome and wanted outcome + summary to make my point easier to understand.
input observed wanted summary
_____________________________________
overflow -> overfl -> overfl : OK
over flow -> over -> over f : NOT OK
over-flow -> over- -> over-f : NOT OK
Setting the reportElement to have isStretchWithOverflow="true" attribute will split the text on two lines, but this is not wanted behaviour.
Is there anyway to fix this?
Thanks.
EDIT: The input data comes from an external source, so I cannot directly change that. I ran some tests and noticed that using non-breaking space will do for spaces. non-breaking hyphen on the other hand is not printed at all, i.e. text 'over-flow' becomes 'overflow'. Not quite what is wanted.
Despite the input source not in my control, I could fix this problem by writing a Scriptlet that'll change spaces to non-breaking spaces and hyphens to non-breaking hyphens, only if those darn non-breaking hyphens would be printed.
Printing to PDF by the way, in case that gives some hints of the problem.
Type in the Text field ''Expression'' like this:
String.join("\uFEFF", $F{field1}.split("(?!^)"))
It's a font issue. Non-breaking hyphen works(\u2011) fine, when the font supports it. See fonts sample on how load other than the default font (DejaVu Sans for example).
If anyone has a better option for the input source modification than the Scriptlet, please let me know.
(Marking my own answer as correct in order to get this topic closed.)
EDIT: Have to wait for two days in order to mark this answer correct.

How can one tell if a field has wrapped in Crystal Reports 2008?

In Crystal Reports 2008, I need to have an accurate count of all of the lines that have been displayed in a sub report.
I'm using a shared variable and incrementing as needed when lines display. The only problem I'm having now is when a field wraps. We are not using a fixed width font, so going by field length does not solve the issue, as 'i' is not as wide as 'w' and so on.
Is there a way to find out if the data in a field will be wrapped, and if so how many lines it wraps to, or is there a way to find out what the height of the section that the field is in (or the field itself) has grown too?
Or, is there an even better way to count how many lines have actually displayed on the sub report?
No, there is no way to do what you describe.
If you used a fixed-width font, you could then do some math based based on "it wraps at X characters" do if length of string is 100, then it went 2 lines, etc.