We know that the proper use of PHP language can help us to realize the function of exporting Word documents. Today we will introduce how PHP handles word-to-pdf implementation.
- The PHP keyword this points to the current object pointer
- The PHP self keyword points to a class static variable
- The parent class constructor is called by PHP parent
- Use Phpexcel Essentials to resolve
- Quickly understand how PHP exports Word documents
Example of PHP handling Word to PDF code:
- < php
- Set_time_limit (0);
- function Makepropertyvalue ($name, $value, $OSM) {
- $ostruct = $osm->bridge_getstruct
("Com.sun.star.beans.PropertyValue");
- $oStruct->Name = $name;
- $oStruct->Value = $value;
- return $oStruct;
- }
- function Word2pdf ($doc _url, $output _url) {
- $OSM = new COM ("Com.sun.star.ServiceManager")
Or Die ("sure is a OpenOffice.org
is installed.\n ");
- $args = array(Makepropertyvalue ("Hidden", True, $OSM));
- $odesktop = $osm->createinstance ("Com.sun.star
. Frame. Desktop ");
- $Owriterdoc = $oDesktop->loadcomponentfromurl
($doc _url, "_blank", 0, $args);
- $Export_args = array(makepropertyvalue
("FilterName", "Writer_pdf_export", $OSM));
- $oWriterDoc->storetourl ($output _url, $export _args);
- $oWriterDoc->Close (True);
- }
- $Output_dir = "d:/lighttpd/htdocs/";
- $doc_file = "D:/lighttpd/htdocs/2.doc";
- $pdf_file = "2.pdf";
- $output_file = $output _dir. $pdf _file;
- $doc_file = "file:///" . $doc _file;
- $output_file = "file:///" . $output _file;
- Word2pdf ($doc _file, $output _file);
- ?>
The above code is the way PHP handles word to PDF implementation.
PHP Word to PDF