Libreoffice only convert from odt to pdf, not other formats [closed] - libreoffice

Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 months ago.
The community reviewed whether to reopen this question 6 months ago and left it closed:
Original close reason(s) were not resolved
Improve this question
I'm trying to convert documents from html,txt to pdf,odt and vice versa.. But only odt to pdf seems to work.. No other file formats are converted
Here are my commands
libreoffice --headless --convert-to pdf test.html [Not working]
libreoffice --headless --convert-to odt test.html [Not working]
libreoffice --headless --convert-to pdf test.docx [Not working]
libreoffice --headless --convert-to pdf test.odt [Working]

Try closing all running instances of LibreOffice before executing the command. This was the root cause of my pain.

This is a known issue in LibreOffice that was fixed in version 5.3.0. Before this fix when an instance of LibreOffice is running --convert-to or any other command would silently terminate without doing anything.
If your version is older than that you could consider the solution suggested by Frank Yin here. That is close all open LibreOffice documents before running the conversion.
If you cannot close all open LibreOffice documents to run the conversion, or if you find it inconvenient, you could try a solution suggested in the comments to the original bug.
If you have LibreOffice version before 4.5 run
soffice -env:UserInstallation=file:///$HOME/.libreoffice-headless/ \
--headless --convert-to pdf test.docx
If you are running LibreOffice version between 4.5 and 5.3 run
soffice -env:UserInstallation=file:///$HOME/.libreoffice-headless/ \
--convert-to pdf test.docx
Here $HOME/.libreoffice-headless is a new profile directory different from your main LibreOffice profile.

The real problem is that the libreoffice/soffice command line doesn't provide any error message or debugging information, so it's all guesswork. If you are up to it, then try strace for hints.
In my case (Linux), I didn't have the correct packages installed - for example, to convert spreadsheets, libreoffice-calc is needed (duh), and also libreoffice-headless (double-duh). But the command line won't tell you that - it just hangs, or runs and doesn't do anything.

The following works
libreoffice --invisible -convert-to pdf myFile.html
libreoffice --invisible -convert-to docx myFile.odt
The option --invisible does not start up the GUI but gives some clues on the command line what is happening.
Tested on Linux Mint 13.

This worked for me on LibreOffice 4.2 / Linux:
soffice --headless --convert-to txt:Text /path_to/document_to_convert.odt
Credit: http://ask.libreoffice.org/en/question/14130/how-do-i-install-filters-for-the-soffice-command/

For me. The problem I had was that --headless does not work, AT ALL (just returns in 15 milli-seconds), if a local libreoffice process already has the document open.
Make sure you only do headless operations on a document that is NOT already open in LibreOffice.

For me, the following two packages were the minimum needed to get headless docx to pdf conversion working on CentOS 7 :
yum install libreoffice-headless libreoffice-writer

One of the problems that I encountered with libreoffice was the problem with empty spaces. After I slugged the name ("test-document.docx" instead of test "documnet.docx") it worked perfectly.
From version 4.2.8.2 - 5.3.

On Windows I encountered the following problem: I tried to convert all DOC files to PDF using the following command:
soffice --invisible --convert-to pdf *.doc
It failed without any error message. But it worked when I put a filename of one of the files instead of *.doc. So apparently it was a problem with resolving wildcard in *.doc. What I did is execute exactly the same command as above but from Git Bash instead of normal command prompt (cmd.exe). It worked. What is more: in Git Bash it displayed progress information and informative messages!
So my advice is: if you're running soffice.exe on Windows and don't get any output, run the command from Git Bash (you can get Git Bash by installing Git for Windows)

I had to install the xvfb package (yum install xorg-x11-server-Xvfb), it is the xserver dummy.

Related

MacOS gives zsh: command not found: flutter after updating path according to Flutter Official Docs [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
Recently I updated Mac OS to latest Catalina and my terminal which is using zsh now start showing me following error:
zsh: command not found: flutter
It was working fine before update.
You need to update the environment path.
Open terminal.
vim $HOME/.zshrc
Press "I" key for going to insert mode.
add the following line in the opened file:
export PATH="$PATH:/YOUR_FLUTTER_DIR/flutter/bin"
Press "Esc" then write :wq! in terminal and press enter to exit vim.
Reopen the terminal and check "flutter doctor"
If this solution did not work, remove the double quote from path or use the full path explicitly instead of ~.
Working on macOS Catalina 10.15.5 (19F101).
I have used .zprofile instead of .zhrc
Provide Full Disk Access to Terminal by
Setting -> Security & Privacy -> Full Disk Access. Add Terminal
If the current terminal uses bash, change to zshell using the below command
chsh -s /bin/zsh
In the root directory i.e something like /Users/^YourAccount^ execute the below
touch .zprofile
vim .zprofile
Press I to enter insert mode. Type the below
export PATH=$PATH:/Users/^YourAccount^/^YourPath^/flutter/bin
Save and quit by pressing Esc, then :wq and Enter
Close Terminal and reopen Again. Then try executing flutter command
For me removing double quotes did the fix.
Try changing
export PATH="$PATH:[PATH TO FLUTTER]/flutter/bin"
into
export PATH=$PATH:[PATH TO FLUTTER]/flutter/bin
adding few more steps for easiness:
Open terminal.
vim $HOME/.zshrc
Press "I" to open insert mode.
add the following line in the opened file:
export PATH=$PATH:[PATH TO FLUTTER]/flutter/bin (remember I don't have double quotes here)
Press "Esc" then type :wq in terminal to exit edit mode.
Type
source .zshrc to reload the terminal for changes
You must update your environment $PATH variable.
1) Open the file $HOME/.zshrc $HOME is your home path
2) add the following line in the opened file:
export PATH="$PATH:/YOUR_FLUTTER_DIR/flutter/bin"
3) save the changes and restart your terminal session.
The process is also documented here
Follow these steps:
Open finder
Enter Cmd + Shift + G
Type ~ in Go to the folder popup.
Now enter Cmd + Shift + . to show hidden files.
Open .zshrc
Add this line
export PATH="$PATH:/YOUR_FLUTTER_DIR/flutter/bin"
Replace this /YOUR_FLUTTER_DIR with the path to your flutter directory.
In my mac, the path is
export PATH=$PATH:$HOME/FlutterDevelopment/flutter/bin
in android studio terminal, simply just type this command:
export PATH="/YOUR_FLUTTER_DIR/flutter/bin:$PATH"
change YOUR_FLUTTER_DIR to your actual directory
I updated from Mojave to Catalina and running Terminal, switched to the default/preferred zsh shell, from the bash shell.
Then was hit with
zsh: command not found: flutter
so, followed the advice seen elsewhere to only add the following to Users/MyUserId/.zshrc
export PATH="$PATH:/YOUR_FLUTTER_DIR/flutter/bin"
echo $PATH showed that /Users/MyUserId/flutter/bin was now one of the configured PATHs.
However, I couldn't get "flutter doctor" to work but came across a post on jelliesgame.com which suggested copying
Users/MyUserId/.bash_profile to Users/MyUserId/.zshenv
Now, flutter doctor gives a clean bill of health
This worked for me:
Steps:
Type on the terminal:
open .zshrc (This opens the document in text edit)
Add this to the end of the file:
export PATH="/Users/YOUR_USERNAME/Documents/code/tools/flutter/bin:$PATH"
Save and close .zshrc
Then type:
flutter doctor
Had the same issue and just realized that I forgot to add the close quote
So the correct way is to add to .zshrc by typing vim ~/.zshrc
PATH="$PATH:$HOME/Flutter/flutter/bin"
or
export PATH="$PATH:/YOUR_FLUTTER_DIR/flutter/bin"
then run source ~/.zshrc or just open a new terminal window
I tried installing flutter on my MAC according to the advice here, but it still doesn't work, after searching for it I found an article here.
So, I change my .zshrc file to:
export PATH="$PATH:/Users/YOUR_PROVILE_NAME/YOUR_DEVELOPMENT_FOLDER/flutter/bin"
Change YOUR_PROVILE_NAME to your name profile, also YOUR_DEVELOPMENT_FOLDER to your development folder for flutter
and now it's working.
Note:
I use Catalina OS v10.15.4
I followed URL to resolve my issue.
I simply created a .zshrc file which was not exist then added my PATH variables copied from existing .bashrc.
I had the same problem when upgrading to mac Catalina 10.15.4:
After many days of research, I have achieved success. Here are the steps I did:
First, open the terminal on your mac.
Next, use the command
cat .bash_profile
and copy the content.
Then type this command into the terminal:
nano $ HOME / .zshrc
and paste the content just copied above into. Save then type
source $ HOME / .zshrc
to refresh this file. Next type
echo $ PATH
to see if the content has been updated. If successful type
flutter --version
and you will see the result.
There are quite a few answers mentioned above pretty much same. I would say worth seeing into the SHELL using echo $SHELL command,
If you’re using Bash, edit $HOME/.bash_profile or $HOME/.bashrc. If you’re using Z shell, edit $HOME/.zshrc. If you’re using a different shell, the file path and filename will be different on your machine.
N.B. Don't forget you need to add VIM before either command in the terminal app.
For further details, click the link Update your path, and look into the section Update your Path. I hope it would help many especially new comers to MAC OS. Cheers
For me .zshrc worked instead of .zprofile. I believe this is because I had created .zshrc earlier and now when I tried creating .zprofile, it was looking into .zshrc file.
You can check if .zshrc file using ls -a command

Markdown preview in emacs fails: (pandoc?) error 127

I am trying to create a markdown document in Emacs *.
It does highlight the syntax etc. and goes into Markdown mode (I am not quite sure if I installed that package or if it is standard issue)..
Problem:
When I try to create a preview (either via C-c C-c p or the GUI), it returns this error code:
markdown failed with exit code 127
Question
What does this error tell me? Is there a way to get a more complete error message?
The docs for markdown-mode suggest that it calls on an external library such as pandoc, which I have installed. According to these SO questions, pandoc can return this error code, but I could not quite establish what it means.
How do I fix this / what documentation should I go to?
I am pretty new to Emacs, so anything will help. Thanks!
*Emacs version 25.3.1 on a Mac (Sierra 10.12.6)
The simplest fix is likely to install the markdown package using your package manager.
I fixed this error for myself with:
$ brew install markdown
(on MacOS Mojave, at the bash command line). Brew installed the "bottle" markdown-1.0.1.mojave.bottle.tar.gz, after which C-c C-c p or M-x markdown-preview worked to export the markdown file and open a browser window showing the exported file.
On an Ubuntu 19 (and now 20.04 and 21.10) system, sudo apt install markdown worked too.
You could do the same thing with a symlink to pandoc's markdown, but a) this just worked, b) there's no fiddling with a potentially messed up manually created symlink, and c) it's tiny (a 36 KByte executable). Pandoc's markdown may support more "modern" markdown, though.

Convert ipynb to pdf in Jupyter

I am new to ipython notebook, and I would like to convert my ipynb to pdf. But I get the following error when I try to Download as PDF via LaTex.
nbconvert failed: pdflatex not found on PATH
There is no documentation anywhere how to add pdflatex to my PATH. I use windows. Thank you!
A simple and surprisingly good solution is to print the notebook to pdf through the browser with ctrl+p. Just make sure your plots and figures are not on interactive mode otherwise they will not be displayed (set them to %matplotlib inline).
Exporting jupyter notebooks through latex is quite troublesome and takes a lot of tinkering to get something remotely close to publish ready. When I absolutely need publication quality I do it on a latex editor, but this tutorial goes in great length about doing it on jupyter.
A few useful tips to get better results:
Higher resolution plots
Hide your code-cells from the pdf
Take a look at these extensions to improve your jupyter documents
For Mac OS X, the solution for me was to install MacTex first and then export the path to find it:
### TeX
export PATH="/Library/TeX/Distributions/.DefaultTeX/Contents/Programs/texbin:$PATH"
You can add this to your .bash_profile or similar config file to load it every time.
See more here https://github.com/jupyter/nbconvert/issues/406
As said by Thomas K in the comments, you need to have Latex installed, and after add the path to the directory containing pdflatex.exe file to the PATH variable of your system.
I have looked for a lightweight distribution and tried installing TeXworks, but I didn't find any pdflatex.exe file.
So I have tried TeX Live, which worked fine creating the pdflatex.exe file under the target installation directory. This path should be like C:\...\texlive\2016\bin\win32.
Finally, you should just add this path to the PATH environment variable of your system (you can use the link shared by Thomas K).
As said here, you need to quit jupyter notebook and open a new command prompt after making any path changes, in order for jupyter to find the newly added item to the PATH.
Then, in Jupyter, you can check your environment variables by running the following (refer to this link for details):
import os
os.environ['PATH'].split(';')
and check if it contains the path to pdflatex.exe file.
If you get some trouble when exporting your notebook to pdf due to missing files/packages (this happened to me), refer to this link to search and install them under TeX Live.
For Linux, the reported error is due to the lack of XeLatex, part of the texlive-xetex package.
Installation in ubuntu will be:
sudo apt install texlive-xetex
Instead of using nbconvert what you can do is :
Download your ipynb file as HTML from File option.
Right-click and select print or use Ctrl+P.
Save as PDF
Easy.
Here is the full solution that worked for me (for Mac).
brew cask install mactex
$ cd ~/
$ touch .bash_profile
This will open the bash profile on TextEditor
$ open -e .bash_profile
Paste the following to the top and save
export PATH="/Library/TeX/Distributions/.DefaultTeX/Contents/Programs/texbin:$PATH"
Close any notebook you have and reopen it
Here is the notebook explaining it step by step:
https://github.com/ybaktir/notes/blob/master/Convert%20Jupyter%20Notebook%20to%20Pdf.ipynb
I agree that latex installation (at least on windows) is painful and the result in my case was not a great looking document. The ctrl-p method alone doesn't work great if you're running in JupyterLab, but if you export the notebook to HTML, then print from the browser, choosing PDF, the result is quite good.
I know my solution is not at a level. But it works !!
in your browser of notebook tab, simply do "ctrl + p" to get download in pdf
First export the notebook file to HTML (available through File> Download as..).
If you are using JupyterLab, then this is available under File > Export Notebook As....
Use (any) free online converters to convert html file to a pdf file. (One such free online converter is sejda (https://www.sejda.com/html-to-pdf)
Note, there are many such converters are available online.

Can't find launcher in ~/anaconda 2.0 in mac osx

I just did a clean install of ananconda 2.0 (python 3.4) on my mac osx after uninstalling the previous version of anaconda.
I used the graphical installer but the launcher is missing in the ~/anaconda directory.
I tried running spyder and ipython from the terminal but i got long error messages that ended with:
ValueError: unknown locale: UTF-8
I am a newbie to python programming and this is quite unnerving for me. I have gone through related answers but I still need help.
Guys, please kindly point me in the right direction.
Thanks.
You have two problems here:
The Anaconda launcher haven't been ported to Python 3 yet, so that's why you can't find it.
To fix the ValueError: unknown locale: UTF-8 problem, you need to:
Open a terminal
Write this command on it
nano ~/.bashrc (nano is terminal-based editor)
Paste this text in nano:
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
Hit these keys to save: Ctrl+O+Enter, then Ctrl+X to exit.
Close that terminal, open a new one and try to start spyder. Everything should be fixed now.

Headless duck not quacking on MacOS

I'm trying to convert an ODT file to a PDF file with the following command:
/Applications/LibreOffice.app/Contents/MacOS/soffice.bin \
--headless --convert-to pdf file.odt
LibreOffice comes up momentarily and... that's it. file.odt exists and is readable. The current directory is writable. I was expecting file.pdf to be created but nope, nothing.
Any hints on how I might debug it?
Turns out, you cannot run LibreOffice headless if you are already running it... uh, "headful". Or you can, but it doesn't do anything.
Or as some might say, the duck won't quack.