rtf primer: building and rtf document
TRANSCRIPT
TH Technology
RTF 101
About Me …
Karen Cannell ~ Consultant, TH Technology
Mechanical/SW Engineer - Analyzed, designed,
developed, converted, upgraded, enhanced legacy &
database applications for 25+ years
Building APEX applications for government, medical,
engineering industries since HTMLDB
Leveraging the Oracle 10g,11g,12c suite of tools
Oracle Ace Associate
Editor, Technical Journal
Send ODTUG Technical Journal Content!
TH Technology
RTF 101
APEX Books …
Expert Oracle Application Express, APress
2015 Report Printing
Beginning Application Express
4.2, APress, 2013
Agile Oracle Application Express
APress, 2012
TH Technology
RTF 101
About You …
Why RTF?
Experience?
Applications?
TH Technology
RTF 101
Session Objectives
RTF Overview
RTF Document Structure
RTF How To Build
Applications
TH Technology
RTF 101
Rich Text Format
“…format for text and graphics interchange …
different output devices, operating
environments and operating systems.”
Microsoft Standard
MS Word
TH Technology
RTF 101
Why RTF?
Well Known Format
Plain Text ~ Readily Readable
Sane Formatting
Easy To Generate
TH Technology
RTF 101
Why RTF? (Developer Perspective)
Simplicity
Plain Text
Sane Coding
Easy To Learn
TH Technology
RTF 101
Why? (Me)
Had to Build a Word Document
Unknown # of Pages
Known Format
RTF WAY Easier to Learn and Build
TH Technology
RTF 101
Uses
Document Generation
Report Templates
Merge/Substitutions
…
TH Technology
RTF 101
Example – Swipe Card
TH Technology
RTF 101
Looks Like .. In Plain Text Editor
TH Technology
RTF 101
RTF Example
End / “Footer”
TH Technology
RTF 101
Note: Plain Text Editor
WordPad
Notepad
EditPad Lite
SQL Developer
MS Word Adds Bloat!
TH Technology
RTF 101
MS Word Adds Bloat!
47K to 104K
Demo MS Word Bloat
All That Extra Formatting Not Necessary
Makes Coding / Reading / Using Harder
TH Technology
RTF 101
Create a Clean RTF
Open in MS Word (or Other Editor)
Copy Contents ( CTRL-A, CTRL-C)
Paste into Blank WordPad Document
Save From WordPad.
TH Technology
RTF 101
Structure of an RTF File
The Basics
{ <header> <document> }
TH Technology
RTF 101
RTF Example
Header
TH Technology
RTF 101
RTF Header
{\rtf1\ansi\ansicpg1252
{ … } Open/Close Object
\rtf1 RTF Version 1
\ansi ANSI Character Set (Default)
\ansicpg1252 US Windows Code Page
TH Technology
RTF 101
Header .. Page Size
\paperw4860 \paperh3060 \margt144
\margb144 \margr144 \margl144
\paperwN
\paperhN
\margtN
\margbN
\margrN
\marglN
TH Technology
RTF 101
Twips
“Sizes” in Twips For Most Control Words
Twips == 1440/inch, 20/pt
Inch * 1440 == Twips
TH Technology
RTF 101
Header .. Page Size, Margins
\paperw4860 \paperh3060 \margt144
\margb144 \margr144 \margl144
4860/1440 = 3.375 in
3060/1440 = 2.125 in
0.1 in margins all around
TH Technology
RTF 101
Header … Fonts and Styles
\deff0{\fonttbl{\f0\fnil\fcharset0 Calibri;}{\f1\fnil
Times New Roman;}{\f2\fnil\fcharset0 Mag
Track 1 XPS Card Printer;}}
Default Font is F0
F0 is Calibri
F1 s Times New Roman
F2 is Mag Track 1 XPS Card Printer
Styles
TH Technology
RTF 101
Basic Paragraph
\pard … \par
\pard resets formatting
\fsNN Font Size in Half Points
\fs20 Font Size 10pt
\par ends the \pard
TH Technology
RTF 101
Tables
No Table Group
Paragraphs Properties
“Table” == Series of Table Rows
\trowd … \row
“Row” == Series of Paragraphs
\trowd … \row
TH Technology
RTF 101
Tables … More
\trgaphN Half Space Between Rows in Twips
\trgap0 == No Gap Between Rows
\clvertalc Text Centered Vertically Betw Rows
\cellx1648 Cell Width in Twips
1648/1440 == 1.1
\cellx4602 Cell Width in Twips
4602/1440 == 3.2
TH Technology
RTF 101
Graphics
Embedded
Easiest
Paste in WordPad, Save.
Edit Around As Needed
Referenced/External
TH Technology
RTF 101
Footer
}
Ends the RTF Document
{ … } Groups Must Be Matched
TH Technology
RTF 101
Generating via PL/SQL
One Card First-Only Template
> 1 Card First Template ( No Footer)
Body Template (No Header)
Concatentate In a Loop …
Simple Concatenate: ||
Can’t Do That w MS Word!
TH Technology
RTF 101
Building an RTF (PL/SQL)
PL/SQL to
Open First Template
Loop
Replace
Concatenate Body Template
End
Add Footer
Save As
TH Technology
RTF 101
Alexandria Utilities
FILE_UTIL_PKG.GET_CLOB_FROM_FILE ()
Load RTF Template Into CLOB
STRING_UTIL_PKG.MULTI_REPLACE (…)
Do Substitutions
FILE_UTIL_PKG.SAVE_CLOB_TO_FILE (…)
Save To File
SQL_UTIL_PKG.CLOB_TO_BLOB (…)
IF need a BLOB (DB Storage?)
TH Technology
RTF 101
Good Luck!
TH Technology
RTF 101
Resources
Best Reference: Word 2007 RTF Spec
https://www.microsoft.com/en-
us/download/details.aspx?id=10725
RFT Pocket Guide https://www.safaribooksonline.com/library/view/rtf-pocket-
guide/9781449302047/ch01.html
Alexandria Utilities https://github.com/mortenbra/alexandria-plsql-utils
TH Technology
RTF 101
Share Your Knowledge!
ODTUG Technical Journal
Call for Articles/Reviewers
Editor, ODTUG Technical Journal