docx to pdf conversion with libreoffice - pdf

I downloaded libreoffice to try to convert docx to pdf. Having a hard time getting it to run. I've looked around on forums and it seems the command is
soffice --convert-to pdf filename.docx
or
libreoffice --convert-to: pdf:writer_pdf_Export filename.docx
soffice is the command I have that works, as the .exe. I'm navigating to where the .exe is and trying to run it there. I'm getting the following error.
C:\Program Files\LibreOffice\program> soffice convert-to pdf C:\Users\mwolfe\OneDrive - Company Inc\doc_converter\test_file.doc
LibreOffice 6.1.4.2 9d0f32d1f0b509096fd65e0d4bec26ddd1938fd3
Error in option: -
Usage: soffice [argument...]
argument - switches, switch parameters and document URIs (filenames).
Using without special arguments:
Opens the start center, if it is used without any arguments.
{file} Tries to open the file (files) in the components
suitable for them.
{file} {macro:///Library.Module.MacroName}
Opens the file and runs specified macros from
the file.
Getting help and information:
--help | -h | -? Shows this help and quits.
--helpwriter Opens built-in or online Help on Writer.
--helpcalc Opens built-in or online Help on Calc.
--helpdraw Opens built-in or online Help on Draw.
--helpimpress Opens built-in or online Help on Impress.
--helpbase Opens built-in or online Help on Base.
--helpbasic Opens built-in or online Help on Basic scripting
language.
--helpmath Opens built-in or online Help on Math.
--version Shows the version and quits.
--nstemporarydirectory
(MacOS X sandbox only) Returns path of the temporary
directory for the current user and exits. Overrides
all other arguments.
General arguments:
--quickstart[=no] Activates[Deactivates] the Quickstarter service.
--nolockcheck Disables check for remote instances using one
installation.
--infilter={filter} Force an input filter type if possible. For example:
--infilter="Calc Office Open XML"
--infilter="Text (encoded):UTF8,LF,,,"
--pidfile={file} Store soffice.bin pid to {file}.
--display {display} Sets the DISPLAY environment variable on UNIX-like
platforms to the value {display} (only supported by a
start script).
User/programmatic interface control:
--nologo Disables the splash screen at program start.
--minimized Starts minimized. The splash screen is not displayed.
--nodefault Starts without displaying anything except the splash
screen (do not display initial window).
--invisible Starts in invisible mode. Neither the start-up logo nor
the initial program window will be visible. Application
can be controlled, and documents and dialogs can be
controlled and opened via the API. Using the parameter,
the process can only be ended using the taskmanager
(Windows) or the kill command (UNIX-like systems). It
cannot be used in conjunction with --quickstart.
--headless Starts in "headless mode" which allows using the
application without GUI. This special mode can be used
when the application is controlled by external clients
via the API.
--norestore Disables restart and file recovery after a system crash.
--safe-mode Starts in a safe mode, i.e. starts temporarily with a
fresh user profile and helps to restore a broken
configuration.
--accept={UNO-URL} Specifies an UNO-URL connect-string to create an UNO
acceptor through which other programs can connect to
access the API. UNO-URL is string the such kind
uno:connection-type,params;protocol-name,params;ObjectName.
--unaccept={UNO-URL} Closes an acceptor that was created with --accept. Use
--unaccept=all to close all open acceptors.
--language={lang} Uses specified language, if language is not selected
yet for UI. The lang is a tag of the language in IETF
language tag.
Developer arguments:
--terminate_after_init
Exit after initialization complete (no documents loaded).
--eventtesting Exit after loading documents.
New document creation arguments:
The arguments create an empty document of specified kind. Only one of them may
be used in one command line. If filenames are specified after an argument,
then it tries to open those files in the specified component.
--writer Creates an empty Writer document.
--calc Creates an empty Calc document.
--draw Creates an empty Draw document.
--impress Creates an empty Impress document.
--base Creates a new database.
--global Creates an empty Writer master (global) document.
--math Creates an empty Math document (formula).
--web Creates an empty HTML document.
File open arguments:
The arguments define how following filenames are treated. New treatment begins
after the argument and ends at the next argument. The default treatment is to
open documents for editing, and create new documents from document templates.
-n Treats following files as templates for creation of new
documents.
-o Opens following files for editing, regardless whether
they are templates or not.
--pt {Printername} Prints following files to the printer {Printername},
after which those files are closed. The splash screen
does not appear. If used multiple times, only last
{Printername} is effective for all documents of all
--pt runs. Also, --printer-name argument of
--print-to-file switch interferes with {Printername}.
-p Prints following files to the default printer, after
which those files are closed. The splash screen does
not appear. If the file name contains spaces, then it
must be enclosed in quotation marks.
--view Opens following files in viewer mode (read-only).
--show Opens and starts the following presentation documents
of each immediately. Files are closed after the showing.
Files other than Impress documents are opened in
default mode , regardless of previous mode.
--convert-to OutputFileExtension[:OutputFilterName]
[--outdir output_dir] [--convert-images-to]
Batch convert files (implies --headless). If --outdir
isn't specified, then current working directory is used
as output_dir. If --convert-images-to is given, its
parameter is taken as the target MIME format for *all*
images written to the output format. If --convert-to is
used more than once, the last value of OutputFileExtension
[:OutputFilterName] is effective. If --outdir is used more
than once, only its last value is effective. For example:
--convert-to pdf *.odt
--convert-to epub *.doc
--convert-to pdf:writer_pdf_Export --outdir /home/user *.doc
--convert-to "html:XHTML Writer File:UTF8" *.doc
--convert-to "txt:Text (encoded):UTF8" *.doc
--print-to-file [--printer-name printer_name] [--outdir output_dir]
Batch print files to file. If --outdir is not specified,
then current working directory is used as output_dir.
If --printer-name or --outdir used multiple times, only
last value of each is effective. Also, {Printername} of
--pt switch interferes with --printer-name.
--cat Dump text content of the following files to console
(implies --headless). Cannot be used with --convert-to.
--script-cat Dump text content of any scripts embedded in the files to console
(implies --headless). Cannot be used with --convert-to.
-env:<VAR>[=<VALUE>] Set a bootstrap variable. For example: to set
a non-default user profile path:
-env:UserInstallation=file:///tmp/test
I can't figure out what I'm doing wrong.

You need to add -- for commands and quotes around paths
first ensure you can open the doc from the command line. start with:
"C:\Program Files\LibreOffice\program\soffice.exe" "C:\Users\mwolfe\OneDrive - Company Inc\doc_converter\test_file.doc"
Then try the export command:
"C:\Program Files\LibreOffice\program\soffice.exe" --convert-to pdf "C:\Users\mwolfe\OneDrive - Company Inc\doc_converter\test_file.doc"
However with the latest libre office I'm not able to get any conversion working for me in windows command line.

Related

Add link to PDF within a PDF file using relative addressing

I want to add a link to some text within a PDF that will bring up another PDF that is located in the same folder. I wish to use relative addressing so that the PDF suite is transportable to other users and computers. I wish this to work on Linux and Macs.
LibreOffice Draw, despite promises, writes out the link address as a full path. Thus if taken to another computer with another user the link fails to work.
I tried manually editing the PDF files using vi and altered the link syntax so;
<</Type/Annot/Subtype/Link/Border[0 0 0]/Rect[940.9 480.3 1200.7 507.9]/A<</Type/Action/S/URI/URI(Content/Information.pdf)>>
where the target file, "Information.pdf" is in a subdirectory "Contents".
On Linux using Document Viewer, it works! On an Apple, Preview (a PDF viewer) interprets the target file needs to be opened by some application. Adobe Reader doesn't like this syntax either. I tried prefixing the filename with the keyword "file:" which works for a full path but not with relative addressing.
Does anyone know what syntax might work for me
Editing a PDF you can select text and add a hyperlink using LibreOffice Draw. It is then possible to edit the PDF file with a text editor such as vi.
To find the line with the link search for the filename of the target. One problem is that LibreOffice insists in using a fully qualified domain name to locate the file and this won't work after the file is moved, say to another computer. The unedited line should be similar to;
<</Type/Annot/Subtype/Link/Border[0 0 0]/Rect[940.9 480.3 1200.7 507.9]/A<</Type/Action/S/URI/URI(File:<fullpathname>/Content/Information.pdf)>>
Where Content/Information.pdf is the link target in the same directory as the linking pdf. This line should be changed to
<</Type/Annot/Subtype/Link/Border[0 0 0]/Rect[940.9 480.3 1200.7 507.9]/A<</Type/Action/S /Launch/F(Content/Information.pdf)>>
This works on Unix and MacOs

executing a Linux command from PDF file in a PDF viewer

Is it possible to execute a Linux command from a PDF file shown in a PDF viewer?
More specific: I generate PDF files from LaTeX using pdflatex. What I would like to do is to include some symbol or text in the PDF file which starts a Linux command when the user clicks on it. Typically I'm using evince to show PDF files.
I'm not sure whether it is at all possible to execute commands from PDF files in a viewer, and if it is possible, which packages and LaTeX commands would be required to include the symbol or text and the associated command in the PDF file?
(Alternatively, is there at least a way to obtain the number of the current page shown in the PDF viewer? That would help to some extent.)
Thanks a lot!
Unfortunately and rather fortunately you cant do that.The pdf standard doesnt allow to run shell scripts. That would be a HUGE security oversight.

Excel on Mac. Cannot open IQY file in Data/Get External Data/Run Web Query

I am running Excel version 16.45 on Mac.
I have created a .iqy and saved it in the Queries directory alongside certain templates which were already there.
I go to Data/Get External Data/Run Web Queries. While the templates are accessible, my file is visible but greyed out (same thing happens if I save the file in a different directory).
Would anyone be able to help?
According to your information, I would like to confirm whether the issue occurs when you follow the steps as below:
1.Create a Word file, paste the web URL.
2.Save the Word as .iqy with .txt format.
3.Choose MS-DOS as coding.
4.Create an Excel file and click "Data >Get External Data >Run Web Query (Or Run Saved Query) " of the Bar
I was able to address the issue as follows.
When navigating to the relevant directory with Finder, the '.iqy' file appears to be appropriately named (as per Image 1).
In fact, if you reach the file in Terminal, the file is saved as '.iqy.txt'.
So all I had to do is rename the file, simply removing the '.txt' string at the end.
Screen you see when navigating in Finder

Are there any Linux scriptable pdf readers?

I would like to make a call to a local server running a REST interface from within a pdf reader, passing the selected text as argument. The first option that came to mind was to write a simple bash script with a curl call inside, and use a script from within the pdf app to execute it.
Are there any scriptable pdf readers that would allow that? It seems that none of the most common ones (e.g. Okular, Evince, gv, xpdf) would make it possible.
Added after #DanielH comment:
I'm not asking for a method to launch arbitrary code when the a pdf file is opened. Rather, I am asking if the user can choose to launch an external app from within the pdf reader (or script).
Okular (KDE reader) has a limited form of this functionality: using KDE web shortcuts, the user can select a portion of text and then launch a browser with a predefined url that contain the text in the URL.
For instance, when an Okular user selects a word and then chooses the "Google" shortcut, Okular will launch a browser and put the following pseudo-URI in the location bar:
https://www.google.com/search?q=\{#}&ie=UTF-8
with {#} replaced by the selected text. KDE Web shortcuts are user-editable and can result in rather complex queries.
This functionality is very close to what I am after, except that the only http request that can be managed this way (as far as I know), is GET. Instead, I would need to start a POST http request, which as far as I know cannot be done from the location bar. Hence, my question about using using bash+curl.
I should have known...anything related to text on Unix? The answer is always emacs.
In particular:
the pdf-tools package can be used to read pdf files in an emacs buffer. It is much more efficient than PdfView and gives full access to annotations and all the usual emacs editing command (selecting regions, etc).
The standard emacs command shell-command-on-region can be used to launch a command with the selected region passed to it as standard input.
The command (as always in emacs) can be called interactively or from an emacs function.
All it's needed is to write a simple shell script that wraps up the needed command and passes on the input it receives.
In my case, I needed to call curl with a few parameters and a JSON string encapsulating the POST request. Iencountered a minor problem wince emacs passes the selected text (region) as standard input and not as argument, but this SX question (and #andy answer especially) helped me understand how to read piped standard input into a variable.

Why does my PDF ask for a password after being retrieved from Visual SourceSafe?

PREFACE: Yes we're moving away from VSS in the next few months.
One of my web projects contains, as one of its files, a PDF. The PDF on our QA site is being pulled from VSS.
A QA tester recently told me he's being prompted for a password when he tries to open it. VSS says the file I have on disk is different than the one it has, so I updated it, but afterwards it's still being shown as different.
So basically VSS is mangling my PDF and the results are so wobbly that Adobe Acrobat Reader is confused and thinks it has a password.
I've tried adding it as Auto-Detect and as Binary. Same results.
Why does my PDF ask for a password after being retrieved from Visual SourceSafe and how can I prevent it?
Do you have the SourceSafe 2005 Update installed?
Handy list of known issues: http://blogs.msdn.com/richardb/archive/2007/06/06/list-of-bugs-fixed-in-sourcesafe-2005-gdr.aspx
The PDF bug was one of the most commonly requested hotfixes: http://support.microsoft.com/kb/925234
I've tried adding it as Auto-Detect and as Binary. Same results.
To be clear, are you adding a version of the file you know is not already corrupted? Even so, there are plenty of other bug fixes on the list above which can cause random file corruption -- try that first.
You can remove PDF password by this tool:
Advanced PDF Password Remover 5.0
Step 1: Import PDF files
Click the "Add File(s)" button, browse your computer to find the PDF files and load them.You can import as many as 200 PDF files into this program for every batch processing.The imported files are listed in the file list window as below.
Step 2: Set output folder
You can customize a folder to save the output files all together. The default folder is My Documents\Advanced PDF Password Removerr. Click "Brows" button to specify a folder on your computer, or you can make a new folder manually in the text box.
Step 3: Remove restrictions
Click "Start" button, and the files are processed one by one.
"SUCCEED" is displayed in the Result column after the removing process is finished.