Skip to content

Commit

Permalink
Convert samples
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanlanin committed Mar 15, 2014
1 parent f4d7fa4 commit 59eec58
Show file tree
Hide file tree
Showing 26 changed files with 190 additions and 144 deletions.
9 changes: 2 additions & 7 deletions samples/Sample_01_SimpleText.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<?php
// Init
error_reporting(E_ALL);
define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
require_once '../Classes/PHPWord.php';
include_once 'Sample_Header.php';

// New Word Document
echo date('H:i:s') , " Create new PHPWord object" , EOL;
Expand Down Expand Up @@ -57,6 +54,4 @@
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}

// Done
echo date('H:i:s'), " Done writing file(s)", EOL;
echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL;
include_once 'Sample_Footer.php';
9 changes: 2 additions & 7 deletions samples/Sample_02_TabStops.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<?php
// Init
error_reporting(E_ALL);
define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
require_once '../Classes/PHPWord.php';
include_once 'Sample_Header.php';

// New Word Document
echo date('H:i:s') , ' Create new PHPWord object' , EOL;
Expand Down Expand Up @@ -45,6 +42,4 @@
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}

// Done
echo date('H:i:s'), " Done writing file(s)", EOL;
echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL;
include_once 'Sample_Footer.php';
9 changes: 2 additions & 7 deletions samples/Sample_03_Sections.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<?php
// Init
error_reporting(E_ALL);
define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
require_once '../Classes/PHPWord.php';
include_once 'Sample_Header.php';

// New Word Document
echo date('H:i:s') , ' Create new PHPWord object' , EOL;
Expand Down Expand Up @@ -38,6 +35,4 @@
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}

// Done
echo date('H:i:s'), " Done writing file(s)", EOL;
echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL;
include_once 'Sample_Footer.php';
9 changes: 2 additions & 7 deletions samples/Sample_04_Textrun.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<?php
// Init
error_reporting(E_ALL);
define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
require_once '../Classes/PHPWord.php';
include_once 'Sample_Header.php';

// New Word Document
echo date('H:i:s') , ' Create new PHPWord object' , EOL;
Expand Down Expand Up @@ -45,6 +42,4 @@
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}

// Done
echo date('H:i:s'), " Done writing file(s)", EOL;
echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL;
include_once 'Sample_Footer.php';
9 changes: 2 additions & 7 deletions samples/Sample_05_Multicolumn.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<?php
// Init
error_reporting(E_ALL);
define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
require_once '../Classes/PHPWord.php';
include_once 'Sample_Header.php';

// New Word Document
echo date('H:i:s') , " Create new PHPWord object" , EOL;
Expand Down Expand Up @@ -48,6 +45,4 @@
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}

// Done
echo date('H:i:s'), " Done writing file(s)", EOL;
echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL;
include_once 'Sample_Footer.php';
9 changes: 2 additions & 7 deletions samples/Sample_06_Footnote.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<?php
// Init
error_reporting(E_ALL);
define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
require_once '../Classes/PHPWord.php';
include_once 'Sample_Header.php';

// New Word Document
echo date('H:i:s') , " Create new PHPWord object" , EOL;
Expand Down Expand Up @@ -46,6 +43,4 @@
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}

// Done
echo date('H:i:s'), " Done writing file(s)", EOL;
echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL;
include_once 'Sample_Footer.php';
11 changes: 3 additions & 8 deletions samples/Sample_07_TemplateCloneRow.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<?php
// Init
error_reporting(E_ALL);
define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
require_once '../Classes/PHPWord.php';
include_once 'Sample_Header.php';

// New Word document
echo date('H:i:s') , " Create new PHPWord object" , EOL;
Expand Down Expand Up @@ -56,11 +53,9 @@
$document->setValue('userName#3', 'Ray');
$document->setValue('userPhone#3', '+1 428 889 775');

$name = 'Sample_07_TemplateCloneRow_result.docx';
$name = 'Sample_07_TemplateCloneRow.docx';
echo date('H:i:s'), " Write to Word2007 format", EOL;
$document->saveAs($name);
rename($name, "results/{$name}");

// Done
echo date('H:i:s'), " Done writing file(s)", EOL;
echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL;
include_once 'Sample_Footer.php';
9 changes: 2 additions & 7 deletions samples/Sample_08_ParagraphPagination.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<?php
// Init
error_reporting(E_ALL);
define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
require_once '../Classes/PHPWord.php';
include_once 'Sample_Header.php';

// New Word document
echo date('H:i:s') , " Create new PHPWord object" , EOL;
Expand Down Expand Up @@ -58,6 +55,4 @@
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}

// Done
echo date('H:i:s'), " Done writing file(s)", EOL;
echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL;
include_once 'Sample_Footer.php';
9 changes: 2 additions & 7 deletions samples/Sample_09_Tables.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<?php
// Init
error_reporting(E_ALL);
define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
require_once '../Classes/PHPWord.php';
include_once 'Sample_Header.php';

// New Word Document
echo date('H:i:s') , ' Create new PHPWord object' , EOL;
Expand Down Expand Up @@ -86,6 +83,4 @@
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}

// Done
echo date('H:i:s'), " Done writing file(s)", EOL;
echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL;
include_once 'Sample_Footer.php';
9 changes: 2 additions & 7 deletions samples/Sample_10_EastAsianFontStyle.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<?php
// Init
error_reporting(E_ALL);
define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
require_once '../Classes/PHPWord.php';
include_once 'Sample_Header.php';

// New Word Document
echo date('H:i:s') , ' Create new PHPWord object' , EOL;
Expand All @@ -22,6 +19,4 @@
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}

// Done
echo date('H:i:s'), " Done writing file(s)", EOL;
echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL;
include_once 'Sample_Footer.php';
9 changes: 2 additions & 7 deletions samples/Sample_11_ReadWord2007.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<?php
// Init
error_reporting(E_ALL);
define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
require_once '../Classes/PHPWord.php';
include_once 'Sample_Header.php';

// Read contents
$name = basename(__FILE__, '.php');
Expand All @@ -19,6 +16,4 @@
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}

// Done
echo date('H:i:s'), " Done writing file(s)", EOL;
echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL;
include_once 'Sample_Footer.php';
9 changes: 2 additions & 7 deletions samples/Sample_12_HeaderFooter.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<?php
// Init
error_reporting(E_ALL);
define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
require_once '../Classes/PHPWord.php';
include_once 'Sample_Header.php';

// New Word document
echo date('H:i:s') , " Create new PHPWord object" , EOL;
Expand Down Expand Up @@ -69,6 +66,4 @@
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}

// Done
echo date('H:i:s'), " Done writing file(s)", EOL;
echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL;
include_once 'Sample_Footer.php';
10 changes: 2 additions & 8 deletions samples/Sample_13_Images.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
/**
* Image creation
*/

// Init
error_reporting(E_ALL);
define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
require_once '../Classes/PHPWord.php';
include_once 'Sample_Header.php';

// New Word document
echo date('H:i:s'), " Create new PHPWord object", EOL;
Expand Down Expand Up @@ -37,6 +33,4 @@
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}

// Done
echo date('H:i:s'), " Done writing file(s)", EOL;
echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL;
include_once 'Sample_Footer.php';
10 changes: 2 additions & 8 deletions samples/Sample_14_ListItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
/**
* List item sample
*/

// Init
error_reporting(E_ALL);
define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
require_once '../Classes/PHPWord.php';
include_once 'Sample_Header.php';

// New Word document
echo date('H:i:s'), " Create new PHPWord object", EOL;
Expand Down Expand Up @@ -61,6 +57,4 @@
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}

// Done
echo date('H:i:s'), " Done writing file(s)", EOL;
echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL;
include_once 'Sample_Footer.php';
10 changes: 2 additions & 8 deletions samples/Sample_15_Link.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
/**
* Link sample
*/

// Init
error_reporting(E_ALL);
define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
require_once '../Classes/PHPWord.php';
include_once 'Sample_Header.php';

// New Word document
echo date('H:i:s'), " Create new PHPWord object", EOL;
Expand Down Expand Up @@ -35,6 +31,4 @@
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}

// Done
echo date('H:i:s'), " Done writing file(s)", EOL;
echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL;
include_once 'Sample_Footer.php';
10 changes: 2 additions & 8 deletions samples/Sample_16_Object.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
/**
* Object sample
*/

// Init
error_reporting(E_ALL);
define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
require_once '../Classes/PHPWord.php';
include_once 'Sample_Header.php';

// New Word document
echo date('H:i:s'), " Create new PHPWord object", EOL;
Expand All @@ -30,6 +26,4 @@
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}

// Done
echo date('H:i:s'), " Done writing file(s)", EOL;
echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL;
include_once 'Sample_Footer.php';
12 changes: 3 additions & 9 deletions samples/Sample_17_TitleTOC.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
<?php
/**
* Generic template for creating PHPWord samples
* Titles and TOC
*/

// Init
error_reporting(E_ALL);
define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
require_once '../Classes/PHPWord.php';
include_once 'Sample_Header.php';

// New Word document
echo date('H:i:s'), " Create new PHPWord object", EOL;
Expand Down Expand Up @@ -62,6 +58,4 @@
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}

// Done
echo date('H:i:s'), " Done writing file(s)", EOL;
echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL;
include_once 'Sample_Footer.php';
12 changes: 3 additions & 9 deletions samples/Sample_18_Watermark.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
<?php
/**
* Generic template for creating PHPWord samples
* Watermark
*/

// Init
error_reporting(E_ALL);
define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
require_once '../Classes/PHPWord.php';
include_once 'Sample_Header.php';

// New Word document
echo date('H:i:s'), " Create new PHPWord object", EOL;
Expand All @@ -31,6 +27,4 @@
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}

// Done
echo date('H:i:s'), " Done writing file(s)", EOL;
echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL;
include_once 'Sample_Footer.php';
12 changes: 3 additions & 9 deletions samples/Sample_19_TextBreak.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
<?php
/**
* Generic template for creating PHPWord samples
* Text break
*/

// Init
error_reporting(E_ALL);
define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
require_once '../Classes/PHPWord.php';
include_once 'Sample_Header.php';

// New Word document
echo date('H:i:s'), " Create new PHPWord object", EOL;
Expand Down Expand Up @@ -44,6 +40,4 @@
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}

// Done
echo date('H:i:s'), " Done writing file(s)", EOL;
echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL;
include_once 'Sample_Footer.php';
Loading

0 comments on commit 59eec58

Please sign in to comment.