Serving Word Using HTML XML and CSS to

















- Slides: 17
Serving Word Using HTML, XML, and CSS to Dynamically Generate Word Documents Samuel R. Neff B-Line Express September 18, 2002 Samuel R. Neff
Serving Word Agenda • Automation • Document Properties • HTML, XML, CSS – – – Formatting Labels Columns Headers, Footers Images • Alternatives September 18, 2002 Samuel R. Neff
Serving Word Automation • • Control one application from another Use COM object “Word. Application” Complete flexibility and power Limitations – Unattended execution – Slow – CF COM Support (all versions) September 18, 2002 Samuel R. Neff
Serving Word Document Properties • • Small quantities of data Very fast and easy to use Safe for servers Limitations – CF COM Support (all versions) – Java version incomplete (Apache POI) September 18, 2002 Samuel R. Neff
Serving Word HTML, XML, CSS • Familiar • Fast • Flexible September 18, 2002 Samuel R. Neff
Serving Word Hello Word Standard HTML document <html> <body>Hello! I'm a Word document. </body> </html> Display in MS Word <cfheader name="Content-Type" value="application/msword"> <cfheader name="Content-Disposition" value="attachment; filename=Hello. Word. doc"> Example: helloword. cfm September 18, 2002 Samuel R. Neff
Serving Word Basic Formatting • Sections • Pages • Margins @page Section 1 { size: 8. 5 in 11. 0 in; margin: 1. 0 in 1. 25 in; } div. Section 1 { page: Section 1; } Example: letter 01. cfm September 18, 2002 Samuel R. Neff
Serving Word Paragraph Formatting • Namespaces <html xmlns: o="…"> • Text wrapping <w: Wrap. Text. With. Punct/> • Margins p { margin: 0 pt; } • Orphan control p { mso-pagination: widoworphan; } • White spaces style='mso-spacerun: yes' Example: letter 02. cfm September 18, 2002 Samuel R. Neff
Serving Word Labels • Tables fixed layout mso-table-layout-alt: fixed; • Don't break rows • Specify row height page-break-inside: avoid; height: 1. 0 in; • Fixed width label cells width: 189. 0 pt; • Spacer cells width: 9. 0 pt; • Paragraph margins margin: 0 in 5. 3 pt; Example: labels 01. cfm September 18, 2002 Samuel R. Neff
Serving Word Advanced Labels • Different sizes and layouts – – – Page Margin Row Height Paragraph Margins Number of Columns Spacers • Reuse code – Despite varying content – Cold. Fusion Components • Not all labels can be generated Examples: labels 02. cfm, labels 03. cfm, Word. Label. Generator*. cfc September 18, 2002 Samuel R. Neff
Serving Word Columns • Columns style on page mso-columns: 2 even. 5 in; • Sections to separate columns and standard layout text @page Section 1 {} @page Section 2 {} • Paragraph margins for spacing margin-bottom: 12. 0 pt; • Breaks to divide document sections <br clear="all" style="pagebreak-before: auto; mso-breaktype: section-break"/> • Div tags to identify sections <div class="Section 1"> <div class="Section 2"> Example: columns 01. cfm September 18, 2002 Samuel R. Neff
Serving Word Multi-File Documents • Web Archives (Multipart MIME) MIME-Version: 1. 0 Content-Type: • Header part ignored This is a Multipart MIME. . . • Boundary between parts ------=_edb 95 f 2 d 9 c • Location of each part Content-Location: • Encoding type Content-Transfer-Encoding: • Encoded message parts Message parts • Include a list of files filelist. xml Examples: Multipart. MIME_Example. htm, Multipart. MIME. cfc September 18, 2002 Samuel R. Neff
Serving Word Headers & Footers • File links <link rel="…" href="…"> • Margins mso-header-margin: . 5 in; mso-footer-margin: . 5 in; • URLs mso-header: url("…") h 1; mso-footer: url("…") f 1; • Style attribute mso-element: header • ID id="h 1" Example: columns 02. cfm September 18, 2002 Samuel R. Neff
Serving Word Images • Use standard <img> tag • Include image in the file list • Include image in Multipart MIME message – Component automatically encodes as Base 64 Example: columns 03. cfm September 18, 2002 Samuel R. Neff
Serving Word Resources • Save as Web Page • Microsoft® Office HTML and XML Reference – http: //msdn. microsoft. com/library/default. asp? url=/library/enus/dnoffxml/html/ofxml 2 k. asp • RFCs 2045 and 2046 – http: //www. ietf. org/rfc 2045. txt – http: //www. ietf. org/rfc 2046. txt September 18, 2002 Samuel R. Neff
Serving Word Conclusions • HTML/XML/CSS Faster and more stable than COM • Can be used for most dynamic Word applications • Builds upon existing developers' skill set September 18, 2002 Samuel R. Neff
Serving Word Questions sam@blinex. com September 18, 2002 Samuel R. Neff