[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2212
  • Last Modified:

DELPHI RTF PARSER

Hi Experts,

Is there a component that parse raw rtf files?

What i need is code that will allow me  to read the raw rtf and then replace the rtf tags with my own, for example #13#10 with </br> and so on. (left,center/bold/italic/fontname,size...)

any IDEA?
0
Remmie26
Asked:
Remmie26
  • 15
  • 10
  • 2
  • +1
2 Solutions
 
jimyXCommented:
Check this out:
http://www.trichview.com/
0
 
Remmie26Author Commented:
that will not work, I have woll2woll and devex that gives you the same info as trichview. what I need is some sort of a parser that will give you the structure of the document as well as the plain text
0
 
aikimarkCommented:
1. Rather than an RTF parser, what about an RTF-to-HTML converter?

2. Is this a one-time conversion or on-demand conversion?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
Remmie26Author Commented:
1. I thought about the RTF to HTML converter but it will not work as well the output I am trying to get is a weird xml type output but this is what the client wants.
2. on demand a user create the rtf document hit convert and the output is stored in the above format. to be used later on with a different system.
0
 
aikimarkCommented:
>>XML

Please explain.  There is no character formatting in XML.  XML is a data transport specification.  There are RTF-to-XML converters for OpenOfficeXML reformatting.  You might also use Microsoft Word automation to accomplish such a conversion.
 
0
 
Remmie26Author Commented:
the idea is to this  

{\rtf1\fbidis\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\froman\fprq2\fcharset0 Times New Roman;}{\f1\fnil\fcharset0 Tahoma;}}
{\colortbl ;\red0\green0\blue0;\red0\green0\blue255;}
\viewkind4\uc1\pard\ltrpar\sa201\sl276\slmult1\qc\cf1\b\f0\fs20 IN THE CIRCUIT COURT OF THE ELEVENTH JUDICIAL CIRCUIT\line\pard\ltrpar IN AND FOR \cf2\f1\fs16 [get(COUNTY_CODE)]\par
\pard\ltrpar\sa201\sl276\slmult1\qc\cf1\f0\fs20


make it into

<font face="roman" size="10" color="#000000">
<p align="center" before="0" after="0" lines="0" lindent="0" rindent="0" >
<b>
IN THE CIRCUIT COURT OF THE [get(COUNTY_JUDICIAL_CIRCUIT)] JUDICIAL CIRCUIT<br />
IN AND FOR [get(COUNTY_NAME)] COUNTY, FLORIDA<br />
CIVIL ACTION<br />
</b>
</p>







0
 
Remmie26Author Commented:
word to xml add so many not needed attributes it is almost imposable to use
0
 
aikimarkCommented:
That really looks like HTML, not XML.
0
 
Remmie26Author Commented:
I know, As I said it is a weird looking xml file that the client load to his other system and I need to follow his guidlines
that why i wanted a parser so I can stringreplace the values with his values.

any ideas?
0
 
aikimarkCommented:
>>any ideas?

* Evaluate the RTF-to-HTML and RTF-to-XML converter utilities to see if any of them will do what you want.

* Find a way to render the RTF in a way that you can inspect its paragraph and text formatting.  The reason I mentioned Word automation is that Word will render RTF and your program can use the properties of the rendered text to create the output your client desires.  You should start with the Delphi RTF component.

* use the C# code in this article to create a utility function that you can call from your Delphi application
http://www.codeproject.com/KB/recipes/RtfConverter.aspx

* Look RTF parsing examples in other languages (PERL, Java, PHP) as utilities that you might shell from your Delphi application and consume the utility's output.

* Consider at two-step process.  First, convert/render the RTF as a PDF and then convert/output the PDF contents as HTML.
0
 
Remmie26Author Commented:

* Find a way to render the RTF in a way that you can inspect its paragraph and text formatting.

that is what I am looking for.

* use the C# code in this article to create a utility function that you can call from your Delphi application
http://www.codeproject.com/KB/recipes/RtfConverter.aspx

did it already didn't help.

* Consider at two-step process.  First, convert/render the RTF as a PDF and then convert/output the PDF contents as HTML.

interesting I will investigate this

Thanks.
0
 
Ephraim WangoyaCommented:

Take a look at JvRichEditToHtml.pas from JEDI as well

You can modify that to suite your needs
0
 
aikimarkCommented:
@ewangoya

Do you have any experience with that unit?
0
 
Remmie26Author Commented:
or any source code
examples?
0
 
Ephraim WangoyaCommented:

Yes,
I use it to format emails. I have the client format text as they wish in a TcxRichEdit control, I then convert the text to HTML and send it as email using Indy.

(I modified the code to work with TcxRichEdit)
0
 
aikimarkCommented:
@Remmie26

Take a look at the Jedi project
http://wiki.delphi-jedi.org/wiki/Category:JvRichEditToHtml.pas

Here's one Delphi code example using the JvRichEditToHtml unit:
http://www.koders.com/delphi/fidE00FC84B2F1F5C5F86D437665D913A505C392A63.aspx

=====
also...

There's rtf2html.pas unit and Delphi code example here:
http://www.koders.com/delphi/fid81F3EC24563C9F190CC898F91D052DE4112546E9.aspx?s=hook
0
 
Remmie26Author Commented:
@aikimark
I will give it a try in the AM and let you know the results.
0
 
Remmie26Author Commented:
@aikimark

It is ok the best so far, still not doing what I need but I have a starting point


Thanks you for your help.
0
 
aikimarkCommented:
@Remmie26

If both rtf2html and the Jedi unit are equal, I recommend using the Jedi unit since ewangoya has experience with it.
0
 
Remmie26Author Commented:
I am using the Jedi
0
 
aikimarkCommented:
what are you...some kind of Sith?!?
0
 
Remmie26Author Commented:
I have the force with me
0
 
aikimarkCommented:
>>...but I have a starting point

Does your closing of this question mean you've moved beyond the starting point and have a working solution?
0
 
Remmie26Author Commented:
not yet still working on modiyfing the JvRichEditToHtml.pas and the JvStrToHtml.pas  to meet the client xml/html hybrid requirement. :(
0
 
Remmie26Author Commented:
aikimark thanks,

I think I can carry on from here it is just a matter of replacing the html tags with the custom tags in these units.
0
 
Remmie26Author Commented:
Hi aikimarc and ewangoya,

I have used the JvRichEditToHtml.pas to convert my RTF to HTML but it does not support numbering it dose support bullet types but not numbering and Ideas?
0
 
aikimarkCommented:
@Remmie26

Now would be a good time to click the ask a related question link and ask for help/advice on numbered list items.
0
 
Remmie26Author Commented:
I am trying to rewrite the JvRichEditToHtml.pas to support numbering
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 15
  • 10
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now