Auto-conversion word to PDF on server side

There is a requirement for a system to convert a ms word file to PDF on server side.

References

  1. using libreoffice
  2. using python and openoffice

direct command

libreoffice --convert-to pdf /path/to/file.{doc,docx}
 OR
shell_exec('/usr/bin/libreoffice --headless --convert-to pdf:writer_pdf_Export --outdir /var/www/html/demo/public_html/src/var/output /var/www/html/demo/public_html/src/var/source/sample.doc');

OR

libreoffice --headless -convert-to pdf fileToConvert.docx -outdir output/path/for/pdf

above sample codes taken from different sources. Actually a similar command with some different optional parameters.

Leave a Reply

Your email address will not be published. Required fields are marked *