Location: PHPKode > scripts > WPhp > wphp/wphp-demo.php
<?php
/*
$Id: wphp-demo.php,v 1.3 2005/04/22 12:06:55 josheli Exp $

-Demo file using WPhp to dynamically generate a WordPerfect document from a webserver without WordPerfect installed
-Of course you need WordPerfect on the client machine
*/

include 'WPhpDocument.php';

$wpd_filename = 'wphp-demo.wpd';

$post = array_map('trim', array_map('stripslashes', $_POST));

$wp =& new WPhpDocument($wpd_filename);


if($post['cover_page'])
{
  $wp->centerPageVertically();
  $wp->setPageJustification(CENTER_JUSTIFY_PAGE);
  $wp->writeText("WPhp Demo\n", WP_ATTRIBUTE_HEADING);
  $wp->writeText("by josheli\n", WP_ATTRIBUTE_BOLD);
  $wp->insertPageBreak();
  //reset the justification
  $wp->setPageJustification(LEFT_JUSTIFY_PAGE);
}

if(!empty($post['chapter_heading']))
{
  $wp->writeText("Chapter Heading:", WP_ATTRIBUTE_UNDERLINE);
  $wp->writeText("\n");

  $wp->writeText($post['chapter_heading']."\n", WP_ATTRIBUTE_CHAPTER_HEADING);
  $wp->writeText("\n");
}

if(!empty($post['regular_heading']))
{
  $wp->writeText("Regular Heading:", WP_ATTRIBUTE_UNDERLINE);
  $wp->writeText("\n");

  $wp->writeText($post['regular_heading']."\n", WP_ATTRIBUTE_HEADING);
  $wp->writeText("\n");
}

if(!empty($post['sub_heading']))
{
  $wp->writeText("Sub Heading:", WP_ATTRIBUTE_UNDERLINE);
  $wp->writeText("\n");

  $wp->writeText($post['sub_heading']."\n", WP_ATTRIBUTE_SUB_HEADING);
  $wp->writeText("\n");
}

if(!empty($post['regular_text']))
{
  $wp->writeText("Regular Text:", WP_ATTRIBUTE_UNDERLINE);
  $wp->writeText("\n");
  $wp->writeText($post['regular_text']."\n");
  $wp->writeText("\n");
}

if(!empty($post['small_caps']))
{
  $wp->writeText("Small Caps:", WP_ATTRIBUTE_UNDERLINE);
  $wp->writeText("\n");

  $wp->writeText($post['small_caps']."\n", WP_ATTRIBUTE_SMALL_CAPS);
  $wp->writeText("\n");
}

if(!empty($post['small_print']))
{
  $wp->writeText("Small Print:", WP_ATTRIBUTE_UNDERLINE);
  $wp->writeText("\n");

  $wp->writeText($post['small_print']."\n", WP_ATTRIBUTE_SMALL_PRINT);
  $wp->writeText("\n");
}

if(!empty($post['fine_print']))
{
  $wp->writeText("Fine Print:", WP_ATTRIBUTE_UNDERLINE);
  $wp->writeText("\n");

  $wp->writeText($post['fine_print']."\n", WP_ATTRIBUTE_FINE_PRINT);
  $wp->writeText("\n");
}

if(!empty($post['bold_text']))
{
  $wp->writeText("Bold Text:", WP_ATTRIBUTE_UNDERLINE);
  $wp->writeText("\n");

  $wp->writeText($post['bold_text']."\n", WP_ATTRIBUTE_BOLD);
  $wp->writeText("\n");
}

if(!empty($post['italic_text']))
{
  $wp->writeText("Italic Text:", WP_ATTRIBUTE_UNDERLINE);
  $wp->writeText("\n");

  $wp->writeText($post['italic_text']."\n", WP_ATTRIBUTE_ITALICS);
  $wp->writeText("\n");
}

if(!empty($post['biru_text']))
{
  $wp->writeText("Multi-styled Text:", WP_ATTRIBUTE_UNDERLINE);
  $wp->writeText("\n");

  $wp->startRedline();
  $wp->startBold();
  $wp->startItalics();
  $wp->startUnderline();
  $wp->writeText($post['biru_text']);
  $wp->endUnderline();
  $wp->endItalics();
  $wp->endBold();
  $wp->endRedline();
  $wp->writeText("\n");
  $wp->writeText("\n");
}

if(!empty($post['dubun_text']))
{
  $wp->writeText("Double-Underlined Text:", WP_ATTRIBUTE_UNDERLINE);
  $wp->writeText("\n");

  $wp->startDoubleUnderline();
  $wp->writeText($post['dubun_text']);
  $wp->endDoubleUnderline();
  $wp->writeText("\n");
  $wp->writeText("\n");
}

if(!empty($post['shadow_text']))
{
  $wp->writeText("Shadowed Text:", WP_ATTRIBUTE_UNDERLINE);
  $wp->writeText("\n");

  $wp->startShadow();
  $wp->writeText($post['shadow_text']);
  $wp->endShadow();
  $wp->writeText("\n");
  $wp->writeText("\n");
}

if(!empty($post['strike_text']))
{
  $wp->writeText("Strikethrough:", WP_ATTRIBUTE_UNDERLINE);
  $wp->writeText("\n");

  $wp->startStrikeout();
  $wp->writeText($post['strike_text']);
  $wp->endStrikeout();
  $wp->writeText("\n");
  $wp->writeText("\n");
}

if(!empty($post['sup_text']))
{
  $wp->writeText("Superscript:", WP_ATTRIBUTE_UNDERLINE);
  $wp->writeText("\n");

  $wp->writeText($post['sup_text']);
  $wp->startSuperscript();
  $wp->writeText("(1)");
  $wp->endSuperscript();
  $wp->writeText("\n");
  $wp->writeText("\n");
}

if(!empty($post['sub_text']))
{
  $wp->writeText("Subscript:", WP_ATTRIBUTE_UNDERLINE);
  $wp->writeText("\n");

  $wp->writeText($post['sub_text']);
  $wp->startSubscript();
  $wp->writeText("(2)");
  $wp->endSubscript();
  $wp->writeText("\n");
  $wp->writeText("\n");
}

$wp->promptDownload();

?>
Return current item: WPhp