Well OK, there usually are images in pptx files, but unless they are required, you don't need them. If they are required, they can be found in the archive and put into a .pdf file. The tricky part would be in determining where in the pdf file they should go. That information is probably available (hopefully in the slides, but might be elsewhere in the pptx archive), how else would the pptx file know where to put the images?
Anyways, I have worked something out for a text only pdf from the slides of a pptx file using the fpdf library:
PHP Code:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
// open file
$file_path = 'Reports/report.pptx';
//$target_folder_path = 'Reports';
$zip = new ZipArchive;
$res = $zip->open($file_path);
if ($res === TRUE) {
// $zip->extractTo($target_folder_path);
require('../../../fpdf181/fpdf.php'); //path to fpdf.php on your server
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',10);
$headings = Array();
// loop through all slide#.xml files
$slide = 1;
while ( ($index = $zip -> locateName("ppt/slides/slide" . $slide . ".xml")) !== false ){
$pdf->Cell(40,7,"Report #$slide:",0,1);
$data = $zip -> getFromIndex($index);
$p = xml_parser_create();
xml_parse_into_struct($p, $data, $vals);
xml_parser_free($p);
$str = '';
foreach($vals as $val){
if(isset($val['value'])){
$str .= chop($val['value']) . " ";
}
}
if(strlen($str)){
$parts = explode(" ", $str);
$tmpstr = "";
foreach($parts as $part){
$apart = chop($part)? chop($part) . " " : "";
$tmpstr .= $apart;
if(strlen($tmpstr) < 113){
$pstr = $tmpstr;
} else {
$pdf->Cell(0,4,$pstr,0,1);
$tmpstr = $apart;
}
}
if(strlen($tmpstr)){
$pdf->Cell(0,4,$tmpstr,0,1);
}
$pdf->Cell(0,3,'',0,1);
}
$slide++;
}
$zip->close();
$pdf->Output();
} else {
echo 'failed';
}
?>
Use fpdf from: http://www.fpdf.org/en/download.php (version 1.81)
Bookmarks