Symptom
- How to format the first line of a paragraph differently?
- How to print the first line of a paragraph in a different font size in Crystal Reports?
Environment
- SAP Crystal Reports 2008
- SAP Crystal Reports 2011
- SAP Crystal Reports 2013
- SAP Crystal Reports 2016
Resolution
- To format the first line of a paragraph with a different font size, use HTML Tags, and format the field to use HTML Text Interpretation:
- In Crystal Reports, open the report or create a new report.
- Create a formula that add html tags to change the formatting of the first line of a paragraph like:
numbervar lf := instr({String_Field},chr(10));
if lf = 0 then
'<big>'&{String_Field}&'</big>'
else
'<big>'&Mid({String_Field},1,lf-1)&'</big>'&
Replace(Mid({String_Field},lf,len({String_Field})),chr(10),'<br>')
Another formula example will be:
numbervar lf := instr({String_Field},chr(10));
if lf = 0 then
'<font size="5">'&{String_Field}&'</font>'
else
'<font size="5">'&Mid({String_Field},1,lf-1)&'</font>'&
Replace(Mid({String_Field},lf,len({String_Field})),chr(10),'<br>')
- Save the formula and insert it on the report.
- Right click on the Formula Field just inserted on the report, and select "Format Field..."
- In the "Format Editor" window, under the tab "Paragraph", set the "Text interpretation" option to: "HTML"
- Still in the "Format Editor" window, under the tab "Common", check the option "Can Grow"
- Click "OK" to accept the change.
- For a list of supported HTML Tags to format the text, see the SAP Knowledge Base Article: 1217084
Keywords
font style, change font style, print fist line in different style, print first line in bold. , KBA , BI-RA-CR , Crystal Reports designer or Business View Manager , How To
Product
Crystal Reports 2008 V1 ; SAP Crystal Reports 2011 ; SAP Crystal Reports 2013 ; SAP Crystal Reports 2016