2017 © Pedro PelĂĄez
 

library html2opendocument

Converting simple HTML to Opendocument Text (ODT) or Spreadsheets (ODS)

image

catoth/html2opendocument

Converting simple HTML to Opendocument Text (ODT) or Spreadsheets (ODS)

  • Saturday, February 10, 2018
  • by CatoTH
  • Repository
  • 3 Watchers
  • 3 Stars
  • 348 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 12 Versions
  • 13 % Grown

The README.md

This is a simple PHP-library to create OpenDocument Text- and Spreadsheet-files (ODT / ODS) from HTML-formatted text., (*1)

It does not support formulae / calculations in spreadsheets. The focus lies on formatted text., (*2)

Please note that this library is mainly developed for AntragsgrĂŒn. For most other projects trying to write ODT and ODS files, PhpSpreadsheet will probably be the better choice., (*3)

Example Scripts

A demo script for the OpenDocument Text converter using the default template:, (*4)

require_once(__DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php');

$html = '

This is a demo for the converter., (*5)

The converter supports the following styles:, (*6)

  • Lists (UL / OL)
  • STRONG
  • U (underlined)
  • S (strike-through)
  • EM (emphasis / italic)
  • INS (Inserted text)
  • DEL (Deleted text)
  • Line
    breaks with BR
You can also use BLOCKQUOTE, though it lacks specific styling for now
'; $html2 = '

You might be interested
in the fact that this converter
also supports
line numbering
for selected paragraphs, (*7)

Dummy Line
Dummy Line
Dummy Line
Dummy Line
Dummy Line, (*8)

'; $odt = new \CatoTH\HTML2OpenDocument\Text(); $odt->addHtmlTextBlock('

Test Page

'); $odt->addHtmlTextBlock($html, false); $odt->addHtmlTextBlock('

Line Numbering

'); $odt->addHtmlTextBlock($html2, true); $odt->finishAndOutputOdt('demo.odt');

A demo script for the OpenDocument Spreadsheet converter using the default template:, (*9)

use CatoTH\HTML2OpenDocument\Spreadsheet;
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php');

$ods = new \CatoTH\HTML2OpenDocument\Spreadsheet();

// Setting to landscape mode with custom page margins
$ods->setMargins("20mm", "10mm", "10mm", "20mm");
$ods->setPageOrientation("297mm", "210mm", "landscape");

// Plain text
$ods->setCell(0, 0, Spreadsheet::TYPE_TEXT, 'Plain text with native formatting');
$ods->setCellStyle(0, 0, [], ['fo:font-weight' => 'bold']);

// Print a number as an actual number, just a little bit bigger
$ods->setCell(1, 0, Spreadsheet::TYPE_NUMBER, 23);
$ods->setCellStyle(1, 0, [], [
    'fo:font-size'   => '16pt',
    'fo:font-weight' => 'bold',
]);
$ods->setMinRowHeight(1, 1.5);

// Print a number as text
$ods->setCell(2, 0, Spreadsheet::TYPE_TEXT, '42');

// Draw a border around two of the cells
$ods->drawBorder(1, 0, 2, 0, 1);


// Now we use HTML, and we need a bit more space for that
$html = '

The converter supports the following styles:, (*10)

  • STRONG
  • U (underlined)
  • S (strike-through)
  • EM (emphasis / italic)
  • Inserted text
  • Deleted text
  • Line
    breaks with BR
  • Lists (UL / OL) cannot be displayed as lists, but will be flattened to paragraphs
You can also use BLOCKQUOTE, though it lacks specific styling for now
'; $ods->setMinRowHeight(3, 10); $ods->setColumnWidth(1, 20); $ods->setCell(3, 1, Spreadsheet::TYPE_HTML, $html); $ods->finishAndOutputOds('demo.ods');

License

This library is licensed under the MIT license, (*11)

The Versions

10/02 2018

dev-master

9999999-dev

Converting simple HTML to Opendocument Text (ODT) or Spreadsheets (ODS)

  Sources   Download

MIT

The Requires

 

by Tobias HĂ¶ĂŸl

html ods odt opendocument

10/02 2018

0.11

0.11.0.0

Converting simple HTML to Opendocument Text (ODT) or Spreadsheets (ODS)

  Sources   Download

MIT

The Requires

 

by Tobias HĂ¶ĂŸl

html ods odt opendocument

28/09 2017

0.10

0.10.0.0

Converting simple HTML to Opendocument Text (ODT) or Spreadsheets (ODS)

  Sources   Download

MIT

The Requires

 

by Tobias HĂ¶ĂŸl

html ods odt opendocument

20/06 2017

0.9

0.9.0.0

Converting simple HTML to Opendocument Text (ODT) or Spreadsheets (ODS)

  Sources   Download

MIT

The Requires

 

by Tobias HĂ¶ĂŸl

html ods odt opendocument

26/02 2017

0.8

0.8.0.0

Converting simple HTML to Opendocument Text (ODT) or Spreadsheets (ODS)

  Sources   Download

MIT

The Requires

 

by Tobias HĂ¶ĂŸl

html ods odt opendocument

25/02 2017

0.7

0.7.0.0

Converting simple HTML to Opendocument Text (ODT) or Spreadsheets (ODS)

  Sources   Download

MIT

The Requires

 

by Tobias HĂ¶ĂŸl

html ods odt opendocument

20/09 2016

0.6

0.6.0.0

Converting simple HTML to Opendocument Text (ODT) or Spreadsheets (ODS)

  Sources   Download

MIT

The Requires

 

by Tobias HĂ¶ĂŸl

html ods odt opendocument

05/05 2016

0.5

0.5.0.0

Converting simple HTML to Opendocument Text (ODT) or Spreadsheets (ODS)

  Sources   Download

MIT

The Requires

 

by Tobias HĂ¶ĂŸl

html ods odt opendocument

02/04 2016

0.4

0.4.0.0

Converting simple HTML to Opendocument Text (ODT) or Spreadsheets (ODS)

  Sources   Download

MIT

The Requires

 

by Tobias HĂ¶ĂŸl

html ods odt opendocument

07/03 2016

0.3

0.3.0.0

Converting simple HTML to Opendocument Text (ODT) or Spreadsheets (ODS)

  Sources   Download

MIT

The Requires

 

by Tobias HĂ¶ĂŸl

html ods odt opendocument

31/01 2016

0.2

0.2.0.0

Converting simple HTML to Opendocument Text (ODT) or Spreadsheets (ODS)

  Sources   Download

MIT

The Requires

 

by Tobias HĂ¶ĂŸl

html ods odt opendocument

30/01 2016

0.1

0.1.0.0

Converting simple HTML to Opendocument Text (ODT) or Spreadsheets (ODS)

  Sources   Download

MIT

The Requires

 

by Tobias HĂ¶ĂŸl

html ods odt opendocument