Libreoffice: How do I covert .xlsx to .pdf format in command line with Khmer Unicode? - excel

Currently, I use this commandline to convert from excel file to pdf file.
soffice --headless --convert-to pdf --outdir . excel-file.xlsx
But the problem is there are not stable with Khmer Unicode (Cambodian) Fonts.

You can get proper Khmer Unicode render by set the "Complex Text Layout" to "Khmer".
To access this command,
Choose LibreOffice - Preferences - Language Settings - Languages - Complex Text Layout.

Related

Convert PDF file to XLSX using liberoffice command line

I'm using the below command which is intended to convert PDF files to XLSX format
soffice --infilter="writer_pdf_import" --convert-to xlsx:"Calc MS Excel 2007 XML" excel.pdf --outdir test.xlsx
But I'm getting an error message which states Application Error. I need to know what is wrong with my command and solution to convert PDF files to XLSX.

Converting xls to semicolon delimited csv with soffice commandline

I'm trying to convert xls files in a directory to csv format using soffice.
soffice --headless --convert-to csv *
It is giving comma separated version(obviously). Now I want to get semi-colon delimited csv.
I thought of replacing commas with semi-colons using vim command.
:%s/,/;/g
But it's not correct, as it replaces commas which are kept intentionally in original content. It has to delimit while converting from xls to csv.
How to get semi-colon delimited csv with soffice command line?
Finally, I got an answer. Adding output_filter_options worked like a charm.
--convert-to output_file_extension[:output_filter_name[:output_filter_options]] [--outdir output_dir] files
This wiki link helped. Here is what I did,
soffice --headless --convert-to csv:"Text - txt - csv (StarCalc)":59,34,0,1,1 *.xls
NOTE: It works with libre office 4.3 or higher version.

Unocov and libreoffice command line .svg conversion error

I'm trying to convert .png to .svg files using unoconv. The command line tool seems to work well with other formats, but is giving me the following error for conversion to svg files specifically:
$ unoconv -f svg ./sample.png
Unable to store document to file:///sample.svg (ErrCode 3088)
I've successfully used the tool with other formats, and the unoconv page even indicates that the .svg ouput format is supported.
I thought the issue might have something to do with the libreoffice used by unoconv, so I tried using the libreoffice command line tool directly. I used both of the following commands with no success:
./soffice --headless --invisible --convert-to svg --outdir ./result ./sample.png
./soffice --headless --invisible --convert-to svg:"impress_svg_Export" --outdir ./result ./sample.png
Both commands resulted in Error: Please reverify input parameters..., although the first command worked perfectly for when jpeg was used rather than svg.

How to convert pptx files to jpg or png (for each slide) on linux?

I want to convert a powerpoint presentation to multiple images. I already installed LibreOffice on my server and converting docx to pdf is no problem. pptx to pdf conversion does not work. I used following command line:
libreoffice --headless --convert-to pdf filename.pptx
Is there es way to convert pptx to pngs immediately or do I have to convert it to pdf first and then use ghostscript or something?
And what about the quality settings? Is there a way to choose the resolution of the resulting images?
Thanks in advance!
EDIT:
According to this link I was able to convert a pdf to images with the simple command line:
convert <filename>.pdf <filename>.jpg
(I guess you need LibreOffice and ImageMagick for it but not sure about it - worked on my server)
But there are still the problems with the pptx-to-pdf convert.
Thanks to googling and Sebastian Heyn's help I was able to create some high quality images with this line:
convert -density 400 my_filename.pdf -resize 2000x1500 my_filename%d.jpg
Please be patient after using it - you still can type soemthing into the unix console but it's processing. Just wait a few minutes and the jpg files will be created.
For further information about the options check out this link
P.S.: The aspect ratio of a pptx file doesn't seem to be exactly 4:3 because the resulting image size is 1950x1500
After Installing unoconv and LibreOffice you can use:
unoconv --export Quality=100 filename.pptx filename.pdf
to convert your presentation to a pdf. For further options look here.
Afterwards you can - as already said above - use:
convert -density 400 my_filename.pdf -resize 2000x1500 my_filename%d.jpg
to receive the images.
Convertion PPTX to PNG/JPG
This solution requires LibreOffice ( soffice ) and Ghostscript ( gs )
sudo apt install libreoffice ghostscript
Then two steps:
PPTX -> PDF
soffice --headless --convert-to pdf prezentacja.pptx
PDF -> PNG/JPG
gs -sDEVICE=pngalpha -o slajd-%02d.png -r96 prezentacja.pdf
-o slajd-%02d.png - output to file, %02d slajd number, two digits
-r96 - resolution:
96 -> 1280x720
144 -> 1920x1080
Not sure about libreoffice, but afaik its the only program to deal with pptx files.
I found this http://ask.libreoffice.org/en/question/23851/converting-pptx-to-pdf-issue/
If you have pdfs you can use imagemagick to output any quality pictures

encoding problem?

i work with txt files, and i recently found e.g. these characters in a few of them:
http://pastebin.com/raw.php?i=Bdj6J3f4
what could these characters be? wrong character-encoding? i just want to use normal UTF-8 TXT files, but when i use:
iconv -t UTF-8 input.txt > output.txt
it's still the same.
When i open the files in gedit, copy+paste them in another txt files, then there's no characters like in the ones in pastebin. so gedit can solve this problem, it encodes the TXT files well. but there are too many txt files.
why are there http://pastebin.com/raw.php?i=Bdj6J3f4 -like chars in the text files? can they be converted to "normal chars"? I can't see e.g.: the "Ì" char, when i open the files with vim, only after i "work with them" (e.g.: awk, etc)
It would help if you posted the actual binary content of your file (perhaps by using the output of od -t x1). The pastebin returns this as HTML:
"Ì"
"Ã"
"é"
The first line corresponds to U+00C3 U+0152. THe last line corresponds to U+00C3 U+00A9, which is the string "\ux00e9" in UTF ("\xc3\xa9") with the UTF-8 bytes reinterpreted as Latin-1.
From man iconv:
The iconv program converts text from
one encoding to another encoding. More
precisely, it converts from the
encoding given for the -f option to
the encoding given for the -t option.
Either of these encodings defaults to
the encoding of the current locale
Because you didn't specify the -f option it assumes the file is encoded with your current locale's encoding (probably UTF-8), which apparently is not true. Your text editors (gedit, vim) do some encoding detection - you can check which encoding do they detect (I don't know how - I don't use any of them) and use that as -f iconv option (or save the open file with your desired encoding using one of those text editors).
You can also use some tool for encoding detection like Python chardet module:
$ python -c "import chardet as c; print c.detect(open('file.txt').read(4096))"
{'confidence': 0.7331842298102511, 'encoding': 'ISO-8859-2'}
..solved !
how:
i just right clicked on the folders containing the TXT files, and pasted them to another folder.. :O and presto..theres no more ugly chars..

Resources