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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert field text to html ok in VS 2005, not in PDF 1

Status
Not open for further replies.

adrianjohnson

Programmer
May 16, 2002
145
GB
Hi all,

We've developed an ASP.Net application in Visual Studio 2005. The data is stored in a SQL Server 2005 table, and the field concerned is of type nvarchar.

We then created a Crystal Report (version 11.5 SR 2), and added the field into it. Next, we formatted the field to display as html text, as the field contains html syntax (nothing major, just the 'p' and 'br' tags).

When the report is previewed in Visual Studio, the field is displayed correctly. When the project is run, the report is converted to PDF and displayed but the field shows the html tags!

How can we get the html in the PDF document to display properly?

Thanks,

Adrian
 
Try formatting the report field with the html. Select Format Field. The under Text Interpretation select "Interpret data as HTML data"

From help on version 9.

"
Text Interpretation constants
The following constants are defined to support importing data which is pre-formatted in Rich Text Format or HTML, and inserting it into a report as string or memo fields.

Constant Description
crUninterpretedText
Interpret data as plain text.

crRTFText
Interpret data as Rich Text Format data.

crHTMLText
Interpret data as HTML data."

Regards




 
Thanks for the reply, but we're already doing that:

Next, we formatted the field to display as html text, as the field contains html syntax (nothing major, just the 'p' and 'br' tags).

Any other ideas?
 
You could try replacing the tags with ansi characters, as in:

replace(replace({table.field},"<br>",chr(13)),"</br>","")

I'm not sure what would replace the <p> for paragraph, but you could continue nesting the replace function, as above, if you find the answer to that one. Then of course remove the html interpretation.

-LB
 
Thanks lbass. Your idea worked ... sort of.

I'm quite new to formulas in Crystal, and as you can imagine, there are a number of tags in the field that need replacing.

Here's my code so far. I removed the html interpretation and added this formula to the Display String of the field:

Code:
whileprintingrecords;

stringvar sample := replace(replace({FieldName},"</p>",chr(13)),"\n","");
sample := replace(replace({FieldName},"<br>",chr(13)),"\n","");

sample;

This code doesn't work. It just replaces the last html tag (<br>) and not the </p> ones. How can I get it to loop through all the tags in the field?

Thanks

Adrian
 
Sorted it. It was me being a bit dim.

Code:
whileprintingrecords;

stringvar sample := replace(replace({FieldName},"</p>",chr(13)),"\n","");
sample := replace(replace(sample,"<br>",chr(13)),"\n","");

sample;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top