CLI’dan Ofis Belgelerini PDF’e Dönüştürme (how to convert office files to pdf)

Dönüştürme işlemleri için Centos üzerinde libreoffice kullanılacaktır.

Kurulum

$ yum install libreoffice-headless libreoffice-writer libreoffice-calc libreoffice-impress

Kullanımı

$ libreoffice --headless --convert-to pdf mydocument.odt

*** Çevrilecek dosyalar kesinlikle belirtilen dosya uzantılarını dosya adında içermeli.

PDF’ler de  plain text’e aşağıdaki şekilde çevrilebilir:

$ pdftotext mydocument.pdf mydocument.txt

Desteklenen Dosya Tipleri

array(
        // Mix. file types
        array('mimeType'=>'text/plain','extension'=>'txt'),
        array('mimeType'=>'application/rtf','extension'=>'rtf'),
        array('mimeType'=>'application/vnd.wordperfect','extension'=>'wpd'),
        array('mimeType'=>'text/csv','extension'=>'csv'),
        array('mimeType'=>'text/tab-separated-values','extension'=>'tsv'),
        // Microsoft office file types
        array('mimeType'=>'application/msword','extension'=>'doc'),
        array('mimeType'=>'application/msword','extension'=>'dot'),
        array('mimeType'=>'application/vnd.openxmlformats-officedocument.wordprocessingml.document','extension'=>'docx'),
        array('mimeType'=>'application/vnd.openxmlformats-officedocument.wordprocessingml.template','extension'=>'dotx'),
        array('mimeType'=>'application/vnd.ms-word.document.macroEnabled.12','extension'=>'docm'),
        array('mimeType'=>'application/vnd.ms-word.template.macroEnabled.12','extension'=>'dotm'),
        array('mimeType'=>'application/vnd.ms-excel','extension'=>'xls'),
        array('mimeType'=>'application/vnd.ms-excel','extension'=>'xlt'),
        array('mimeType'=>'application/vnd.ms-excel','extension'=>'xla'),
        array('mimeType'=>'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet','extension'=>'xlsx'),
        array('mimeType'=>'application/vnd.openxmlformats-officedocument.spreadsheetml.template','extension'=>'xltx'),
        array('mimeType'=>'application/vnd.ms-excel.sheet.macroEnabled.12','extension'=>'xlsm'),
        array('mimeType'=>'application/vnd.ms-excel.template.macroEnabled.12','extension'=>'xltm'),
        array('mimeType'=>'application/vnd.ms-excel.addin.macroEnabled.12','extension'=>'xlam'),
        array('mimeType'=>'application/vnd.ms-excel.sheet.binary.macroEnabled.12','extension'=>'xlsb'),
        array('mimeType'=>'application/vnd.ms-powerpoint','extension'=>'ppt'),
        array('mimeType'=>'application/vnd.ms-powerpoint','extension'=>'pot'),
        array('mimeType'=>'application/vnd.ms-powerpoint','extension'=>'pps'),
        array('mimeType'=>'application/vnd.ms-powerpoint','extension'=>'ppa'),
        array('mimeType'=>'application/vnd.openxmlformats-officedocument.presentationml.presentation','extension'=>'pptx'),
        array('mimeType'=>'application/vnd.openxmlformats-officedocument.presentationml.template','extension'=>'potx'),
        array('mimeType'=>'application/vnd.openxmlformats-officedocument.presentationml.slideshow','extension'=>'ppsx'),
        array('mimeType'=>'application/vnd.ms-powerpoint.addin.macroEnabled.12','extension'=>'ppam'),
        array('mimeType'=>'application/vnd.ms-powerpoint.presentation.macroEnabled.12','extension'=>'pptm'),
        array('mimeType'=>'application/vnd.ms-powerpoint.template.macroEnabled.12','extension'=>'potm'),
        array('mimeType'=>'application/vnd.ms-powerpoint.slideshow.macroEnabled.12','extension'=>'ppsm'),
        // Open office file types
        array('mimeType'=>'application/vnd.oasis.opendocument.text','extension'=>'odt'),
        array('mimeType'=>'application/vnd.oasis.opendocument.spreadsheet','extension'=>'ods'),
        array('mimeType'=>'application/vnd.sun.xml.calc','extension'=>'sxc','convertTo'=>'txt'),
        array('mimeType'=>'application/vnd.oasis.opendocument.presentation','extension'=>'odp'),
        array('mimeType'=>'application/vnd.sun.xml.writer','extension'=>'swx'),
        array('mimeType'=>'application/vnd.sun.xml.impress','extension'=>'sxi'),
);
Print Friendly, PDF & Email

Leave a Reply

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