Convert docx to pdf(image) /(odg to pdf)

My Purpose is to convert docx to pdf(each page is image)

I’d just export to PDF directly, and then used GhostScript (or any other capable tool, maybe ImageMagick) to convert the PDF to all-raster.

When I first time want to convert docx to pdf, I get libreoffice, then use it commandline, but when I want to finish the more operations(for the less commandline convertion provided), the commandline is limited.
So I try to use libreoffice uno api, Such operation can be accomplished by the api provied by it.
I also used PIL to finish the convertion, but it will increase the pdf size (5 times larger), I also use PIL decrease the image’s quality, which makes the image dispalyed worse.

It doesn’t mean that everything must be using the API. You use if to do what can’t be done in commandline - then use it for that, and leave the rest to proper tools. Or call the final rasterization external command from the script. Do you know, e.g., that Draw can’t have different page sizes in one document (yet)?

Do you expect anything else from conversion of the document to raster? You need to check your expectations, because it’s possible that you would be surprised to learn that it is always the same huge size increase.

A sample GhostScript command line:

gs -dBATCH -dNOPAUSE -sDEVICE=pdfimage24 -sOutputFile=path/to/output.pdf path/to/input.pdf

I tried to automatically convert some .docx files to .pdf files using libreoffice command line. And this works fine for me.

I created a directory with three .docx files, and used the following command.

call “C:\Program Files\LibreOffice\program\soffice.exe” --convert-to pdf --outdir “C:\sas\libreoffice_convert_test” “C:\sas\libreoffice_convert_test*.docx”

Please try it yourself

Note that your command line has nothing to do with the author’s stated goal of converting all pages to raster images.

sorry, missed a backslash in the command

call “C:\Program Files\LibreOffice\program\soffice.exe” --convert-to pdf --outdir “C:\sas\libreoffice_convert_test” “C:\sas\libreoffice_convert_test*.docx”

problems pasting. there must be a backslash before the *.docx

“C:\sas\libreoffice_convert_test\*.docx”

Use preformatted text instead of regular text.


For this is an ask site don’t use answers for your statements - only if it can solve the question.