View Source

<ac:macro ac:name="note"><ac:parameter ac:name="title">Under Construction</ac:parameter><ac:rich-text-body>
<p>This proposal is under construction and is not ready for review.</p></ac:rich-text-body></ac:macro>

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[{zone-template-instance:ZFDEV:Zend Proposal Zone Template}

{zone-data:component-name}
Zend_Rtf
{zone-data}

{zone-data:proposer-list}
[Andries Seutens|mailto:andries.seutens@skynet.be]
{zone-data}

{zone-data:revision}
0.1 - use-cases
0.2 - module overview
{zone-data}

{zone-data:overview}
Zend_Rtf module functions as a RTF *(Rich Text Format)* manipulation engine. It should be able to load existing documents, create new, modify and save modified documents. Thus it can help any PHP-driven application dynamically prepare documents in RTF by modifying existing template or generating document from a scratch.
{zone-data}

{zone-data:references}
* [Word 2003: Rich Text Format (RTF) Specification, version 1.8|http://www.microsoft.com/downloads/details.aspx?familyid=ac57de32-17f0-4b46-9e4e-467ef9bc5540&displaylang=en]
{zone-data}

{zone-data:requirements}
Zend_Rtf module should/must supports the following features:

* Must be able to create new document
* Must be able to load an existing document and modify items
* Must be able to manipulate pages within document
** add and remove pages
** change the page order
** copy pages
** change the format
* Must support styles and markup to modify the visual look
** alignment
** font
** font families
** font size
** font colors
** italic
** bold
** background color
** margins
** borders
*** border kind
*** border type
*** border width
*** border color
*** border distance from paragraph
** shading
** scale
** emboss
** kerning
** small capital
** engrave
** strike and double strike
** subscript
** superscript
** ...
* Must be able to draw and modify tables (html-like)
* Tables must be able to be formatted as such:
** table
*** borders
** row
*** aligment
*** height
*** left, right margin
** cell
*** left, right, top, bottom margin
*** shading
*** text direction
* Must be able to draw text using built-in fonts or custom TrueType fonts
* Must be able to draw primitives
** lines
** rectangles
** olygons
** circles
** ellipses
** sectors
* Must be able to create document footers and headers
** Footers and headers must be able to turn on/off per page and as a whole
* Must be able to store metadata for the document
* Must support different page orientations
** portrait
** landscape
* Must support different page formats/sizes
** A4
** USLetter
** B11 X 17
** LGL8.5 X 14
** HLT5.5 X 8.5
** EXE7.5 X 10.5
** A3
* Must support custom page formats/sizes
* Must be able to support unicode (help prefered here)
* Must be able to support tabs
* Must be able to support columns
* Must be able to support bullets and numbering
* Must be able to load images (*.bmp, *.jpg, *.gif)

In a later phase, there could be an engine for *PDF to RTF*, and vica versa.
{zone-data}

{zone-data:dependencies}
* Zend_Exception
* ...

{zone-data}

{zone-data:operation}
todo
{zone-data}

{zone-data:milestones}
* Milestone 1: Proposal
* Milestone 2: Proposal accepted
* Milestone 3: Working release
* Milestone 4: Unit tests
* Milestone 5: Documentation
* Milestone 6: Future enhancements
{zone-data}

{zone-data:class-list}
* Zend_Rtf
* Zend_Rtf_Document
* Zend_Rtf_Page
* Zend_Rtf_Exception
* ...
-
* Zend_Rtf_Style
* Zend_Rtf_Style_Abstract
* Zend_Rtf_Style_Paragraph
* Zend_Rtf_Style_Heading
* Zend_Rtf_Style_Table
* ...
-
* Zend_Rtf_Section
* Zend_Rtf_Section_Abstract
* Zend_Rtf_Section_Header
* Zend_Rtf_Section_Footer
* ...
-
* Zend_Rtf_Color
* Zend_Rtf_Color_Abstract
* Zend_Rtf_Color_Html
* Zend_Rtf_Color_Rgb
* ...
{zone-data}

{zone-data:use-cases}

h3. UC-1: creating an RTF document, and setting it's metadata:

{code:php}
$document = new Zend_Rtf_Document();
$document->properties['title'] = 'Title of the document';
$document->properties['subject'] = 'Subject of the document';
$document->properties['author'] = 'Author of the document';
$document->properties['manager'] = 'Manager of the author';
$document->properties['company'] = 'Company of the author';
$document->properties['operator'] = 'Person who last made changes to the document';
$document->properties['category'] = 'Category of the document';
$document->properties['keywords'] = 'Selected keywords for the document';
$document->properties['comment'] = 'Comments; text is ignored';
$document->properties['version'] = 'Version number of the document';
$document->properties['doccomm'] = 'Comments displayed in the Summary Info or Properties dialog box in Word';
$document->properties['hlinkbase'] = 'The base address of all relative hyperlinks inserted in the document.';
$document->properties['creatim'] = '2008-01-01 10:00:00';
$document->properties['printim'] = '2008-01-01 10:00:00';
$document->properties['buptim'] = '2008-01-01 10:00:00';

$metadata = $document->getMetadata();
{code}

h3. UC-2: adding pages:

{code:php}
$document = new Zend_Rtf_Document();
$page = new Zend_Rtf_Page(Zend_Rtf_Page::SIZE_A4);

$document->pages[] = $page;
{code}

h3. UC-3: using styles and adding text:

{code:php}
$document = new Zend_Rtf_Document();
$h1Format = new Zend_Rtf_Style('heading');
$h1Format->setBold(10)
->setSize(16)
->setFont(Zend_Rtf_Font::FONT_HELVETICA);

$h2Format = new Zend_Rtf_Style('heading');
$h2Format->setBold(10)
->setSize(14)
->setColor(new Zend_Rtf_Color_Rgb(125, 120, 115));

$h3Format = new Zend_Rtf_Style('heading');
$h3Format->setBold(10)
->setSize(12)
->setColor(new Zend_Rtf_Color_Html('EFEFEF'));

$paraFormat = new Zend_Rtf_Style('para');
$paraFormat->setSize(10);

$headFootFormat = new Zend_Rtf_Style('para');
$headFootFormat->setItalic();

$page = new Zend_Rtf_Page(Zend_Rtf_Page::SIZE_A4);
$page->setStyle($h1Format);
$page->writeText('This is the h1 section');

$page->setStyle($h2Format);
$page->writeText('This is the h2 section');

$page->setStyle($h3Format);
$page->writeText('This is the h3 section');

$page->setStyle($paraFormat);
$section->writeText('This is the first paragraph');
{code}

h3. UC-4: creating document header and footer:

{code:php}
$document = new Zend_Rtf_Document();
$headFootFormat = new Zend_Rtf_Style('para');
$headFootFormat->setItalic();

$sectionHeader = new Zend_Rtf_Section_Header();
$sectionHeader->setStyle($headFootFormat);
$sectionHeader->writeText('This is the document header');

$sectionFooter = new Zend_Rtf_Section_Footer();
$sectionFooter->setStyle($headFootFormat);
$sectionFooter->writeText('This is the document footer');

$document->setHeader($sectionHeader);
$document->setFooter($sectionFooter);
{code}

h3. UC-5: copying and modifying copied pages:

{code:php}
$document = new Zend_Rtf_Document();
$template = new Zend_Rtf_Page(Zend_Rtf_Page::SIZE_A4);
$template->writeText('i am a template page');

$pageClone = new Zend_Rtf_Page($template);
$pageClone->setPageSize(Zend_Rtf_Page::SIZE_LETTER_LANDSCAPE);
$pageClone->setNoFooter();
{code}
{zone-data}

{zone-data:skeletons}
todo
{zone-data}

{zone-template-instance}]]></ac:plain-text-body></ac:macro>