From the course: PHP: Exporting Data to Files

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Extracting the main content file from a .odt document

Extracting the main content file from a .odt document - PHP Tutorial

From the course: PHP: Exporting Data to Files

Start my 1-month free trial

Extracting the main content file from a .odt document

We need a new file for the script that ill extract content.xml and delete the placeholder image, so in your testing site, create a new PHP file, save it in the output folder as odt_extract.php. We need a couple of variables, one for the name of the template, the other for the name that you want to save content.xml as. The first one will be our sourcefile and that's flowers_odtTemplate. And, the other one is for our copy of content.xml, which will be saved as an XSLT file. So, XSLT equals and, we'll call that, flowers_odt.xslt. We know that an open document text file is really a zip file, so we can use the PHP zip class to extract content.xml and delete the placeholder image. And the interesting thing is we don't even need to change the file name extension from odt to zip, PHP will open in automatically. Zip equals new ZipArchive and we need to open it. So zip open file name is sourcefile and then if you know the name of the file that you want to extract, you can use the get from name…

Contents