Wow, it's been 15 yers since I worked with this, so...
The way I learned was by opening wordpad, typing out something simple, like "Hello world." saving the doc, and then opening that doc in Notepad. Notepad shows the .rtf formatting charters, along with the "Hello World text. Something like this, for two centered hello world sentences, in two different size Lucinda Console fonts...
{\rtf1\ansi\deff0{\fonttbl{\f0\fmodern\fprq1\fcharset0 Lucida Console;}}
{\colortbl ;\red0\green0\blue0;}
\viewkind4\uc1\pard\cf1\lang1033\f0\fs24
\par
\pard\qc\
fs24Hello World Big!\par
\par
\fs1\par
\fs16Hello World smaller.\par
}
So to get that at into a QB64 print routine program, you need to first make a header database...
{\rtf1\ansi\deff0{\fonttbl{\f0\fmodern\fprq1\fcharset0 Lucida Console;}}
{\colortbl ;\red0\green0\blue0;}
\viewkind4\uc1\pard\cf1\lang1033\f0\fs24
\par
[/html]
So let's say I save that as: [b]my_rtf_header.dat[/b]
Now let's look at the code that centers the characters on the page, \pard\qc
The code that changes font-size is \fs24 (for 24pt font size, and \fs16 (for font-size 16pt.)
To change the font size, the code is \fs1\par is used to indicate a size change is coming.
so I can assign these actions to QB64 variables like...
[code=qb64]rtf_center_text$ = "\pard\qc\par" ' Center text.
rtf_font_change$ = "\fs1\par" ' Change font size.
rtf_24pt$ = "\fs24" ' Font size 24.
rtf_16pt$ = "\fs16" ' Font size 16.
rtf_eol$ = "\par" ' End of line or paragraph
Now to put it altogether, it would look something like this...
' CAUTION: This routine will overwrite files named as...
' $my_exp~word~pad.rtf
' $my_doc_to_print_in_wordpad.txt
' DO NOT RUN THIS ROUTINE IF ANY R YOUR FILES HAVE EITHER OF THESE NAMES IN YOUR DIRECTORY.
' Variables needed.
rtf_center_text$ = "\pard\qc\par" ' Center text
rtf_font_change$ = "\fs1\par" ' Change font size.
rtf_24pt$ = "\fs24" ' Font size 24.
rtf_16pt$ = "\fs16" ' Font size 16.
rtf_eol$ = "\par" ' End of line or paragraph
' First put what you want printed in a text file...
PRINT #1, "Hello World Smaller." '----------------------------------------------------
' Now add the .rtf formatting...
OPEN "my_rtf_header.dat" FOR INPUT AS #1 ' Remember you need to create this file first, by saving the example in this post. OPEN "$my_doc_to_print_in_wordpad.txt" FOR INPUT AS #2 ' Can be renamed to whatever you want.
mydoc$ = "$my_exp~word~pad.rtf" ' I assigned a variable here, because this same file will be used again in the SHELL printing statement.
OPEN mydoc$
FOR OUTPUT AS #3 ' Crazy name just to avoid someone overwriting an existing file. Rename this to whatever you want.
DO UNTIL EOF(1) ' Adds the .rtf header to the doc.
PRINT #3, rtf_center_text$
' Tell Wordpad to center the text.
text_line = 0
DO UNTIL EOF(2) ' This is your saved doc unformatted text file. text_line = text_line + 1
CASE 1 ' Line 1 we want printed in 24pt. PRINT #3, text$
+ rtf_eol$
CASE 3 ' Line 2 we want printed in 16pt. PRINT #3, rtf_font_change$;
PRINT #3, text$
+ rtf_eol$
PRINT #3, text$
+ rtf_eol$
' Now , print the file using wordpad minimized to the task bar.
Worked as coded on my Windows 10, using QB64 v1.3. All other Qb64 versions should work as well.
Some technical stuff I don't know is the font measurements. They don't match the font selection in the Wordpad app. In other words, font-size 24, set in the code, will appear as a smaller font-size in the drop down font selection box. So it's some relative measurement like pt to em, etc. I don't really care to know why the difference, and if I was making an app with this, today, I'd either look it up or just play with some sizes until I could get a feel for it.
So fun stuff. Look some stuff p on line about .rtf code / formatting, or just play around with it like I did, and you should be able to add margins, colors, underlined text, bold text, etc. to your printing. Anyway, I hope the examples are not too confusing. Oh, and can you have a spaces between those code switches like...
\fs16\par
written as:
\fs16 \par
YES! It allows a space, or no space. Either is fine.
Pete