Here is a Quick Action that uses a single action (run shell script) to convert specific types of files selected in the Finder to PDF. It is written to use the file's path as the output directory, so selecting a file on the Desktop will see the PDF bearing the original filename written to the Desktop.
Here is the Quick Action:

and the code to copy and paste into the blank Run Shell Script action:
#!/bin/zsh
: <<'COMMENT'
Quick Action to convert selected files in the Finder to PDF. Default output
directory is the same as the input file.
Zsh file modifers: a - absolute path
h - just the path, not the file name
Tested: macOS 11.6, Zsh 5.8
Dependency: Needs LibreOffice Suite installed.
VikingOSX, 2021-09-29, Apple Support Communities, No warranties expressed or implied.
COMMENT
source $HOME/.zshrc || :
for f in "${@}";
do
case "${f}" in
*.(txt|rtf|doc|docx|odt))
echo ${f} > ~/Desktop/rpt.txt
# convert document to PDF and place it in the same folder location
/Applications/LibreOffice.app/Contents/MacOS/soffice --headless --convert-to pdf \
--outdir "${f:a:h}" "${f:a}" 2> /dev/null
;;
*.(pdf|rtfd|webarchive))
continue;;
esac
done
exit 0
I named by Quick Action, To PDF. You must have the current LibreOffice Suite installed for this QA to work. Presently, LibreOffice needs macOS 10.12 (Sierra) or later.