I have been using LibreOffice in my rails app to convert my Doc to PDF using the command

/Applications/LibreOffice.app/Contents/MacOS/soffice --headless --convert-to pdf --outdir destination_path source_path/*.doc

in my rails app.

I planned to convert the entire Doc to PDF and display only a few pages of PDF, but it was not efficient to store the entire PDF only for preview purposes.

Is there a LibreOffice command or any other command that can help me export only the first few pages of Doc to PDF.


I needed to do that conversion some time ago, and I used unoconv in this way:

$ unoconv -f pdf -e PageRange=1-3 file.doc

It will convert to pdf only the first three pages.

Let me know if that works for you.

  • As per this code, the doc is converted and saved in the same folder. How can i change the destination folder? – Preethi Kumar Jan 27 '15 at 12:12
  • Try this option: -o /path/to/folder/ – skytux Jan 27 '15 at 15:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.