PHP Word to PDF

Source: Internet
Author: User
Tags php language

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:

  1. < php
  2. Set_time_limit (0);
  3. function Makepropertyvalue ($name, $value, $OSM) {
  4. $ostruct = $osm->bridge_getstruct
    ("Com.sun.star.beans.PropertyValue");
  5. $oStruct->Name = $name;
  6. $oStruct->Value = $value;
  7. return $oStruct;
  8. }
  9. function Word2pdf ($doc _url, $output _url) {
  10. $OSM = new COM ("Com.sun.star.ServiceManager")
    Or Die ("sure is a OpenOffice.org
    is installed.\n ");
  11. $args = array(Makepropertyvalue ("Hidden", True, $OSM));
  12. $odesktop = $osm->createinstance ("Com.sun.star
    . Frame. Desktop ");
  13. $Owriterdoc = $oDesktop->loadcomponentfromurl
    ($doc _url, "_blank", 0, $args);
  14. $Export_args = array(makepropertyvalue
    ("FilterName", "Writer_pdf_export", $OSM));
  15. $oWriterDoc->storetourl ($output _url, $export _args);
  16. $oWriterDoc->Close (True);
  17. }
  18. $Output_dir = "d:/lighttpd/htdocs/";
  19. $doc_file = "D:/lighttpd/htdocs/2.doc";
  20. $pdf_file = "2.pdf";
  21. $output_file = $output _dir. $pdf _file;
  22. $doc_file = "file:///" . $doc _file;
  23. $output_file = "file:///" . $output _file;
  24. Word2pdf ($doc _file, $output _file);
  25. ?>

The above code is the way PHP handles word to PDF implementation.

PHP Word to PDF

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.