{"id":8458,"date":"2021-06-28T15:14:34","date_gmt":"2021-06-28T07:14:34","guid":{"rendered":"https:\/\/blog.hoyo.idv.tw\/?p=8458"},"modified":"2023-03-10T17:51:45","modified_gmt":"2023-03-10T09:51:45","slug":"centos-7-%e4%bd%bf%e7%94%a8-liberoffice-%e5%b0%87-office-%e8%bd%89%e6%8f%9b-pdf","status":"publish","type":"post","link":"https:\/\/blog.hoyo.idv.tw\/?p=8458","title":{"rendered":"Liberoffice - \u5c07 Office \u8f49\u63db PDF"},"content":{"rendered":"<p>--<\/p>\n<h2>\u53c3\u8003<\/h2>\n<ul>\n<li><a href=\"https:\/\/diegolamonica.info\/how-to-make-libreoffice-headless-to-work-on-centos-6-3\/\" target=\"_blank\" rel=\"noopener\">How to make libreoffice headless to work on CentOS 6.3<\/a><\/li>\n<li><a class=\"question-hyperlink\" href=\"https:\/\/askubuntu.com\/questions\/60778\/how-can-i-convert-an-odt-file-to-a-pdf\" target=\"_blank\" rel=\"noopener\">How can I convert an ODT file to a PDF?<\/a><\/li>\n<li><a href=\"https:\/\/www.twblogs.net\/a\/5c015ef0bd9eee7aec4eb0a3\" target=\"_blank\" rel=\"noopener\">\u95dc\u65bclibreoffice\u5728centos7\u4e0a\u8f49pdf\u9047\u5230\u4e2d\u6587\u4e82\u78bc\u7684\u554f\u984c<\/a><\/li>\n<li><a href=\"https:\/\/stackoverflow.com\/questions\/30349542\/command-libreoffice-headless-convert-to-pdf-test-docx-outdir-pdf-is-not\" target=\"_blank\" rel=\"noopener\">Command `libreoffice --headless --convert-to pdf test.docx --outdir \/pdf` is not working [closed]<\/a><\/li>\n<\/ul>\n<p>--<\/p>\n<h2>\u5b89\u88dd - Debian<\/h2>\n<pre class=\"lang:default decode:true \"># apt install libreoffice<\/pre>\n<p>--<\/p>\n<h2>\u5b89\u88dd\u3001\u4e2d\u6587\u5316\u8a2d\u5b9a - CentOS 7<\/h2>\n<pre class=\"lang:default decode:true\" style=\"color: #333333; font-style: normal; font-weight: 300;\"># yum install libreoffice-headless\r\n# yum groupinstall \"fonts\"<\/pre>\n<p>\u6aa2\u67e5\u8a9e\u7cfb\u8a2d\u5b9a<\/p>\n<pre class=\"lang:default decode:true\">vi \/etc\/locale.conf<\/pre>\n<pre class=\"lang:default decode:true\">LANG=\"zh_TW.UTF-8\"<\/pre>\n<p>\u5957\u7528<\/p>\n<pre class=\"lang:default decode:true\"># source \/etc\/locale.conf<\/pre>\n<p>--<\/p>\n<h2>\u5b89\u88dd\u5b57\u578b<\/h2>\n<pre class=\"lang:default decode:true\"># cp simsun.ttc \/usr\/share\/fonts\/\r\n# fc-cache -fv\r\n# fc-list<\/pre>\n<p>--<\/p>\n<h2>\u8f49\u63db<\/h2>\n<p>\u9996\u5148\u4f9d\u64da\u4f86\u6e90\u6587\u4ef6\u5b89\u88dd\u5c0d\u61c9\u7a0b\u5f0f\uff0c\u4f8b\u5982\u8a66\u7b97\u8868 calc<\/p>\n<pre class=\"lang:default decode:true\"># yum install libreoffice-calc\r\n# libreoffice --headless --convert-to pdf a.xls<\/pre>\n<p><a href=\"https:\/\/blog.hoyo.idv.tw\/wp-content\/uploads\/2021\/06\/20210628_151136.png\" data-rel=\"lightbox-image-0\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" class=\"alignnone size-medium wp-image-8462\" src=\"https:\/\/blog.hoyo.idv.tw\/wp-content\/uploads\/2021\/06\/20210628_151136-300x202.png\" alt=\"\" width=\"300\" height=\"202\" srcset=\"https:\/\/blog.hoyo.idv.tw\/wp-content\/uploads\/2021\/06\/20210628_151136-300x202.png 300w, https:\/\/blog.hoyo.idv.tw\/wp-content\/uploads\/2021\/06\/20210628_151136-768x518.png 768w, https:\/\/blog.hoyo.idv.tw\/wp-content\/uploads\/2021\/06\/20210628_151136-445x300.png 445w, https:\/\/blog.hoyo.idv.tw\/wp-content\/uploads\/2021\/06\/20210628_151136.png 857w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>--<\/p>\n<h2>\u5f9e\u7db2\u9801\u57f7\u884c<\/h2>\n<ul>\n<li><a class=\"question-hyperlink\" href=\"https:\/\/stackoverflow.com\/questions\/22973641\/php-libreoffice-shell-exec-not-working\" target=\"_blank\" rel=\"noopener\">php libreoffice shell_exec not working<\/a><\/li>\n<\/ul>\n<p>\u9664\u4e86\u9700\u8981\u8a2d\u5b9a\u4e00\u500b\u7db2\u9801 apache \u53ef\u4ee5\u5beb\u5165\u7684\u76ee\u9304\u5916\uff0c\u9084\u8981\u6ce8\u610f SELinux \u662f\u5426\u5df2\u7d93\u95dc\u9589<\/p>\n<p>--<\/p>\n<h2>Windows CLI<\/h2>\n<ul>\n<li><a href=\"https:\/\/wiki.documentfoundation.org\/Faq\/General\/150\" target=\"_blank\" rel=\"noopener\">Using the --convert-to command-line function to convert formats under Windows 10<\/a><\/li>\n<\/ul>\n<pre class=\"lang:default decode:true \">\"C:\\Program Files\\LibreOffice\\program\\soffice.exe\" --convert-to pdf test.xls<\/pre>\n<p>--<\/p>\n<h2>Word -&gt; HTML<\/h2>\n<ul>\n<li><a href=\"https:\/\/ask.libreoffice.org\/t\/headless-conversion-to-html-embeds-images-instead-of-creating-separate-files\/15085\" target=\"_blank\" rel=\"noopener\">Headless conversion to HTML embeds images instead of creating separate files<\/a><\/li>\n<\/ul>\n<pre class=\"lang:default decode:true\"># libreoffice --headless --convert-to html:HTML:EmbedImages Q1.docx<\/pre>\n<p>--<\/p>\n<h2>HTML -&gt; PDF<\/h2>\n<pre class=\"lang:default decode:true \"># libreoffice --headless --convert-to pdf 1234.html<\/pre>\n<p>--<\/p>\n<h2>HTML -&gt; Word<\/h2>\n<ul>\n<li><a class=\"question-hyperlink\" href=\"https:\/\/stackoverflow.com\/questions\/71855986\/how-to-manage-footer-while-converting-html-to-docx-file-using-libreoffice-comman\" target=\"_blank\" rel=\"noopener\">How to manage footer while converting html to docx file using libreoffice command?<\/a><\/li>\n<\/ul>\n<pre class=\"lang:default decode:true\">libreoffice --headless --convert-to docx:\"MS Word 2007 XML\" --outdir \/dev\/shm \/dev\/shm\/a.html<\/pre>\n<p>--<\/p>\n<pre class=\"lang:default decode:true\">Usage: soffice [argument...]\r\n       argument - switches, switch parameters and document URIs (filenames).\r\n\r\nUsing without special arguments:\r\nOpens the start center, if it is used without any arguments.\r\n   {file}              Tries to open the file (files) in the components\r\n                       suitable for them.\r\n   {file} {macro:\/\/\/Library.Module.MacroName}\r\n                       Opens the file and runs specified macros from\r\n                       the file.\r\n\r\nGetting help and information:\r\n   --help | -h | -?    Shows this help and quits.\r\n   --helpwriter        Opens built-in or online Help on Writer.\r\n   --helpcalc          Opens built-in or online Help on Calc.\r\n   --helpdraw          Opens built-in or online Help on Draw.\r\n   --helpimpress       Opens built-in or online Help on Impress.\r\n   --helpbase          Opens built-in or online Help on Base.\r\n   --helpbasic         Opens built-in or online Help on Basic scripting\r\n                       language.\r\n   --helpmath          Opens built-in or online Help on Math.\r\n   --version           Shows the version and quits.\r\n   --nstemporarydirectory\r\n                       (MacOS X sandbox only) Returns path of the temporary\r\n                       directory for the current user and exits. Overrides\r\n                       all other arguments.\r\n\r\nGeneral arguments:\r\n   --quickstart[=no]   Activates[Deactivates] the Quickstarter service.\r\n   --nolockcheck       Disables check for remote instances using one\r\n                       installation.\r\n   --infilter={filter} Force an input filter type if possible. For example:\r\n                       --infilter=\"Calc Office Open XML\"\r\n                       --infilter=\"Text (encoded):UTF8,LF,,,\"\r\n   --pidfile={file}    Store soffice.bin pid to {file}.\r\n   --display {display} Sets the DISPLAY environment variable on UNIX-like\r\n                       platforms to the value {display} (only supported by a\r\n                       start script).\r\n\r\nUser\/programmatic interface control:\r\n   --nologo            Disables the splash screen at program start.\r\n   --minimized         Starts minimized. The splash screen is not displayed.\r\n   --nodefault         Starts without displaying anything except the splash\r\n                       screen (do not display initial window).\r\n   --invisible         Starts in invisible mode. Neither the start-up logo nor\r\n                       the initial program window will be visible. Application\r\n                       can be controlled, and documents and dialogs can be\r\n                       controlled and opened via the API. Using the parameter,\r\n                       the process can only be ended using the taskmanager\r\n                       (Windows) or the kill command (UNIX-like systems). It\r\n                       cannot be used in conjunction with --quickstart.\r\n   --headless          Starts in \"headless mode\" which allows using the\r\n                       application without GUI. This special mode can be used\r\n                       when the application is controlled by external clients\r\n                       via the API.\r\n   --norestore         Disables restart and file recovery after a system crash.\r\n   --safe-mode         Starts in a safe mode, i.e. starts temporarily with a\r\n                       fresh user profile and helps to restore a broken\r\n                       configuration.\r\n   --accept={UNO-URL}  Specifies an UNO-URL connect-string to create an UNO\r\n                       acceptor through which other programs can connect to\r\n                       access the API. UNO-URL is string the such kind\r\n                   uno:connection-type,params;protocol-name,params;ObjectName.\r\n   --unaccept={UNO-URL} Closes an acceptor that was created with --accept. Use\r\n                       --unaccept=all to close all open acceptors.\r\n   --language={lang}   Uses specified language, if language is not selected\r\n                       yet for UI. The lang is a tag of the language in IETF\r\n                       language tag.\r\n\r\nDeveloper arguments:\r\n   --terminate_after_init\r\n                       Exit after initialization complete (no documents loaded).\r\n   --eventtesting      Exit after loading documents.\r\n\r\nNew document creation arguments:\r\nThe arguments create an empty document of specified kind. Only one of them may\r\nbe used in one command line. If filenames are specified after an argument,\r\nthen it tries to open those files in the specified component.\r\n   --writer            Creates an empty Writer document.\r\n   --calc              Creates an empty Calc document.\r\n   --draw              Creates an empty Draw document.\r\n   --impress           Creates an empty Impress document.\r\n   --base              Creates a new database.\r\n   --global            Creates an empty Writer master (global) document.\r\n   --math              Creates an empty Math document (formula).\r\n   --web               Creates an empty HTML document.\r\n\r\nFile open arguments:\r\nThe arguments define how following filenames are treated. New treatment begins\r\nafter the argument and ends at the next argument. The default treatment is to\r\nopen documents for editing, and create new documents from document templates.\r\n   -n                  Treats following files as templates for creation of new\r\n                       documents.\r\n   -o                  Opens following files for editing, regardless whether\r\n                       they are templates or not.\r\n   --pt {Printername}  Prints following files to the printer {Printername},\r\n                       after which those files are closed. The splash screen\r\n                       does not appear. If used multiple times, only last\r\n                       {Printername} is effective for all documents of all\r\n                       --pt runs. Also, --printer-name argument of\r\n                       --print-to-file switch interferes with {Printername}.\r\n   -p                  Prints following files to the default printer, after\r\n                       which those files are closed. The splash screen does\r\n                       not appear. If the file name contains spaces, then it\r\n                       must be enclosed in quotation marks.\r\n   --view              Opens following files in viewer mode (read-only).\r\n   --show              Opens and starts the following presentation documents \r\n                       of each immediately. Files are closed after the showing.\r\n                       Files other than Impress documents are opened in\r\n                       default mode , regardless of previous mode.\r\n   --convert-to OutputFileExtension[:OutputFilterName] \r\n     [--outdir output_dir] [--convert-images-to]\r\n                       Batch convert files (implies --headless). If --outdir\r\n                       isn't specified, then current working directory is used\r\n                       as output_dir. If --convert-images-to is given, its\r\n                       parameter is taken as the target MIME format for *all*\r\n                       images written to the output format. If --convert-to is\r\n                       used more than once, the last value of OutputFileExtension\r\n                       [:OutputFilterName] is effective. If --outdir is used more\r\n                       than once, only its last value is effective. For example:\r\n                   --convert-to pdf *.odt\r\n                   --convert-to epub *.doc\r\n                   --convert-to pdf:writer_pdf_Export --outdir \/home\/user *.doc\r\n                   --convert-to \"html:XHTML Writer File:UTF8\" *.doc\r\n                   --convert-to \"txt:Text (encoded):UTF8\" *.doc\r\n   --print-to-file [--printer-name printer_name] [--outdir output_dir]\r\n                       Batch print files to file. If --outdir is not specified,\r\n                       then current working directory is used as output_dir.\r\n                       If --printer-name or --outdir used multiple times, only\r\n                       last value of each is effective. Also, {Printername} of\r\n                       --pt switch interferes with --printer-name.\r\n   --cat               Dump text content of the following files to console\r\n                       (implies --headless). Cannot be used with --convert-to.\r\n   --script-cat        Dump text content of any scripts embedded in the files to console\r\n                       (implies --headless). Cannot be used with --convert-to.\r\n   -env:&lt;VAR&gt;[=&lt;VALUE&gt;] Set a bootstrap variable. For example: to set\r\n                       a non-default user profile path:\r\n                       -env:UserInstallation=file:\/\/\/tmp\/test\r\n\r\nIgnored switches:\r\n   -psn                Ignored (MacOS X only).\r\n   -Embedding          Ignored (COM+ related; Windows only).\r\n   --nofirststartwizard Does nothing, accepted only for backward compatibility.\r\n   --protector {arg1} {arg2}\r\n                       Used only in unit tests and should have two arguments.<\/pre>\n<p>--<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p class=\"pvc_stats all \" data-element-id=\"8458\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> &nbsp;3,416&nbsp;total views, &nbsp;1&nbsp;views today<\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>-- \u53c3\u8003 How to ma...<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p class=\"pvc_stats all \" data-element-id=\"8458\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> &nbsp;3,416&nbsp;total views, &nbsp;1&nbsp;views today<\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[31],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/8458"}],"collection":[{"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=8458"}],"version-history":[{"count":20,"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/8458\/revisions"}],"predecessor-version":[{"id":11781,"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/8458\/revisions\/11781"}],"wp:attachment":[{"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=8458"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=8458"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=8458"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}