Jump to content

Direct RTF writer


Lazycat
 Share

Recommended Posts

UDF allow to create empty RTF document, apply formatting to given text and appent to previously created document. For text allow describing font, size, color and style. Note that UDF at very early stage, so working only with the self-created documents is allowed (no general parser for now). Parameters for functions are described in the UDF, example included.

Comments/ideas are welcome.

http://www.autoitscript.com/fileman/users/public/Lazycat/rtf_writer.zip

Link to comment
Share on other sites

@josbe:

What did you have in mind?

<{POST_SNAPBACK}>

Would be many things...as such, generate a RTF file from a simple Edit, adding tags.

Or a converter/parser from a HTML text to RTF file. Yes, I know that already we can find tools like this(web), but I like the idea of handle with AutoIT only. :idiot:

Link to comment
Share on other sites

UDF allow to create empty RTF document, apply formatting to given text and appent to previously created document. For text allow describing font, size, color and style. Note that UDF at very early stage, so working only with the self-created documents is allowed (no general parser for now). Parameters for functions are described in the UDF, example included.

Comments/ideas are welcome.

http://www.autoitscript.com/fileman/users/public/Lazycat/rtf_writer.zip

<{POST_SNAPBACK}>

hello :idiot: very Nice SlimShady i like it !Great job)
Link to comment
Share on other sites

Very Cool, Lazycat :D

.. and very nicely written too! I'd say this is a good example of good coding practice for AU3 scripters: Jon is asking for examples to include with the next release - this seems perfect. (Illustrates use of UDFs, bitwise operators, hungarian notation, colour control, even proper indentation)

:idiot:

Link to comment
Share on other sites

I think you're being too modest :lol: ...

I want some nice examples for the release.  Mainly for GUI stuff but anything is fine.

[..]

I wouldn't want to try and code a GUI script without seeing something first.

<{POST_SNAPBACK}>

:idiot: His comments about GUI stuff apply also to those people who are new to AU3 in general.

But whether or bnot you submit it to him is up to you - I just think it's an excellent exponent of the language.

:D

Link to comment
Share on other sites

Wicked. Opens the door for building scripts with nicely formatted reports or so many other things.

Very nice.

Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines.

Link to comment
Share on other sites

  • 5 months later...

I have small questions about this splendid script :

1 - Why not to use :

"{\rtf1\ansi\ansicpg1252\deff0\deflang2060{\fonttbl{\f0\fswiss\fcharset0 " & $sDefaultFont & ";}{\f1\fswiss\fprq2\fcharset0 " & $sDefaultFont & ";}{\f2\fnil\fcharset2 Symbol;}}"

in place of :

Local $sDoc = "{\rtf1\ansi\deff0"
    $sDoc = $sDoc & "{\fonttbl{\f0\fnil " & $sDefFont & ";}{\fontplaceholder}}"
    $sDoc = $sDoc & "{\colortbl \red0\green0\blue0;{\colorplaceholder}}"
    $sDoc = $sDoc & "{\placeholder}}"
:evil:

2 - Second is in connection with the colors :

Why not add the definition of the colors in de header of the RTF File

$sDoc = $sDoc & "{\colortbl;\red0\green0\blue0;\red255\green255\blue0;\red0\green0\blue255;" & _
                    "\red255\green0\blue0;\red0\green255\blue0;\red128\green0\blue128;" & _
                    "\red128\green0\blue0;\red0\green128\blue0;\red128\green128\blue0;" & _
                    "\red0\green0\blue128;\red0\green128\blue128;\red128\green128\blue128;" & _
                    "\red192\green192\blue192;\red255\green0\blue255;\red0\green255\blue255;" & _
                    "\red255\green255\blue255;}"

to be able to determine constants of colors (in variable ??) :

\viewkind4\uc1\pard\cf1\f0\fs20 noir\cf0\par
\cf2 jaune\par
\cf3 bleu\par
\cf4 rouge\par
\cf5 vert\par
\cf6 violet\par
\cf7 rouge fonce\par
\cf8 vert fonce\par
\cf9 marron clair\par
\cf10 bleu fonce\par
\cf6 violet\par
\cf11 bleu vert\par
\cf12 gris\par
\cf13 argente\par
\cf14 fuschia\cf6\par
\cf15 vert d'eau\cf6\par
\cf16 blanc\par
\cf0 automatique\par

:D

With this diagram it would be easy to be able to add the tags according to:

\strike barre\strike0\par
\pard{\pntext\f2\'B7\tab}{\*\pn\pnlvlblt\pnf2\pnindent0{\pntxtb\'B7}}\fi-720\li720 puce\par
\pard\qc\cf0\f0 centre\par
\pard\qr droite\par

identical to the HTML !?:)

This is only one fast idea... Considering script is in v0.1 (Initial), we could make it evolve.:mad:

Thank you for your opinions... :D

----------------------GroumphyMore information about me [Fr]

Link to comment
Share on other sites

I have small questions about this splendid script :

1 - Why not to use :

"{\rtf1\ansi\ansicpg1252\deff0\deflang2060{\fonttbl{\f0\fswiss\fcharset0 " & $sDefaultFont & ";}{\f1\fswiss\fprq2\fcharset0 " & $sDefaultFont & ";}{\f2\fnil\fcharset2 Symbol;}}"

in place of :

Indeed, this can be done in this way. Or by using StringFormat, that I very like personally. But this record was made for readability, because you can see each block separately.

2 - Second is in connection with the colors :

Why not add the definition of the colors in de header of the RTF File

...

to be able to determine constants of colors (in variable ??) :

You can, but what the reason? If you add color, that already in the table, it's index will be used anyway, if other - it will be added to table.

With this diagram it would be easy to be able to add the tags according to:

\strike barre\strike0\par
\pard{\pntext\f2\'B7\tab}{\*\pn\pnlvlblt\pnf2\pnindent0{\pntxtb\'B7}}\fi-720\li720 puce\par
\pard\qc\cf0\f0 centre\par
\pard\qr droite\par

identical to the HTML !?:)

Not sure I understand. You mean paragraph formatting, tables etc.? If so, this was in todo...

This is only one fast idea... Considering script is in v0.1 (Initial), we could make it evolve.:evil:

This script in it's current state have couple flaws: it will work only with the data created itself, and idea of parsing fonts and colors table each time you add string is not so good. So I planned change whole script behaviour and maybe try to add general parser. But this is not on the top of my plans atm :D
Link to comment
Share on other sites

Indeed, this can be done in this way. Or by using StringFormat, that I very like personally. But this record was made for readability, because you can see each block separately.

You can, but what the reason? If you add color, that already in the table, it's index will be used anyway, if other - it will be added to table.

Not sure I understand. You mean paragraph formatting, tables etc.? If so, this was in todo...

This script in it's current state have couple flaws: it will work only with the data created itself, and idea of parsing fonts and colors table each time you add string is not so good. So I planned change whole script behaviour and maybe try to add general parser. But this is not on the top of my plans atm :)

<{POST_SNAPBACK}>

;@Lazycat or somebody.

Can u make this script available again, it is no longer in the filearea. You posted this well before i found out about AutoIt.

Thanks

EDIT

I got it from your web page....thanx

HardCopy

Edited by HardCopy

Contributions: UDF _DateYearFirstChildren are like Farts, you can just about stand your own.Why am I not a Vegetarian?...Well...my ancestors didn't fight & evolve to the Top of the food chain for me to survive on Salad

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...