Headless duck not quacking on MacOS - libreoffice

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.

Related

How to stop VScode creating a symlink instead of a file

I have tried to google, this can't find anything or on here so suspect i'm being a noob, so perhaps someone can educate me.
I am copying a file from one directory within by repo in VScode to another. It is a MAKEFILE (which i'm not that familiar with anyway).
I then select copy...
And then i select a sub directory within same directory so i can paste
Once i complete this, rather than the file being copied, it creates a syslink to the file which isn't what i want as i now need to modify the file...
Even if i create the file as a new file, this will still display as a symlink.
Am i doing something stupid here?
I have created the file through the command line but the file still shows as a symlink.
Driving me crazy, please help!
thanks :)
I found the solution here, just complete these steps:
Open VSCode and press Command+Shift+p
Type Uninstall and select option "Uninstall code command from PATH"
Input admin password and then close VSCode once it confirms its been removed
Close VScode application
Re-open VScode and press Command+Shift+p
Type "Install code command to PATH"
Input admin password
Try now and this should work.
I found if i didnt close VScode after removing/adding command to PATH, the setting was lost.
Hope this helps.

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.

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

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.

Run Fiji from command line?

Here is what I want to do:
I want to run Fiji from command-line, to do something like batch image processing. I imagine by typing some command at some console, some batch file can be launched to execute some macro. In this case, the Fiji GUI will not show up, but the processing will be running behind the scene.
Here is what I have done:
I simply tried the FIji headless , but when I tried ./Build.sh misc/headless.jar as the web suggested, the console prompt returns could not find project for artifactID 'headless';
I also tried Javassist,pretty much just built it, but have not figure out how to use it.
Here is the problem I am encountering:
When I type fiji --headless HelloWorldMacro.ijm, nothing happened, where inside the HelloWorldMacro.ijm is printf("Hello world!");
I am wondering, how should I run FIji from command line? Is what I have tried on the right track? If so, what additional work/changes needed to make it work? Thanks a lot.
For the record:
Johannes Schindelin answered this question on the ImageJ mailing list (additionally pointing out why the ImageJ mailing list is the most suitable place for this kind of discussions).
In short, either of the following should work:
fiji --headless --console HelloWorldMacro.ijm
or
fiji --headless HelloWorldMacro.ijm > output.txt
cat output.txt

QuickText in notepad++ not saving code snippets!

I installed notepad++ on Windows7. I installed QuickText into notepad++. I add my custom snippets into QuickText and while notepad is open, the snippets work fine. As soon as I close notepad and open it again, the snippets are gone. Has anyone else had this problem, it should be an easy fix? They are not persisting or sticking.
Anyone know how to fix this? Any ideas?
Haven't used Quicktext but it looks like it is no longer under development.
From what I can tell FingerText is similar, and hopefully should be able to do what you are after.
The complete answer lies in a combination of Nick's and Jrod's answers.
If you create the a Config folder in the C:\Program Files\Notepad++\plugins\ (or C:\Program Files (x86)\Notepad++\plugins\ if you installed it to that folder) and then place the QuickText.ini file within that folder you will notice many default "snippits" show up.
Now in order for you to save your "snippits" if you are in Windows 7 or Vista (which will save to the QuickText.ini file) you must run Notepad++ as Administrator.
As a side note the snippits save fine with in Linux if you install Notepad++ through Wine.
This issue is caused by administrative privileges. You need to run notepad++ as an administrator or it will fail silently.
You must copy QuickText.ini to folder c:\Program Files\Notepad++\plugins\Config\ (I created this folder itself)
This page help me
Sorry for my badly english. Your problem is in inslall. Correct install:
Copy to folder plugins all files except one (quicktext.ini).
In such directory create new folder config.
Copy quicktext.ini into it.
After such installation snippets works correctly.