Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I print bold face a word of a string in the report? 1

Status
Not open for further replies.

binhpham

Programmer
Oct 12, 1999
33
0
0
US
Hi all
I have a report print out a memo field, it look OK until my boss want to print bold face a certain word in that field.
I know the fix location in that string .
Example :
line 1: "Hello this is a test,Finding:This is an example of print memo field"
line 2: "Recommendation:This is a example xxxxx"
How we can bold face just the word "Finding:" and "Recommendation:"
Any help would be appreciated.
Thanks
 
You'd perhaps not do this with the legacy report label control. Take a look at the reportlistener and read the basic chapter "Using GDI+ in Reports".

If you want to do more with reports you may like the Report Sculptor, which enables you to do things you might not even have imagined:
Bye, Olaf.
 
Hi Binhpham,

This is not really possible using the normal VFP reporting tools. There are various ways in which you can achieve this goal, but they all involve using either third-party controls or some advanced programming, or both.

My advice would be to ask your boss how badly he want this feature. You could end up spending a lot of time, and possibly some money, in getting it.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Hi Mike Lewis ,
Thanks for your answer,I can use rich text box but it only works on screen, when I print it out using report tool I could not find the control rich text box. I try use the text control in report, it output something like this
"{\rtf1\ansi\ansicpg1252\deff0{\fonttbl{\f0\fswiss
Arial;}{\f1\fnil\fcharset0 Arial;}}
{\colortbl ;\red255\green0\blue0;\red0\green255\blue0;}
\viewkind4\uc1\pard\li180\ri240\lang1033\f0\fs20 The \b RichTextBox\b0"

Any idea?
Thanks
 
As the others above have suggested the VFP Report Form assigns a single Font and its associated attributes to an entire textbox field within the report, not to individual pieces within the text string.

If you are printing your entire Memo field contents within a single Report Form textbox, you will not be able to do what you want.

You could parse the individual sentences (or other pieces) out of the Memo field and put them individually into their own field before going to the Report Form.

Then within the Report Form you could put in over-lapping textboxes representing the BOLD word and non-BOLD word each with its own Font and an appropriate Print When.. expression.

This is a good bit of work, but it can get the job done.

Good Luck
JRB-Bldr
 
JRB-Bldr,

within the Report Form you could put in over-lapping textboxes representing the BOLD word and non-BOLD word each with its own Font and an appropriate Print When.. expression.

I wondered about suggesting something along those lines to Binhpham. But when I started thinking about it, I realised how tricky it would be. Remember, bold text takes up slightly more width than non-bold. So if you had multiple instances of bold text, and these were non-contiguous, you would somehow have to calculate the offset of each bold string from the previous one, taking account of line endings, word wrap, and so on. I guess it might be do-able, but I wouldn't like to have to do it myself.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Mike - you are correct.

But in his example above there are shown 2 BOLD words, each of which are the first word in the line

Finding: This is an example of print memo field
Recommendation: This is a example xxxxx


If this was all there was to it, then it wouldn't be TOO hard nor TOO messy to bring it off.

And the differences between BOLD and non-BOLD font widths would not be too terribly difficult to account for when laying out the individual Report Form textboxes.

Actually if each Memo field had one "Finding:" followed by one (or more) "Recommendation:" (could be a GROUP) then this could be even easier.
By parsing out the individual lines into individual records as suggested above, and then using STRTRAN() to remove the actual words "Finding" and "Recommendation" from the lines, those line 'headings' could be 'hard coded' into the Report Form as BOLD TextLabels.

JRB-Bldr
 
Hi all
Thanks for all suggestions, but the words need to be bold face not always at the top of the string :
Example :
line 1: "Hello this is a test,Finding:This is an example of print memo field" (not at top of the string)
line 2: "Recommendation:This is a example xxxxx" (top of string)
I think I will try "richtx32.ocx"
I will update this problem when i can.
 
I agree with OlafDoschke, if you need to embed different fonts, sizes, italics, bold or other within a report field, you should do it with the ReportListener class.

I have seen it done and followed the logic, but i haven't done it myself. If this is the only place you'll ever need to do special formatting, it may not be worth the effort. But if there will be other uses for it, then do investigate the ReportListener class.
 
Hi Binhphan:

You have lot of good idea to tackle the problem. I want to add my few cents here. If you are printing to a specific printer all the time, example HP Laserjet. Try adding the 'Bold Esc Sequence'(Start and End). Give extra spacing to the right to count for the Bold. May have problem for right allign.

Nasib



 
binhpham said:
I can use rich text box but it only works on screen, when I print it out using report tool I could not find the control rich text box. I try use the text control in report
Have you tried the Picture/OLE Bound control on your report? I have used this to retrieve a general field that contains a rich text document. In my case, the text is static and not generated from data in a table as it seems you need to do. I found a Microsoft article on generating a Word document from data and appending it to a general field:
How to print a general field by using Word and Visual FoxPro 9.0 or earlier versions

But, it would probably be more worthwhile to learn how to use the ReportListener instead.

Teresa
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top