Getting the (pdf) preview of the first page of a word or excel document

Hi group,

is there a way to generate a pdf of the first page of a word document, using standard command line ?
… and no plugin … ?
this is mainly for macos , but if you have a solution for windows too or linux it’s ok.
I don’t want to have to install any library or app like libreoffice.
this should be possible from a default macos installation.

using qlmanage, I’m able to convert a docx to an html file, but then again how to convert it to a pdf page ?


You can use LibreOffice.

e.g. use Shell class with something like

/Applications/ --convert-to pdf --outdir outputFolder inputFile


1 Like

on Mac Quickview is able to preview them and then take a screenshot. I’ve no idea how you might automate that.

qlmanage is the command line quicklook is based upon.
I know how to make an html preview of the docx file using qlmanage
but then to convert the html to a pdf ?

According to this webpage, you can use qlmanage to generate a preview to a PNG file. With that you would create a PDF using the PDFDocument:

qlmanage -t -o thumbnails -s 1000 ~/Downloads/IMG_5494.jpeg
1 Like

seems I can manage with that. thanks.
anyone for a windows version ? :wink:

you do not need OpenOffice or any other similar software to make pdf.
Try Ctrl + P to print the document you want and instead of printer select pdf document. you may also select the page(s) you want to print(make pdf).

Be well.!!

I don’t know about more modern versions of Windows but certainly older ones didn’t have a PDF printer plugin as standard. You had to add one.

Windows 10 and 11 have “Microsoft print to PDF”

Yes modern windows ver 10 and 11 do have PDF printer plugin as standard. For earlier versions we were installing programs to act as PDF printer.

This is part of the original request. “Ctrl + P” and “print to PDF” are not command line options, right?

No, you have to be in the windows.
Not command line.
Let me see what i can do for you
as windows command line is the old old MSDOS commands
which i new very well.!!!

1 Like

So did I a very long time ago. :slight_smile:

1 Like

at standard command line you may use the command print directly to print a *.txt file syntax as follows:

PRINT [/D:device] [[drive:][path]filename[…]]

How does it know where to save it?

on windows suppose you have a word docx file, and no microsoft word installed…
on the mac you can preview the docx file using qlmanage see post above
but on windows ? is it possible ?
or on linux where microsoft word doesn’t even exists… libreoffice is not default on linux ?

my computer is dual boot (windows + ubuntu)
Well in Ubuntu you may install openoffice

At windows if you do not have office you may open
documents with the program write.exe (it is in the c:\windows ) folder.

Yes, but the request is for a preview to be created of the first page without user intervention. To a PDF or image file.

1 Like