Sign in to follow this  
Followers 0
Floppy

Save RTF Text

7 posts in this topic

Hello,

How can I save with AutoIt some RTF text into a file?

Share this post


Link to post
Share on other sites



Do you use a RichEdit UDF? Lokk at mine, there is an example for saving and loading rtf-files


*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

Yes, I do...

In the sample script I don't understand the string:

_GUICtrlRichEdit_AppendText($h_RichEdit, _RTF_GetBMPRTF(_FindFirstBMP()) & @CRLF)

What are: _RTF_GetBMPRTF and _FindFirstBMP? I don't see those commands in pastebin.com/f7f2a956b...

--------------------------------------------------------------------------------------

Then, to save a RTF file I must write:

Case $msg = $bt2
                Local $RTFFile = FileOpen(@DesktopDir & "\AutoIt_testrtf.rtf", 2)
                DllStructSetData($FileStreamStruct, 1, $RTFFile); -> Send handle to CallbackFunc
                Local $send = _GUICtrlRichEdit_StreamOut($h_RichEdit, $SF_RTF, $FileStreamStruct)
                FileClose($RTFFile)
                ConsoleWrite($send & @CRLF)

Right?

---------------------------------------------------------------------------------------

Istead, is there an option to export the RTF text as HTML?

---------------------------------------------------------------------------------------

Sorry for bother and for my bad english...Thanks in advance!

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Your first question:Those functions are declared in the example.

..._FindFisrtBMP gets the first BMP in a folder. default Windows dir

..._RTF_GetBMPRTF creates RTF code for a .bmp-file

-> this line inserts the first found bitmap inzo the RichEdit.

2nd question:

You have to create a stream structure:

Global $FileStreamCallBack = DllCallbackRegister("_EditStreamCallbackFile", "dword", "long_ptr;ptr;long;ptr")
Global $FileStreamStruct = DllStructCreate($tagEDITSTREAM)
DllStructSetData($FileStreamStruct, 3, DllCallbackGetPtr($FileStreamCallBack))

then you need a function to write to the file:

Func _EditStreamCallbackFile($dwCookie, $pbBuff, $cb, $pcb)
    Local $pcb_Struct = DllStructCreate("long", $pcb)
    Local $FileHandle = $dwCookie

    Local $buufs = DllStructCreate("char[" & $cb & "]", $pbBuff)

  ; Write To File smile.gif, could also append to a variable ....
    FileWrite($FileHandle, DllStructGetData($buufs, 1))
    DllStructSetData($pcb_Struct, 1, $cb)
    Return 0
EndFunc ;==>_EditStreamCallbackFile

at last you have to call streamout:

Local $RTFFile = FileOpen(@DesktopDir & "\AutoIt_testrtf.rtf", 2)
                DllStructSetData($FileStreamStruct, 1, $RTFFile); -> Send handle to CallbackFunc
                Local $send = _GUICtrlRichEdit_StreamOut($h_RichEdit, $SF_RTF, $FileStreamStruct)
                FileClose($RTFFile)
                ConsoleWrite($send & @CRLF)
Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

Thanks for explaination...but you didn't reply me to third question...

However...THANK YOU VERY MUCH!!!

Share this post


Link to post
Share on other sites

well, you need an extra dll to convert RTF to html: http://www.autoitscript.com/forum/index.php?showtopic=86530


*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

Yes...I already saw that post...but that script converts only the RTF text to HTML.

I want a COMPLETE HTML converter, wich converts ALL (including images)...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0