In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.

Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.

RTF 2 HTML

Foro de Xailer profesional en español
Responder
Avatar de Usuario
bingen
Mensajes: 581
Registrado: Lun Jul 07, 2014 8:17 pm
Ubicación: Bilbao
Contactar:

RTF 2 HTML

Mensaje por bingen »

Buenas XTeam. Necesito pasar de RTF a HTML pero para esto hay que tener instalado Office y sus librerías de conversión.

Quisiera hacerlo directamente por que el cliente puede no tener siquiera el Office y para eso habría que fabricar un parser, o alguien lo tiene ya hecho, por favor.

He visto funciones en C para ello e intento implementarlas en Xailer pero con nulo resultado

//------------------------------------------------------------------------------
#pragma BEGINDUMP

#include <windows.h>
#include <xailer.h>

//--------------------------------------------------------------------------

XA_FUNC( XRTFTOHTML )

private static string ConvertRtfToXaml(string rtfText)

{

var richTextBox = new RichTextBox();

if (string.IsNullOrEmpty(rtfText)) return ““;

var textRange = new TextRange(richTextBox.Document.ContentStart, richTextBox.Document.ContentEnd);

using (var rtfMemoryStream = new MemoryStream())

{

using (var rtfStreamWriter = new StreamWriter(rtfMemoryStream))

{

rtfStreamWriter.Write(rtfText);

rtfStreamWriter.Flush();

rtfMemoryStream.Seek(0, SeekOrigin.Begin);

textRange.Load(rtfMemoryStream, DataFormats.Rtf);

}

}

using (var rtfMemoryStream = new MemoryStream())

{

textRange = new TextRange(richTextBox.Document.ContentStart, richTextBox.Document.ContentEnd);

textRange.Save(rtfMemoryStream, DataFormats.Xaml);

rtfMemoryStream.Seek(0, SeekOrigin.Begin);

using (var rtfStreamReader = new StreamReader(rtfMemoryStream))

{

return rtfStreamReader.ReadToEnd();

}

}

}

//--------------------------------------------------------------------------

#pragma ENDDUMP
BiSoft Desarrollo de software profesional
http://www.bisoft.es
Avatar de Usuario
bingen
Mensajes: 581
Registrado: Lun Jul 07, 2014 8:17 pm
Ubicación: Bilbao
Contactar:

Re: RTF 2 HTML (Solucionado)

Mensaje por bingen »

Buenas xTeam.

Ya he conseguido una manera de converir de RTF a HTML con unas DLL gratuitas (2 DLL = 200Kb) con manual, ejemplos, etc. muy bueno.

IRun RTF Converter version 1.18 Pilot Software Ltd.

http://www.pilotltd.com

Y la forma de ejecutarlo desde Xailer:

#pragma BEGINDUMP
#include "Windows.h"
#include "Xailer.h"

typedef int __stdcall (* EXRTF2WEB)
(const char* source,
const char* dest,
int options,
const char* title,
const char* bgcolor,
int dpi);

HB_FUNC( RTF2HTML ) // --> Rtf2Html( cFileRTF, cHTML, nOptions, cBackColor, cTitle, nDPI ) -> nResult OJO nDPI es obligatorio y como mínimo 30 Ejemplo Rtf2Html( "RtfFile.Rtf", "HtmlFile.Html", 7, , , 96 )
{
HINSTANCE inst;
EXRTF2WEB proc;
int ret = 0;

inst=LoadLibrary( (LPCTSTR)"irun.dll");
if(inst)
{
proc=(EXRTF2WEB)GetProcAddress(inst,(LPCTSTR)"EXRTF2WEB");
if(proc)
ret=(*proc)( hb_parc( 1 ), hb_parc( 2 ), hb_parnl( 3 ), hb_parc( 4 ), hb_parc( 5 ), hb_parnl( 6 ) );
FreeLibrary(inst);
}
hb_retnl( ret );
}
BiSoft Desarrollo de software profesional
http://www.bisoft.es
avitalini
Mensajes: 141
Registrado: Mié Ene 07, 2015 6:31 pm

Re: RTF 2 HTML

Mensaje por avitalini »

Excelente aportación Bingen, muchas gracias!
Avatar de Usuario
ignacio
Site Admin
Mensajes: 9447
Registrado: Lun Abr 06, 2015 8:00 pm
Ubicación: Madrid, Spain
Contactar:

Re: RTF 2 HTML

Mensaje por ignacio »

Hola Bingen,

Te animo a que lo subas al área de descargas.

Un saludo
Ignacio Ortiz de Zúñiga
[OZ Software]
https://www.ozs.es
--
[Equipo de Xailer / Xailer team]
https://www.xailer.com
Avatar de Usuario
bingen
Mensajes: 581
Registrado: Lun Jul 07, 2014 8:17 pm
Ubicación: Bilbao
Contactar:

Re: RTF 2 HTML

Mensaje por bingen »

Lo preparo y lo subo encantado, me faltaba probarlo un poco más.
BiSoft Desarrollo de software profesional
http://www.bisoft.es
Avatar de Usuario
bingen
Mensajes: 581
Registrado: Lun Jul 07, 2014 8:17 pm
Ubicación: Bilbao
Contactar:

Re: RTF 2 HTML

Mensaje por bingen »

Ya lo subi el sábado pero no aparece ?¿??¿
BiSoft Desarrollo de software profesional
http://www.bisoft.es
Avatar de Usuario
ignacio
Site Admin
Mensajes: 9447
Registrado: Lun Abr 06, 2015 8:00 pm
Ubicación: Madrid, Spain
Contactar:

Re: RTF 2 HTML

Mensaje por ignacio »

subido. Muchas gracias
Ignacio Ortiz de Zúñiga
[OZ Software]
https://www.ozs.es
--
[Equipo de Xailer / Xailer team]
https://www.xailer.com
Responder