CLI- soffice convert csv to pdf with semicolon as delimiter

637 views Asked by At

I want to convert the csv file to pdf file from command line using soffice command. But my csv file is colon separated instead of comma.

If I use command:

soffice --convert-to pdf ./sampleCSVFile.csv

This will give me pdf file but there are ; in the file. I found a article to convert to convert ods to csv with semicolon as delimiter: https://ask.libreoffice.org/t/cli-convert-ods-to-csv-with-semicolon-as-delimiter/5021

So similar to that I tried:

unoconv -f pdf -e FilterOptions="59,34,0,1" ./sampleCSVFile.csv

But it didn't help. sampleCSVFile.csv as follow:

Level 1;Level2
Level 1;Level2
Level 1 ;Level2 
Level 1;Level2
Level 1 ;Level2 
Level 1;Level2
Level 1;Level2
Level 1;Level2
Level 1;Level2

Is there a way to convert this colon separated csv file to pdf? (without changing the delimiter colon to comma)

1

There are 1 answers

2
K J On

Traditionally in DOS you used Edline to write a text file then either Copy or Type to the Con, Com or Lpn device (Line PriNter).

Windows still allows the print command to do that, and its possible to echo text via Notepad to a PDF virtual printer as a port. I will skip that as it not quite suited to your usage.

However by way of example, here I take your file and print virtually to PDF FilePort then call the Port result to the console. I could use one line rather than two but its more GUI visual.

enter image description here

However its not cross platform, and there are other simpler ways to convert text to pdf per platform.

You ask about Soffice and the principles are much the same since before PDFs were invented. soffice --infilter="calc_pdf_export" --convert-to pdf sampleCSVFile.csv

The text you transPort to exPort is the same as you imPort. However printing blind can add default print headers, footers (Page 1) and styles.

enter image description here

Because it is the most basic of methods

Whatever is in your Character Separated Values File.txt will be similar output. The only difference is there is no such thing as a tab or line wrap in a PDF (as its a virtual laser printer) not a mechanical line feed one.

enter image description here